Every host runs node_exporter, cAdvisor (now against Podman), Alloy and the security-metrics script, on its private address. Each service declares its own expected ports, users and privileged containers next to its definition, so the security baseline follows the config instead of a separate inventory list. On ops: Prometheus, Loki, Grafana, the blackbox prober and the Postgres exporter, with the same scrape jobs, probes, retention, dashboards and 33 alert rules. Two rules matched container-era names and now match the native ones: Forgejo's log is unit forgejo.service, Grafana's route is grafana@file. Grafana keeps its default secret_key on production, because its database was written with it; rotating it is a separate step. Prometheus, Grafana and Alloy come from nixos-unstable: their data is from newer versions than 26.05 ships. LLMNR and mDNS are off: the baseline flagged them as public listeners. Tried on the rehearsal pair: all 28 scrape targets up, logs from both hosts in Loki, Grafana WireGuard-only, no unexpected port, user or container on either host. Assisted-by: Claude:opus-5-5
544 lines
27 KiB
YAML
544 lines
27 KiB
YAML
# Managed by Ansible (role monitoring).
|
|
apiVersion: 1
|
|
groups:
|
|
- orgId: 1
|
|
name: asxpio
|
|
folder: Alerts
|
|
interval: 1m
|
|
rules:
|
|
- uid: host-down
|
|
title: "Host down"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "1 - up{job=\"node\"}", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 2m
|
|
labels: { severity: critical }
|
|
annotations: { summary: "{{ $labels.host }} stopped answering (node_exporter over the VPC)" }
|
|
- uid: target-down
|
|
title: "Scrape target down"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "up{job!~\"node|probe_.*\"} == 0", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [-1] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 5m
|
|
labels: { severity: warning }
|
|
annotations: { summary: "{{ $labels.job }} on {{ $labels.instance }} is not answering metrics scrapes" }
|
|
- uid: probe-down
|
|
title: "Service down (outside-in probe)"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "1 - probe_success", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 2m
|
|
labels: { severity: critical }
|
|
annotations: { summary: "{{ $labels.probe }} ({{ $labels.instance }}) is not reachable" }
|
|
- uid: cert-expiry
|
|
title: "Certificate expires soon"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "(probe_ssl_earliest_cert_expiry - time()) / 86400", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: lt, params: [14] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 1h
|
|
labels: { severity: warning }
|
|
annotations: { summary: "{{ $labels.probe }}: certificate expires in {{ $values.A.Value | printf \"%.0f\" }} days" }
|
|
- uid: disk-full
|
|
title: "Disk almost full"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "100 * (1 - node_filesystem_avail_bytes{fstype!~\"tmpfs|overlay|squashfs|fuse.*\"} / node_filesystem_size_bytes{fstype!~\"tmpfs|overlay|squashfs|fuse.*\"})", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [85] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 10m
|
|
labels: { severity: warning }
|
|
annotations: { summary: "{{ $labels.host }} {{ $labels.mountpoint }} is {{ $values.A.Value | printf \"%.0f\" }}% full" }
|
|
- uid: memory-low
|
|
title: "Memory almost exhausted"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "100 * (1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [92] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 10m
|
|
labels: { severity: warning }
|
|
annotations: { summary: "{{ $labels.host }} memory is {{ $values.A.Value | printf \"%.0f\" }}% used" }
|
|
- uid: container-restarting
|
|
title: "Container restart-looping"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "changes(container_start_time_seconds{name!=\"\"}[15m])", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [2] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 0m
|
|
labels: { severity: critical }
|
|
annotations: { summary: "{{ $labels.name }} on {{ $labels.host }} restarted {{ $values.A.Value | printf \"%.0f\" }} times in 15 minutes" }
|
|
- uid: postgres-down
|
|
title: "Postgres down"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "pg_up", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: lt, params: [1] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 1m
|
|
labels: { severity: critical }
|
|
annotations: { summary: "Postgres (storage) is not answering" }
|
|
- uid: backup-stale
|
|
title: "Backup stale"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "(time() - restic_backup_last_success_timestamp_seconds) / 3600", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [26] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 0m
|
|
labels: { severity: warning }
|
|
annotations: { summary: "restic on {{ $labels.host }}: last good backup {{ $values.A.Value | printf \"%.0f\" }} hours ago" }
|
|
- uid: xmpp-cert-sync-stale
|
|
title: "XMPP certificate sync stale"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "(time() - xmpp_cert_sync_last_success_timestamp_seconds) / 3600", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [50] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 0m
|
|
labels: { severity: warning }
|
|
annotations: { summary: "xmpp-cert-sync on asxpio-ops last succeeded {{ $values.A.Value | printf \"%.0f\" }} hours ago (journalctl -u xmpp-cert-sync)" }
|
|
- uid: xmpp-cert-outdated
|
|
title: "XMPP serves an older certificate than Traefik has"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "((max(xmpp_cert_source_not_after_timestamp_seconds{cert=\"asxp.io\"}) - min(probe_ssl_earliest_cert_expiry{probe=\"xmpp c2s tls asxp.io\"})) / 86400 > 1) or ((max(xmpp_cert_source_not_after_timestamp_seconds{cert=\"xmpp.asxp.io\"}) - min(probe_ssl_earliest_cert_expiry{probe=\"xmpp c2s tls\"})) / 86400 > 1)", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [1] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 6h
|
|
labels: { severity: warning }
|
|
annotations: { summary: "ejabberd's certificate expires {{ $values.A.Value | printf \"%.0f\" }} days before the one Traefik holds: the push or the reload failed" }
|
|
- uid: replica-stale
|
|
title: "Bucket replica stale"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "(time() - s3_replicate_last_success_timestamp_seconds) / 3600", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [26] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 0m
|
|
labels: { severity: warning }
|
|
annotations: { summary: "hel1 -> fsn1 bucket replica: last good run {{ $values.A.Value | printf \"%.0f\" }} hours ago" }
|
|
# Security: unexpected peers, devices, accounts, ports and containers
|
|
# (metrics from security-metrics, role monitoring_agent) and logins
|
|
# (Loki). The baseline lives in that role's defaults and in host_vars.
|
|
- orgId: 1
|
|
name: security
|
|
folder: Alerts
|
|
interval: 1m
|
|
rules:
|
|
- uid: sec-wg-peer-unknown
|
|
title: "Unknown WireGuard peer"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "security_wg_peer_info{known=\"false\"}", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 0m
|
|
labels: { severity: critical }
|
|
annotations: { summary: "WireGuard peer {{ $labels.peer }} ({{ $labels.allowed_ips }}) on {{ $labels.host }} is not in wireguard_clients" }
|
|
- uid: sec-wg-endpoint-new
|
|
title: "WireGuard peer on a new network"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "security_wg_peer_endpoint_info unless on (host, interface, peer, net) max_over_time(security_wg_peer_endpoint_info[14d] offset 30m) and on (host) (security_audit_last_run_timestamp_seconds offset 1d)", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 0m
|
|
labels: { severity: warning }
|
|
annotations: { summary: "{{ $labels.peer }} connected to {{ $labels.host }} from {{ $labels.endpoint }}: no address in {{ $labels.net }} was seen for it in 14 days" }
|
|
- uid: sec-vpc-host-unknown
|
|
title: "Unknown device on the private network"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "security_vpc_host_info{known=\"false\"}", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 2m
|
|
labels: { severity: critical }
|
|
annotations: { summary: "{{ $labels.ip }} answers on the VPC (seen from {{ $labels.host }}) and is not in security_vpc_hosts" }
|
|
- uid: sec-hcloud-server-unknown
|
|
title: "Unknown server in the Hetzner project"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "up{job=\"hcloud\",known=\"false\"}", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 2m
|
|
labels: { severity: critical }
|
|
annotations: { summary: "Server {{ $labels.server }} ({{ $labels.type }}, {{ $labels.public_ip }}, private {{ $labels.private_ip }}) exists in the Hetzner project and is not in monitoring_hcloud_servers" }
|
|
- uid: sec-hcloud-inventory-stale
|
|
title: "Hetzner server list not updating"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "absent(up{job=\"hcloud\"}) or increase(prometheus_sd_refresh_failures_total{mechanism=\"hetzner\"}[30m]) > 3", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 10m
|
|
labels: { severity: critical }
|
|
annotations: { summary: "Prometheus cannot list the servers of the Hetzner project (token revoked or API unreachable): new servers go unnoticed" }
|
|
- uid: sec-user-unknown
|
|
title: "Unknown login account"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "security_user_info{known=\"false\"}", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 0m
|
|
labels: { severity: critical }
|
|
annotations: { summary: "{{ $labels.host }}: account {{ $labels.user }} (uid {{ $labels.uid }}, {{ $labels.shell }}) is not in security_login_users" }
|
|
- uid: sec-group-member-unknown
|
|
title: "Unknown member of sudo or docker"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "security_group_member_info{known=\"false\"}", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 0m
|
|
labels: { severity: critical }
|
|
annotations: { summary: "{{ $labels.host }}: {{ $labels.user }} is in group {{ $labels.group }}" }
|
|
- uid: sec-files-changed
|
|
title: "Access files changed"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "changes(security_fileset_hash[15m])", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 0m
|
|
labels: { severity: warning }
|
|
annotations: { summary: "{{ $labels.host }}: a file in set {{ $labels.set }} changed (accounts, sudoers, sshd, wireguard or authorized_keys)" }
|
|
- uid: sec-port-unknown
|
|
title: "Unexpected listening port"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "security_listening_port_info{known=\"false\"}", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 3m
|
|
labels: { severity: warning }
|
|
annotations: { summary: "{{ $labels.host }}: {{ $labels.process }} listens on {{ $labels.proto }}/{{ $labels.port }} ({{ $labels.scope }}), not in security_ports" }
|
|
- uid: sec-container-privileged
|
|
title: "Container with unexpected host access"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "security_container_privileged_info{known=\"false\"}", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 0m
|
|
labels: { severity: critical }
|
|
annotations: { summary: "{{ $labels.host }}: container {{ $labels.name }} runs with {{ $labels.flags }}" }
|
|
- uid: sec-container-new
|
|
title: "New container"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "group by (host, name) (container_last_seen{name!=\"\", name!~\"[a-z]+_[a-z]+\"}) unless on (host, name) group by (host, name) (max_over_time(container_last_seen{name!=\"\"}[7d] offset 30m))", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 0m
|
|
labels: { severity: warning }
|
|
annotations: { summary: "{{ $labels.host }}: container {{ $labels.name }} was not seen in the last 7 days" }
|
|
- uid: sec-forgejo-new
|
|
title: "Forgejo: new user, key or runner"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "security_forgejo_objects{kind=~\"users|admins|ssh_keys|deploy_keys|runners\"} - security_forgejo_objects offset 15m", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 0m
|
|
labels: { severity: warning }
|
|
annotations: { summary: "Forgejo: {{ $labels.kind }} grew by {{ $values.A.Value | printf \"%.0f\" }}" }
|
|
- uid: sec-ssh-outside
|
|
title: "SSH login from outside WireGuard"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 300, to: 0 }
|
|
datasourceUid: loki
|
|
model: { refId: A, expr: "sum by (host, user, src) (count_over_time({job=\"journal\", unit=\"ssh.service\"} |~ `Accepted \\S+ for ` !~ `Accepted \\S+ for git from ` | regexp `Accepted \\S+ for (?P<user>\\S+) from (?P<src>\\S+)` | src !~ `10\\.20\\.0\\.\\d+|10\\.10\\.(\\d|1[0-5])\\.\\d+` [5m]))", queryType: instant, intervalMs: 60000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 0m
|
|
labels: { severity: critical }
|
|
annotations: { summary: "{{ $labels.host }}: {{ $labels.user }} logged in over SSH from {{ $labels.src }}" }
|
|
- uid: sec-ssh-failed-internal
|
|
title: "Failed SSH logins from inside"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 600, to: 0 }
|
|
datasourceUid: loki
|
|
model: { refId: A, expr: "sum by (host) (count_over_time({job=\"journal\", unit=\"ssh.service\"} |~ `Failed \\S+ for |Invalid user |Connection closed by (authenticating|invalid) user ` |~ ` (10\\.20\\.0\\.\\d+|10\\.10\\.(\\d|1[0-5])\\.\\d+) port ` [10m]))", queryType: instant, intervalMs: 60000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [2] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 0m
|
|
labels: { severity: warning }
|
|
annotations: { summary: "{{ $labels.host }}: {{ $values.A.Value | printf \"%.0f\" }} failed SSH logins from WireGuard or VPC addresses in 10 minutes" }
|
|
- uid: sec-ssh-failed-burst
|
|
title: "Failed SSH logins spike"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 600, to: 0 }
|
|
datasourceUid: loki
|
|
model: { refId: A, expr: "sum by (host) (count_over_time({job=\"journal\", unit=\"ssh.service\"} |~ `Failed \\S+ for |Invalid user |Connection closed by (authenticating|invalid) user ` [10m]))", queryType: instant, intervalMs: 60000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [150] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 0m
|
|
labels: { severity: warning }
|
|
annotations: { summary: "{{ $labels.host }}: {{ $values.A.Value | printf \"%.0f\" }} failed SSH logins in 10 minutes (usual: about 10)" }
|
|
- uid: sec-login-failed-forgejo
|
|
title: "Failed logins: Forgejo"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 600, to: 0 }
|
|
datasourceUid: loki
|
|
model: { refId: A, expr: "sum(count_over_time({unit=\"forgejo.service\"} |= `Failed authentication attempt` [10m]))", queryType: instant, intervalMs: 60000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [10] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 0m
|
|
labels: { severity: warning }
|
|
annotations: { summary: "Forgejo: {{ $values.A.Value | printf \"%.0f\" }} failed logins in 10 minutes" }
|
|
- uid: sec-login-failed-grafana
|
|
title: "Failed logins: Grafana"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 600, to: 0 }
|
|
datasourceUid: loki
|
|
model: { refId: A, expr: "sum(count_over_time({job=\"traefik-access\"} |= `\"grafana@file\"` |~ `\"POST /login HTTP/[0-9.]+\" 401 ` [10m]))", queryType: instant, intervalMs: 60000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [4] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 0m
|
|
labels: { severity: warning }
|
|
annotations: { summary: "Grafana: {{ $values.A.Value | printf \"%.0f\" }} failed logins in 10 minutes" }
|
|
- uid: sec-login-failed-asxpio
|
|
title: "Failed logins: asxp.io admin"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 600, to: 0 }
|
|
datasourceUid: loki
|
|
model: { refId: A, expr: "sum(count_over_time({job=\"traefik-access\"} |= `\"asxpio@docker\"` |~ `\"POST /admin/login HTTP/[0-9.]+\" (401|429) ` [10m]))", queryType: instant, intervalMs: 60000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [4] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 0m
|
|
labels: { severity: warning }
|
|
annotations: { summary: "asxp.io admin: {{ $values.A.Value | printf \"%.0f\" }} failed or rate-limited logins in 10 minutes" }
|
|
- uid: sec-logs-stopped
|
|
title: "Logs stopped arriving"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "sum by (host) (rate(loki_write_sent_entries_total[10m]))", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: lt, params: [0.001] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 5m
|
|
labels: { severity: critical }
|
|
annotations: { summary: "Alloy on {{ $labels.host }} has sent Loki nothing for 10 minutes: every log-based alert is blind" }
|
|
- uid: sec-audit-stale
|
|
title: "Security metrics stale"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "(time() - security_audit_last_run_timestamp_seconds > 600) or on (host) (up{job=\"node\"} == 1 unless on (host) security_audit_last_run_timestamp_seconds)", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 5m
|
|
labels: { severity: critical }
|
|
annotations: { summary: "security-metrics on {{ $labels.host }} has not written its file for 10 minutes, or the file is gone" }
|
|
- uid: sec-audit-check-failed
|
|
title: "Security check failing"
|
|
condition: C
|
|
data:
|
|
- refId: A
|
|
relativeTimeRange: { from: 900, to: 0 }
|
|
datasourceUid: prometheus
|
|
model: { refId: A, expr: "1 - security_audit_check_ok", instant: true, intervalMs: 30000, maxDataPoints: 43200 }
|
|
- refId: C
|
|
datasourceUid: __expr__
|
|
model: { refId: C, type: threshold, expression: A, conditions: [ { evaluator: { type: gt, params: [0] } } ] }
|
|
noDataState: OK
|
|
execErrState: Error
|
|
for: 5m
|
|
labels: { severity: warning }
|
|
annotations: { summary: "security-metrics on {{ $labels.host }}: check {{ $labels.check }} fails (journalctl -u security-metrics)" }
|