Skip to content

Instantly share code, notes, and snippets.

View asachs01's full-sized avatar
Caffeinated.

Aaron Sachs asachs01

Caffeinated.
View GitHub Profile
@asachs01
asachs01 / README.md
Last active January 30, 2024 13:30
Scripts used for installing Prometheus on Windows & Linux

Aaron's Scripts for Installing the Prometheus Node Exporter, Windows Exporter and Promtail

This is a collection of the scripts that I'm using to install the Prometheus node exporter, Windows exporter and promtail in my hoem lab environments. There are certainly more battle-tested solutions (i.e., the Ansible Prometheus collection is 🤌🤌🤌), but these work well enough to use in small environments. Feel free to use and abuse.

NOTE: Rather than reinventing the wheel on Linux, I'm using https://github.com/carlocorradini/node_exporter_installer to install the node exporter.

NOTE: While yes, Windows does have the ability to create a service natively, I've found that starting the Promtail binary via the natively supported method isn't possible. I'm using WinSW to create a service that will start the Promtail binary.

@asachs01
asachs01 / windows_account_lockouts.json
Created October 17, 2023 18:23
Grafana Dashboard for Windows Account Lockouts
{
"__inputs": [
{
"name": "DS_LOKI",
"label": "Loki",
"description": "",
"type": "datasource",
"pluginId": "loki",
"pluginName": "Loki"
}
@asachs01
asachs01 / event4740_loki_logql_expr.txt
Created September 27, 2023 13:05
A Grafana Loki logql expression for extracting usernames and lockout sources for event 4740
{job="windows_security"}
| json
| event_id = `4740`
| line_format "{{.event_data}}"
| regexp "'TargetUserName'>(?P<UserName>[^<]+)<"
| regexp "'TargetDomainName'>(?P<LockoutSource>[^<]+)<"
@asachs01
asachs01 / install_promtail.ps1
Last active September 27, 2023 14:11
A Powershell Script for Installing Promtail on Windows
param (
[string]$hostUrl = $(if ($env:PROMTAIL_HOST_URL) { $env:PROMTAIL_HOST_URL } else { "http://localhost:3100/loki/api/v1/push" }),
[string]$eventTypesStr = $(if ($env:PROMTAIL_EVENT_TYPES) { $env:PROMTAIL_EVENT_TYPES } else { "Application,Security,System" })
)
# Variables
$latestReleaseUrl = "https://github.com/grafana/loki/releases/latest"
$repoUrl = "https://github.com/grafana/loki"
$winswUrl = "https://github.com/winsw/winsw/releases/download/v2.12.0/WinSW-x64.exe"
$outputDir = "C:\"
@asachs01
asachs01 / graylog_metrics.json
Created October 31, 2021 02:18
Graylog Grafana Dashboard
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
@asachs01
asachs01 / graylog_api_routes.json
Created November 24, 2020 02:31
A listing of all api endpoints & routes for Graylog
{
"models": {},
"apiVersion": "4.0.0+9376305",
"swaggerVersion": "1.2",
"apis": [],
"basePath": "http://192.168.156.229:9000/api",
"resourcePath": "/streams/streamid/alerts/alertId/history"
}
{
"models": {
@asachs01
asachs01 / docker-compose.yml
Last active April 1, 2020 16:46
Sensu Sandbox Docker Compose
---
version: "3"
services:
sensu-backend:
image: sensu/sensu:latest
ports:
- 3000:3000
- 8080:8080
- 8081:8081
volumes:
@asachs01
asachs01 / sensuctl-aliases
Last active December 17, 2019 17:00
Aliases I use to make operating Sensu Go like buttah
‎‎​alias sensuctl-whoami="sensuctl config view --format yaml"
etcd-advertise-client-urls: https://192.168.1.1:2379
etcd-initial-advertise-peer-urls: https://192.168.1.1:2380
etcd-initial-cluster: backend-0=https://backend-0.example.com:2380,backend-1=https://backend-1.example.com:2380,backend-2=https://backend-2.example.com:2380
etcd-initial-cluster-state: new
etcd-listen-client-urls: https://192.168.1.1:2379
etcd-listen-peer-urls: https://0.0.0.0:2380
etcd-name: backend-1
log-level: debug
state-dir: /var/lib/sensu/sensu-backend
cert-file: "/etc/pki/tls/certs/cert.pem"
---
- name: Install, configure and run Sensu backend in debug mode
hosts: monitoring-sensu
remote_user: centos
become: true
become_method: sudo
collections: [sensu.sensu_go]
roles:
- role: backend
backend_config: