diff --git a/.forgejo/workflows/nixos.yaml b/.forgejo/workflows/nixos.yaml new file mode 100644 index 0000000..d4b3144 --- /dev/null +++ b/.forgejo/workflows/nixos.yaml @@ -0,0 +1,90 @@ +name: nixos + +# Every push: evaluate every host, so a broken config never reaches main. +# main: build and switch each production host that already runs NixOS. +# A host still on Debian is skipped (it is checked for /etc/NIXOS first), +# so this job cannot touch a server before its conversion. +# +# Secret: SSH_DEPLOY_KEY (user deploy). Service secrets are decrypted on +# the hosts by sops-nix; CI holds none of them. +# +# Switching asxpio-services can restart the runner that runs this job: +# the change lands, the job shows as cancelled, the next run confirms. + +run-name: "${{ github.ref == 'refs/heads/main' && 'deploy' || 'evaluate' }}: ${{ github.ref_name }}" + +on: + push: + paths: + - 'nixos/**' + - '.forgejo/workflows/nixos.yaml' + workflow_dispatch: + +jobs: + nixos: + runs-on: nix-latest + env: + NIX_CONFIG: | + experimental-features = nix-command flakes + build-users-group = + sandbox = false + steps: + - name: Prepare container for actions + run: nix-env -iA nixpkgs.nodejs_22 + + - name: Checkout + uses: actions/checkout@v7.0.1 + + # Job containers are unprivileged, so Nix cannot sandbox builds in + # them. Evaluating catches config errors; the build itself happens + # on each server during the deploy. + - name: Evaluate + working-directory: nixos + run: | + for host in asxpio-ops asxpio-services rehearsal-ops rehearsal-services; do + nix eval --raw ".#nixosConfigurations.$host.config.system.build.toplevel.drvPath" + echo + done + + - name: Set up SSH + if: github.ref == 'refs/heads/main' + env: + SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} + run: | + umask 077 + mkdir -p ~/.ssh + printf '%s\n' "$SSH_DEPLOY_KEY" > ~/.ssh/id_ed25519 + cp known_hosts ~/.ssh/known_hosts + # The runner's own host is reached through asxpio-ops: a job + # container connecting to its host arrives from a bridge address + # that sshd refuses. + cat > ~/.ssh/config <<'EOF' + Host asxpio-ops + HostName 10.10.0.10 + User deploy + Host asxpio-services + HostName 10.10.0.20 + User deploy + ProxyJump asxpio-ops + EOF + + - name: Deploy + if: github.ref == 'refs/heads/main' + working-directory: nixos + # Ops first: services reaches it for WireGuard, logs and Forgejo + run: | + # Tools from the flake's dev shell: the same pinned nixpkgs + for host in asxpio-ops asxpio-services; do + os=$(nix develop -c ssh "$host" 'test -e /etc/NIXOS && echo nixos || echo other') + if [ "$os" != nixos ]; then + echo "$host: not NixOS yet, skipped" + continue + fi + echo "== $host" + nix develop -c nixos-rebuild switch --flake ".#$host" \ + --target-host "$host" --build-host "$host" --sudo + done + + - name: Remove credentials + if: always() + run: rm -f ~/.ssh/id_ed25519 diff --git a/MIGRATION.md b/MIGRATION.md new file mode 100644 index 0000000..9742598 --- /dev/null +++ b/MIGRATION.md @@ -0,0 +1,326 @@ +# Moving production from Ansible and Terraform to NixOS and OpenTofu + +The plan and the runbook. Delete this file when the last step is done. + +**End state:** both servers run NixOS built from `nixos/`, deployed by +`.forgejo/workflows/nixos.yaml`; services are native NixOS services +where nixpkgs has a module and Podman containers otherwise; no Docker +daemon, no Ansible; infrastructure in `terraform/` is applied with +OpenTofu. The servers themselves stay: they are billed below today's +list price, so each one is converted **in place** and never recreated. + +**Nothing in production changes without the owner's go-ahead for that +step.** Every step below that touches a server says so. + +## Where things stand (2026-11-17) + +Production is untouched: both servers run Debian, deployed by Ansible +from `main`. Branch `nix` holds the new system, and every part of it ran +on the rehearsal pair (two cx23 in the personal project), most of it on +a restored copy of last night's production data: + +| Area | Rehearsed | Notes | +|---|---|---| +| First boot (cloud-init + nixos-infect) | yes | 3–4 min to a bare NixOS | +| In-place conversion with Docker data | yes | data kept under `/old-root` | +| Base, SSH, firewall, WireGuard, sops | yes | same host keys, same peers | +| Postgres 18.7, Garage 2.5, Forgejo 17 | yes, prod data | roles, buckets, keys from sops | +| Traefik, label routing via Podman | yes | certificates: staging CA only | +| asxpio, datacenterbingo on Podman | yes, prod data | mail and IndexNow disabled | +| Minecraft, SillyTavern, Xray, ACME forward | yes, prod data | Discord plugin kept off | +| XMPP (ejabberd, apushd, tackygram) | dummy data only | never started on prod data on purpose | +| CI runner + jobs | yes | against the rehearsal Forgejo | +| Backup, restore, bucket replica | yes | replica: config only, no run | +| Monitoring, logs, alerts, security baseline | yes | 28 targets up, 0 unknown items | +| CI deploy job | evaluate only | deploys nothing until a host is NixOS | + +What each service became, and why: + +| Was (Ansible role, container) | Now | +|---|---| +| `base`, `ssh_hardening`, `swap` | `modules/base.nix`, `hetzner.nix` | +| `wireguard` | `modules/wireguard.nix`, keys in sops | +| `traefik` | native `services.traefik`; native services' routes in Nix, apps keep labels | +| `forgejo` | native `services.forgejo` as user `git`; no SSH passthrough needed | +| storage repo: Postgres, Garage | native `services.postgresql`, `services.garage` (2.x pinned) | +| `monitoring`, `monitoring_agent` | native Prometheus, Loki, Grafana, Alloy, exporters, cAdvisor (Podman) | +| `restic_backup`, `s3_replicate`, `crawler_alert`, `xmpp_cert_sync` | systemd units from Nix, same scripts and schedules | +| `forgejo_runner`, `forgejo_runner_interop` | native runner module; interop as its own unit | +| `sillytavern`, `minecraft`, `xray`, `acme_forward` | native modules | +| `xmpp` | Podman containers (a custom build, not nixpkgs' ejabberd) | +| App stacks (asxpio, datacenterbingo, blog, czsk, vhpbot) | unchanged compose stacks on Podman, deployed by their own CI | + +## Phase 0: preparation (no downtime) + +Everything here can be done while Ansible still runs production. + +1. **Push `nix`** and let CI evaluate it. It does not deploy: the job + skips any host without `/etc/NIXOS`, and branches never deploy. + +2. **OpenTofu.** Once, from a workstation: + + ```sh + cd terraform + tofu init -reconfigure + tofu plan # expected: only the new user_data output + tofu apply # writes the output; changes no resource + ``` + + The state is the one Terraform wrote; the servers ignore + `user_data`, `image` and `ssh_keys`, so nothing can be replaced. + +3. **App repositories: healthcheck in the compose file.** Podman ignores + the `HEALTHCHECK` of OCI-format images, which is what the app CI + builds, so the deploy's wait for "healthy" would time out on NixOS. + Copy each image's healthcheck into its compose file (asxpio, + datacenterbingo, blog; czsk has none). Under Docker the result is the + same, so this ships now, through the normal deploy. The exact block + for asxpio: + + ```yaml + healthcheck: + test: ["CMD-SHELL","ruby -rnet/http -e 'port = ENV.fetch(\"PUMA_PORT\", \"3000\"); exit(Net::HTTP.get_response(URI(\"http://127.0.0.1:#{port}/healthz\")).code == \"200\" ? 0 : 1)'"] + interval: 30s + timeout: 5s + start_period: 20s + retries: 3 + ``` + + Read the others with `skopeo inspect --raw --config docker://`. + +4. **Storage repo: stop its deploys.** Its CI starts Postgres and Garage + containers in `/opt/storage`; after the ops conversion those would + fight the native services for their ports. Disable the deploy + workflow (or archive the repo) before Phase 2. Its secrets + (`ASXPIO_*`, `BINGO_*`, `PUBLIC_*`) stay: the app repos use the same + values. + +5. **Secrets.** `nixos/secrets/asxpio-*.yaml` were filled on 2026-11-16 + and 17 from the Ansible vault, `/opt/storage/.env` and the Garage RPC + secret. If any of those changed since, update the sops file + (`sops nixos/secrets/asxpio-ops.yaml`). Keys: WireGuard, Xray config, + restic password, S3, alert SMTP, Forgejo (secret key, internal token, + JWT secrets, SMTP, metrics token), Postgres roles, Garage keys and RPC + secret, Traefik ACME email, runner tokens, Grafana admin password, + Hetzner read-only token. The vault and sops must agree until Ansible + is gone. + +6. **Freeze.** On conversion day: no pushes to the app repos, to `iac`, + or Renovate merges, from the start of a phase until its checks pass. + +7. **Rehearse once more against the latest backups** (both hosts), on a + fresh rehearsal pair, following `nixos/README.md` → Rehearsal and the + rules at the end of this file. It costs about €0.02 an hour and is the + only way to know that the night's data still fits the config. + +**Go/no-go for Phase 1:** steps 1–7 done, last night's restic backup of +both hosts green, a Hetzner snapshot of the host just taken. + +## Phase 1: asxpio-services (owner's go-ahead required) + +Downtime about 15–20 minutes for Minecraft, SillyTavern, XMPP, Xray and +CI. asxpio-ops and everything on it stays up. Services first: it has +less data and nothing on ops depends on it. + +From a workstation on WireGuard, in the repo: + +1. **Snapshot** (the rollback): + + ```sh + hcloud server create-image --type snapshot --description pre-nixos asxpio-services + ``` + +2. **Stop what writes, then Docker:** + + ```sh + ssh root@10.20.0.20 'docker stop -t 120 minecraft; cd /opt/xmpp && docker compose stop; \ + docker stop forgejo-runner forgejo-runner-interop sillytavern xray acme-forward; \ + systemctl stop docker.socket docker containerd' + ``` + +3. **Convert** (the same lines cloud-init runs; `tofu output -json + user_data | jq -r '."asxpio-services"'` shows them filled in). Write + `/etc/nixos/bootstrap.nix` with the content from there, then: + + ```sh + ssh root@10.20.0.20 'umount -l /tmp; curl -fsSL -o /root/nixos-infect \ + https://raw.githubusercontent.com/elitak/nixos-infect/40f62a680bb0e8f2f607d79abfaaecd99d59401c/nixos-infect \ + && echo "4354bd68773b41da65c0e815202c43c8549713b3ed3ff6381c71fbc0b0a840ab /root/nixos-infect" | sha256sum -c \ + && PROVIDER=hetznercloud NIX_CHANNEL=nixos-26.05 NIXOS_IMPORT=./bootstrap.nix \ + setsid bash /root/nixos-infect > /var/log/nixos-infect.log 2>&1 < /dev/null &' + ``` + + It reboots into a bare NixOS after about four minutes. WireGuard is + down until step 4; reach it through ops over the private network: + `ssh -J root@10.20.0.10 root@10.10.0.20`. + +4. **Switch to the flake** (through ops, as above): + + ```sh + cd nixos + NIX_SSHOPTS="-J root@10.20.0.10" nixos-rebuild switch --flake .#asxpio-services \ + --target-host root@10.10.0.20 --build-host root@10.10.0.20 + ``` + + Services that own data stay stopped: the marker file is missing. + +5. **Move the data and start everything:** + + ```sh + ssh root@10.20.0.20 'bash -s /old-root' < migration/services-data.sh + ssh root@10.20.0.20 reboot + ``` + +6. **Check:** + - `wg show` on ops: the services peer has a fresh handshake. + - `systemctl --failed` empty; Grafana's security panel shows nothing + unknown for asxpio-services. + - Minecraft log reaches `Done`; join once (Java and Bedrock). + - SillyTavern on `http://10.20.0.20:8000`. + - An XMPP client logs in; a message to a contact goes through. + - Forgejo → Site administration → Runners: the new runner idle (it + registered itself again); delete the old, offline entry. Push an + empty commit to an app repo and watch a full CI run. + - `systemctl start restic-backup` succeeds (it continues the same + repositories). + +**Rollback:** until step 3, start Docker and the containers again. +After it: `hcloud server disable-protection asxpio-services rebuild`, +rebuild from the snapshot, `tofu apply`. Debian comes back as it was at +the snapshot. + +After a week without surprises: `rm -rf /old-root`, delete the snapshot. + +## Phase 2: asxpio-ops (owner's go-ahead required) + +Downtime about 30–45 minutes for every site, Forgejo, the registry and +monitoring: the conversion itself, the first build of the system, then +pulling each app image again (Docker's image store does not carry over). +Announce it. + +ops is the WireGuard hub, so during the window the admin network is +down. Until step 4, ops is reachable as root on its public address +(nixos-infect's bootstrap system has no address restriction); from step +4 on, over WireGuard again, or from services over the private network. + +1. **Snapshot**, as in Phase 1. +2. **Dumps and stop**, the staged copies the data script loads: + + ```sh + ssh root@10.20.0.10 'set -e; d=/var/backups/restic-stage; install -d -m 700 $d; \ + docker exec storage-postgres pg_dumpall -U postgres > $d/pg_dumpall.sql; \ + sqlite3 /opt/forgejo/data/gitea/gitea.db ".backup $d/forgejo-gitea.db"; \ + docker exec storage-garage /garage meta snapshot --all; \ + docker ps -q | xargs -r docker stop -t 60; systemctl stop docker.socket docker containerd' + ``` + +3. **Convert**, as in Phase 1 step 3, on 135.181.27.77. +4. **Switch to the flake** on its public address: + + ```sh + nixos-rebuild switch --flake .#asxpio-ops --target-host root@135.181.27.77 \ + --build-host root@135.181.27.77 + ``` + + From here on root logs in from WireGuard and the private network only; + WireGuard is up again with the same keys, so clients reconnect. + +5. **Move the data, start everything, pull the app images:** + + ```sh + ssh root@10.20.0.10 'bash -s /old-root' < migration/ops-data.sh + ssh root@10.20.0.10 reboot + ``` + + The script moves Forgejo, Garage, Traefik's certificates, the + monitoring history and `/opt/`; loads the Postgres dump (roles + then get their passwords from sops); regenerates Forgejo's hooks and + SSH keys file; and runs `docker compose pull && up -d` for each app + as `deploy` (vhpbot-prod builds locally). + +6. **Check:** + - Every site answers (Grafana → Probes). Certificates are the old ones + from `acme.json`; Traefik renews as before. + - `git clone` over SSH and HTTPS; a push; the package registry serves + a pull. + - asxpio: log in to the admin, render an invoice (the boot test that + catches what a database check does not). + - datacenterbingo shows photos (Garage through the app) and + `/data.json`. + - `garage status`; `curl -I https://s3.asxp.io/public/`. + - Grafana: targets up, logs from both hosts, security panel clean. + - CI: push an empty commit to an app repo; the deploy reaches + "healthy" (Phase 0 step 3). + - `systemctl start restic-backup xmpp-cert-sync` succeed. + +**Rollback:** as in Phase 1. If services has already moved, it keeps +working against a Debian ops: nothing on services depends on how ops is +built. + +## Phase 3: clean-up + +1. Merge `nix` into `main`: `deploy.yaml` (Ansible) then finds no change + to apply, `nixos.yaml` deploys both hosts from now on. +2. Delete `ansible/`, `.forgejo/workflows/deploy.yaml`, the + `ANSIBLE_VAULT_PASSWORD` secret, `ansible/known_hosts` (the root copy + `known_hosts` stays), the Ansible parts of `renovate.json`. +3. Retire the storage repo (archive). Optional, later: drop the + `storage` network from the app compose files and point their + `DATABASE_URL`/`S3_ENDPOINT` at the host, then remove `apps.nix`'s + compatibility entries. +4. On both hosts after a week: `rm -rf /old-root`; delete the snapshots; + on ops remove the old Postgres 17 volume data, which went with + `/old-root`. +5. Delete the rehearsal servers, network and firewall (`managed-by=claude` + in the personal project). +6. Rotate what sat in the old history and the vault for a year + (`INTERNAL_TOKEN`, the JWT secrets, runner tokens), now in sops; and + give Grafana its own `secret_key` (production keeps the default for + now because its database was written with it; Grafana documents the + rotation). +7. Update the workspace `CLAUDE.md` (servers, deploys, gotchas). +8. Branches, last, because until then `main` is what deploys: + + ```sh + git push origin main:retired/ansible # keep the Ansible line + # Forgejo → Settings → Branches: default branch nix; unprotect main + git push origin --delete main + git push origin nix:main + # Forgejo: default branch main again; then + git push origin --delete nix + git branch -m main retired/ansible && git branch -m nix main + ``` + +## Rules for the rehearsal pair + +Restored data carries production credentials inside it. Anything that +would use them outward is kept from starting in `hosts/rehearsal/`, and +the following must hold every time: + +- **Before a runner meets restored Forgejo data,** run + `migration/rehearsal-sanitize-forgejo.sh` on the rehearsal ops. A + restored database still has production's queued jobs, schedules and + Actions secrets; on 2026-11-16 the test runner picked up a queued + production job and was stopped only by the different secret key. +- XMPP and the Telegram gateway, Forgejo's mail, mirrors and webhooks, + Grafana mail, the crawler mail, the bucket replica and the interop + runner do not start there. The Minecraft plugins that talk outward + (DiscordSRV, ServerBackup, AutoUpdateGeyser) are set aside before + every start: on 2026-11-16 DiscordSRV was missed on the first start + and logged the production bot in from the test server for 15 seconds. +- Apps run with mail pointed at nothing and `INDEXNOW_KEY` empty; the + asxpio monitor worker (external probes) stays off. +- SSH is limited by a Hetzner firewall to the admin; backup credentials + are on the servers only in `/run`, only during a restore. +- Delete the servers when testing ends: they hold production data. + +## Risks + +| Risk | Mitigation | +|---|---| +| Lock-out after the switch | Phase steps say how each host is reached at each point; services through ops and the other way round; Hetzner console last | +| nixos-infect breaks with a later NixOS | pinned by commit and checksum; `nix_channel` pinned to 26.05; nixos-anywhere as the fallback (`nixos/README.md`) | +| ops disk (38 GB) | 18 GB free today; the Nix store adds 3–5 GB, `/old-root` holds the old images until deleted; delete `/old-root/var/lib/docker` once the apps run | +| Data of newer versions than 26.05 ships | Prometheus, Grafana, Xray, SillyTavern from nixos-unstable; Garage 2.x pinned; checked on the rehearsal pair with prod data | +| Something only production does | XMPP on real data and Let's Encrypt issuance were not rehearsed; both have a snapshot rollback and are checked first in their phase | +| A deploy during the window | freeze (Phase 0 step 6); the storage repo's deploy is off (step 4) | diff --git a/README.md b/README.md index 2291331..1e90769 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ # asxp.io infrastructure -Two Hetzner Cloud servers, described by Terraform and configured by -Ansible. Pushing to `main` deploys: a Forgejo Actions workflow applies -`ansible/site.yaml` to both servers. +Two Hetzner Cloud servers, described by OpenTofu. They are moving from +Debian configured by Ansible to NixOS (`MIGRATION.md`); until a host has +moved, pushing to `main` still applies `ansible/site.yaml` to it. + +- Build the servers from nothing: `nixos/README.md` +- Restore data from backups: `RESTORE.md` ## Servers diff --git a/RESTORE.md b/RESTORE.md new file mode 100644 index 0000000..9be32a7 --- /dev/null +++ b/RESTORE.md @@ -0,0 +1,127 @@ +# Restoring from backups + +Each host backs itself up nightly with restic (ops 03:30, services 04:15 +UTC) into two independent repositories: + +| Name | Repository | +|------|------------| +| `hel1` | `s3:https://hel1.your-objectstorage.com/asxpio-backups-main/restic/` | +| `fsn1` | `s3:https://fsn1.your-objectstorage.com/asxpio-backups-repl/restic/` | + +A snapshot holds `/etc`, `/opt`, the listed container volumes and +`/var/backups/restic-stage`, where hooks put consistent copies of the +databases just before the run: + +| Host | In `/var/backups/restic-stage` | Volumes | +|------|--------------------------------|---------| +| asxpio-ops | `pg_dumpall.sql`, `asxpio.dump` (`pg_dump -Fc`), `forgejo-gitea.db` | `storage_garage_meta`, `storage_garage_data` (with a fresh Garage metadata snapshot) | +| asxpio-services | `ejabberd.sqlite`; ejabberd's Mnesia as `nightly.backup` inside `xmpp_database` | `xmpp_database`, `xmpp_tackygram` | + +Not in the backup: Postgres' data directory (restore from the dump), +`/opt/containerd`, and what Minecraft downloads again (`cache`, +`libraries`, `versions`). The exact lists are `restic_paths`, +`restic_excludes` and `restic_pre_hooks` in +`ansible/inventory/host_vars/`. + +Three secrets are needed, and none of them may exist only on the +servers: the Object Storage access key and secret key, and the restic +password (`vault_restic_password` in the Ansible vault). **Without the +password nothing can be read.** + +## One file or one service, on a running host + +```sh +restic-backup hel1 snapshots +restic-backup hel1 ls latest /opt/xmpp +restic-backup fsn1 restore latest --target /tmp/r --include /opt/xmpp +``` + +Restore beside the live data, compare, then stop the service and move +the files into place. + +## A whole host, onto a fresh system + +On a host built by `nixos/README.md` (or any Linux with restic): + +```sh +export AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... +export RESTIC_PASSWORD=... +export RESTIC_REPOSITORY=s3:https://hel1.your-objectstorage.com/asxpio-backups-main/restic/asxpio-ops +restic snapshots --host asxpio-ops # pick one; "latest" below +``` + +Keep every service stopped until its data is back, so nothing starts on +an empty directory and creates fresh state where the restore will land. + +1. **Files.** `/etc` is restored aside, for reference only: the system's + configuration comes from the flake. + + ```sh + restic restore latest --target / --include /opt --include /var/backups/restic-stage + restic restore latest --target /root/restored-etc --include /etc + ``` + +2. **Volumes** (while services still run in containers): create each + volume, then restore into it. + + ```sh + docker volume create storage_garage_meta # one per volume in the table + restic restore latest --target / --include /var/lib/docker/volumes/storage_garage_meta + ``` + + Under Podman the volume lives in + `/var/lib/containers/storage/volumes/`: restore to a temporary + target and move `_data` there. + +3. **Databases**, from the staged copies rather than the live files: + + - **Postgres** (ops): start Postgres alone on its empty data + directory, then load everything, roles included: + + ```sh + psql -U postgres -f /var/backups/restic-stage/pg_dumpall.sql + ``` + + `asxpio.dump` is the same database in `pg_restore` format, for + restoring only that one. + - **Forgejo** (ops): `cp /var/backups/restic-stage/forgejo-gitea.db + /opt/forgejo/data/gitea/gitea.db`, owner as the file it replaces. + - **Garage** (ops): if it does not start on the restored metadata, use + the snapshot inside the metadata volume (`snapshots/`), as described + in Garage's [recovery documentation](https://garagehq.deuxfleurs.fr/documentation/operations/recovering/). + - **ejabberd** (services): replace `ejabberd.sqlite` in `xmpp_database` + with the staged copy; if Mnesia does not come up clean, + `ejabberdctl restore /opt/ejabberd/database/nightly.backup`. + +4. **Start the services**, then check: the sites answer, a `git clone` + from Forgejo works, an XMPP client logs in, the Minecraft world is the + expected one, and the next nightly backup succeeds. + +The app stacks on ops (asxpio, datacenterbingo, blog, czsk, vhpbot, +storage) come back with `/opt/` (compose file and `.env`); their +images are pulled from the registry in Forgejo, so Forgejo and storage +come first. If the registry copy is gone, re-run each app's CI. + +## Onto a NixOS host + +The backup made by a NixOS host holds the new layout (`/var/lib/forgejo`, +`/var/lib/garage`, `/var/lib/minecraft`, ...): restore to `/`, load the +Postgres dump, `touch /var/lib/.data-in-place`, start the services. + +A backup made while the host was still Debian holds the layout described +above. Restore it to a side directory and let the migration script move +it into place; this is what was rehearsed on 2026-11-16: + +```sh +restic restore latest --host asxpio-ops --target /restore +bash nixos/migration/ops-data.sh /restore # or services-data.sh +``` + +## Keeping this true + +A restore that was never tried is a hope. After any change to what is +backed up, and at least twice a year, restore the latest snapshot of +each host onto a rehearsal server (`nixos/README.md`) and walk through +this page. Last walk-through: 2026-11-16, both hosts, onto the NixOS +rehearsal pair (Traefik, monitoring, the app stacks and XMPP not yet +part of it). diff --git a/known_hosts b/known_hosts new file mode 100644 index 0000000..ed9c64c --- /dev/null +++ b/known_hosts @@ -0,0 +1,2 @@ +10.10.0.10,10.20.0.10 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEzuhnXIFERF+slCGpjnQFhaO5iTVqVn9OMbt7jeFOUf +10.10.0.20,10.20.0.20 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDArwdI8bHpQhNnMqz7vOIGJvb5eYE7GahtkbxrNgtvp diff --git a/nixos/.sops.yaml b/nixos/.sops.yaml new file mode 100644 index 0000000..066253a --- /dev/null +++ b/nixos/.sops.yaml @@ -0,0 +1,19 @@ +# Who can decrypt what. A host decrypts with its SSH host key (converted +# with ssh-to-age); the admin key edits everything. +keys: + - &admin age19xvmm6j3h2u6mc3w6k65ufry4p5aa5lwu96p55h3e42p9wfzwc0qp2w7pk + - &asxpio_ops age1jxcl9cwk64wak2gyzf22vm3dpj80wtl76c7krywlrj7jjxftscrskrg3tf + - &asxpio_services age15ws8alg3ftsgmzvqxft09556g87s4n8c8v39nmvhaz6k50gp4e7se8acmg + # Throwaway servers: replace with the new host's key, then + # sops updatekeys secrets/rehearsal-*.yaml + - &rehearsal_ops age1hfaf7h2h43ahhql8zc6u3yr67yx4utnrlw57h6r32wnm4axvzves8pcl0r + - &rehearsal_services age1au6f8m6l245ddrunqf2a62xprnlevn9yrducynlay2tgknfxeeusj94j5l +creation_rules: + - path_regex: secrets/asxpio-ops\.yaml$ + key_groups: [{ age: [*admin, *asxpio_ops] }] + - path_regex: secrets/asxpio-services\.yaml$ + key_groups: [{ age: [*admin, *asxpio_services] }] + - path_regex: secrets/rehearsal-ops\.yaml$ + key_groups: [{ age: [*admin, *rehearsal_ops] }] + - path_regex: secrets/rehearsal-services\.yaml$ + key_groups: [{ age: [*admin, *rehearsal_services] }] diff --git a/nixos/README.md b/nixos/README.md new file mode 100644 index 0000000..71508e5 --- /dev/null +++ b/nixos/README.md @@ -0,0 +1,214 @@ +# NixOS + +Each server's whole system, as one flake. A server is created by OpenTofu +(`../terraform`), converts itself to NixOS on first boot, and gets its +configuration from here. Production is moving over from `../ansible`; +the plan and its state are in `../MIGRATION.md`. + +``` +flake.nix inputs (nixpkgs 26.05, unstable for a few packages, sops-nix), hosts, dev shell +modules/hetzner.nix disk, boot and network of a Hetzner Cloud VM +modules/base.nix users, SSH, fail2ban, firewall, journal cap, Nix settings +modules/wireguard.nix the admin network; ops is the hub +modules/podman.nix Podman, and the Docker CLI on its socket +modules/backup.nix nightly restic backup, `restic-backup` command +modules/alert.nix mail when a unit fails +modules/monitoring-agent.nix node, container and security metrics, logs to Loki +hosts/asxpio-ops/ Traefik, Forgejo, Postgres, Garage, monitoring, app stacks +hosts/asxpio-services/ runners, Minecraft, XMPP, Xray, SillyTavern, one file each +hosts/rehearsal/ overrides that turn the two hosts into a test pair +migration/ one-off scripts: Debian-era data into place, rehearsal clean-up +secrets/*.yaml sops-encrypted, one file per host +``` + +Services run as native NixOS services wherever nixpkgs has a module; +the rest are Podman containers declared here (XMPP) or deployed by their +own repositories (the app stacks on ops). There is no Docker daemon: +`docker` is the Docker CLI talking to Podman's socket, so `docker ps`, +`docker compose` and the apps' CI deploys work as they did. + +Each service file also says what it adds to the backup +(`asxpio.backup`), which ports and users the security baseline should +expect (`asxpio.security`), and whether it waits for restored data +(`asxpio.waitForData`). + +All tools used below come from the dev shell: `nix develop ./nixos`. + +## Changing something + +Edit, push a branch (CI evaluates every host), merge to `main`: CI +builds each host on itself and switches to it, ops first. A host that +does not run NixOS yet is skipped. By hand, over WireGuard: + +```sh +nixos-rebuild switch --flake .#asxpio-services \ + --target-host root@10.20.0.20 --build-host root@10.20.0.20 +``` + +Only units whose definition changed restart. Undo with +`nixos-rebuild switch --rollback` on the host, or pick the previous +generation in the boot menu (Hetzner console). Package updates come from +Renovate (`flake.lock` weekly, pinned images and versions as they are +released); by hand: `nix flake update`, commit `flake.lock`. + +Try anything risky on the rehearsal pair first (below). + +## Building the servers from scratch + +What you need: a Hetzner Cloud project and its API token, Object Storage +keys (hel1 and fsn1), an SSH key listed in `../terraform/keys.tf`, and, +to restore data, the restic password (`../RESTORE.md`). + +The existing servers are billed below today's list price, and a new +server is not. **For asxpio-ops and asxpio-services use "Reinstalling in +place" below**; this section is for a new project or a lost server. + +1. **Create the infrastructure** (network, firewalls, DNS, buckets, + servers): + + ```sh + cd terraform + cp terraform.tfvars.example terraform.tfvars # fill in the token and keys + export AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... # for the state bucket + tofu init + tofu apply + ``` + + In a new project the state bucket does not exist yet: comment out the + `backend "s3"` block for the first apply, then restore it and run + `tofu init -migrate-state`. + +2. **Wait about four minutes.** Each server boots Debian, and cloud-init + (`../terraform/cloud-init/nixos.yaml.tftpl`) runs a pinned + nixos-infect, which installs NixOS over the running system and + reboots. The result is a bare NixOS: root login with the keys from + `keys.tf`, public and private network, nothing else. + + ```sh + ssh root@ nixos-version + ssh -J root@ root@10.10.0.20 nixos-version # services: no public SSH + ``` + + If a server still answers as Debian after ten minutes, read + `/var/log/nixos-infect.log` on it. + +3. **Set the host's facts** in `hosts//default.nix`: the public + addresses (`tofu output`), and on ops the WireGuard endpoint the + others use. Add the host's age recipient to `.sops.yaml` and + re-encrypt its secrets: + + ```sh + ssh root@ cat /etc/ssh/ssh_host_ed25519_key.pub | ssh-to-age + sops updatekeys secrets/.yaml + ``` + +4. **Install the configuration** (same addresses as in step 2; add + `NIX_SSHOPTS="-J root@"` for services): + + ```sh + cd nixos + nixos-rebuild switch --flake .#asxpio-ops \ + --target-host root@ --build-host root@ + ssh root@ reboot # once: new kernel command line, interface names + ``` + + From here on root and the admin users log in only from WireGuard and + the private network (`asxpio.sshFrom`): connect your WireGuard client + to ops first, or go through the other server over the private network. + +5. **Restore the data**: `../RESTORE.md`. + +6. Remove what the conversion left behind: `rm -rf /old-root` (the + Debian image, about 2 GB). + +## Reinstalling in place + +Keeps the server, its addresses and its price; **wipes the disk**. + +```sh +cd terraform +hcloud server disable-protection asxpio-services rebuild +tofu output -json user_data | jq -r '."asxpio-services"' | + hcloud server rebuild --image debian-13 --user-data-from-file - asxpio-services +tofu apply # puts the rebuild protection back +``` + +Then continue at step 2 above. The server gets new SSH host keys, so +step 3's `sops updatekeys` is needed, and `known_hosts` entries change. + +## Secrets + +`secrets/.yaml` is encrypted with [sops](https://github.com/getsops/sops) +for the keys in `.sops.yaml`: the admin's age key and the host's SSH host +key. The host decrypts at boot into `/run/secrets`. + +```sh +sops secrets/asxpio-services.yaml # edit; needs ~/.config/sops/age/keys.txt +``` + +The SSH host key is therefore part of a host's identity. It survives the +in-place conversion and is in the backup (`/etc/ssh`); a rebuilt server +has a new one and needs `sops updatekeys`. + +## Data and the marker file + +Services that own data (`asxpio.waitForData`: Postgres, Garage, Forgejo, +Minecraft, SillyTavern, XMPP, the backup itself) do not start until +`/var/lib/.data-in-place` exists. A fresh install +therefore never creates empty state where a restore is about to land, +and never backs up an empty host over a full one. After restoring or +moving the data: `touch /var/lib/.data-in-place`, then start the units +or reboot. + +## Rehearsal + +`.#rehearsal-ops` and `.#rehearsal-services` are the two hosts' own +configurations plus `hosts/rehearsal/`: other keys and addresses, dummy +secrets, SSH open to the world, backups into local directories, and +anything that would act as production (the XMPP server) started by hand +only. **Every change is tried there first**, and the pair should be able +to do everything production does before a production host is converted. + +Two servers on a private network with the production addresses: + +```sh +hcloud network create --name rehearsal --ip-range 10.10.0.0/20 +hcloud network add-subnet rehearsal --type cloud --network-zone eu-central --ip-range 10.10.0.0/23 +tofu -chdir=../terraform output -json user_data | jq -r '."asxpio-ops"' > /tmp/ops.yaml +tofu -chdir=../terraform output -json user_data | jq -r '."asxpio-services"' > /tmp/services.yaml +hcloud server create --name rehearsal-ops --type cx23 --image debian-13 --location hel1 \ + --ssh-key --network rehearsal --user-data-from-file /tmp/ops.yaml +hcloud server create --name rehearsal-services --type cx23 --image debian-13 --location hel1 \ + --ssh-key --network rehearsal --user-data-from-file /tmp/services.yaml +``` + +Then, per server: put its age recipient in `.sops.yaml` (`&rehearsal_*`) +and `sops updatekeys secrets/rehearsal-.yaml`; put its addresses in +`hosts/rehearsal/.nix` (and ops's public key in services' file, +the other way round for WireGuard); `nixos-rebuild switch --flake +.#rehearsal- --target-host root@ --build-host root@`; +reboot once. + +With test data: `touch /var/lib/.data-in-place`. With a restored copy of +production: restore last night's snapshot to `/restore`, run +`migration/ops-data.sh /restore` or `services-data.sh /restore`, and on +ops `migration/rehearsal-sanitize-forgejo.sh` before the runner starts. +Read the rehearsal rules in `../MIGRATION.md` first: restored data +carries production credentials. + +## How the first boot works, and its limits + +- nixos-infect is pinned by commit and checksum in + `../terraform/servers.tf`; it replaces the operating system, so bump it + deliberately and rehearse. +- It keeps the Debian image's partitions (`modules/hetzner.nix` matches + them) and moves the old system to `/old-root`. +- `bootstrap.nix` in the cloud-init corrects three things for the first + generation: the scripted initrd (the takeover does not exist in the + systemd initrd, which NixOS 26.05 uses by default), the IPv4 default + route, and the private network's route. All three were found and + verified on test servers on 2026-11-16. +- The scripted initrd is deprecated upstream. When a NixOS release drops + it, keep `nix_channel` at the last release that has it (the flake then + upgrades the system), or switch the first boot to + [nixos-anywhere](https://github.com/nix-community/nixos-anywhere). diff --git a/nixos/flake.lock b/nixos/flake.lock new file mode 100644 index 0000000..4dab583 --- /dev/null +++ b/nixos/flake.lock @@ -0,0 +1,65 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1794552581, + "narHash": "sha256-qXFIqA6FCcx7XeDzw0ZNlkDT9UiCzrNDwK8RuU8RcHM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f1e5c356f35d07e7b71a6b5e6c9338e0b029e0c0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-26.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1794537146, + "narHash": "sha256-Wpz/7x/YWnDIBu7yj6ixe8j6fIMsidd9Y+o1PqPF3iM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d5cc6833999746cffdfe0598f7bc801a57b887a9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable", + "sops-nix": "sops-nix" + } + }, + "sops-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1794624949, + "narHash": "sha256-3q/hxp/flW1PnV3Dx+H3p8kHGEHJ7251BqVMNsAAB9E=", + "owner": "Mic92", + "repo": "sops-nix", + "rev": "11e5885d241743ff0193465d533b20e754bc3ce0", + "type": "github" + }, + "original": { + "owner": "Mic92", + "repo": "sops-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/nixos/flake.nix b/nixos/flake.nix new file mode 100644 index 0000000..fac3e85 --- /dev/null +++ b/nixos/flake.nix @@ -0,0 +1,78 @@ +{ + description = "asxp.io servers"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05"; + # For the few packages 26.05 has older than what production runs + nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; + sops-nix = { + url = "github:Mic92/sops-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + { + nixpkgs, + nixpkgs-unstable, + sops-nix, + ... + }: + let + mkHost = + modules: + nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs.unstable = nixpkgs-unstable.legacyPackages.x86_64-linux; + modules = [ + sops-nix.nixosModules.sops + ./modules/hetzner.nix + ./modules/base.nix + ./modules/shell.nix + ./modules/podman.nix + ./modules/wireguard.nix + ./modules/alert.nix + ./modules/backup.nix + ./modules/monitoring-agent.nix + ] + ++ modules; + }; + in + { + # `nix develop ./nixos`: every tool the READMEs call + devShells.x86_64-linux.default = + let + pkgs = nixpkgs.legacyPackages.x86_64-linux; + in + pkgs.mkShell { + packages = with pkgs; [ + opentofu + hcloud + nixos-rebuild + sops + ssh-to-age + age + restic + rclone + jq + openssh + ]; + }; + + nixosConfigurations = { + asxpio-ops = mkHost [ ./hosts/asxpio-ops ]; + asxpio-services = mkHost [ ./hosts/asxpio-services ]; + + # Both hosts on throwaway servers, with their own keys and + # addresses: everything is tried there first. + rehearsal-ops = mkHost [ + ./hosts/asxpio-ops + ./hosts/rehearsal/ops.nix + ]; + rehearsal-services = mkHost [ + ./hosts/asxpio-services + ./hosts/rehearsal/services.nix + ]; + }; + }; +} diff --git a/nixos/hosts/asxpio-ops/apps.nix b/nixos/hosts/asxpio-ops/apps.nix new file mode 100644 index 0000000..4449755 --- /dev/null +++ b/nixos/hosts/asxpio-ops/apps.nix @@ -0,0 +1,38 @@ +# The app stacks (asxpio, datacenterbingo, blog, czsk, vhpbot) deploy +# themselves from their own repositories: CI copies a compose file and a +# .env to /opt/ and runs `docker compose up -d` as user deploy. +# +# Their compose files still expect the Docker-era storage stack: a +# network named "storage" and the hosts "postgres" and "garage" on it. +# Postgres and Garage are native services now, so every container on +# this host resolves those two names to the host, and the network exists +# empty. Nothing in the app repositories has to change for the move; +# dropping the storage network from their compose files is a later +# clean-up. +{ config, pkgs, ... }: +let + hosts = pkgs.writeText "container-hosts" '' + 10.10.0.10 postgres garage + ''; +in +{ + virtualisation.containers.containersConf.settings.containers.base_hosts_file = "${hosts}"; + # The API service (the socket the Docker CLI and Traefik use) reads it + # at start only + systemd.services.podman.restartTriggers = [ hosts ]; + + # `docker compose up --build` (vhpbot-prod builds on the host) starts + # BuildKit in a privileged container + asxpio.security.containers."buildx_buildkit_.*" = [ "privileged" ]; + + systemd.services.podman-network-storage = { + description = "Podman network storage (empty; see apps.nix)"; + wantedBy = [ "multi-user.target" ]; + path = [ config.virtualisation.podman.package ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + script = "podman network exists storage || podman network create storage"; + }; +} diff --git a/nixos/hosts/asxpio-ops/crawler-alert.py b/nixos/hosts/asxpio-ops/crawler-alert.py new file mode 100644 index 0000000..5bca6a8 --- /dev/null +++ b/nixos/hosts/asxpio-ops/crawler-alert.py @@ -0,0 +1,878 @@ +#!/usr/bin/env python3 +"""Crawler watch for a Traefik-fronted Forgejo (or any Traefik site). + +Separates real AI crawlers from traffic that only claims to be, by +checking the source IP against each vendor's published range list. + +Modes: + (default) daily threshold alert: mail only if yesterday exceeded + CRAWLER_THRESHOLD requests + --weekly summary: always mail stats for the past 7 days + --dry-run print instead of mailing (combinable with --weekly) + +Configuration is by environment variable; see README.md. The only +value with no sensible default is CRAWLER_RECIPIENT. +""" +import configparser, glob, gzip, ipaddress, json, os, re, smtplib, socket, subprocess, sys, urllib.request +from collections import Counter +from datetime import date, timedelta +from email.mime.text import MIMEText + +# --- configuration ------------------------------------------------------ +THRESHOLD = int(os.environ.get("CRAWLER_THRESHOLD", "100000")) +RECIPIENT = os.environ.get("CRAWLER_RECIPIENT", "") +SITE = os.environ.get("CRAWLER_SITE", "this site") +LOG_GLOB = os.environ.get("CRAWLER_LOG", "/var/log/traefik/access.log*") +# Traefik router name to filter on, e.g. "forgejo@docker". Empty = all +# traffic reaching Traefik, which is what you want for a single-site host. +ROUTER = os.environ.get("CRAWLER_ROUTER", "") +# Container to read SMTP settings from (Forgejo/Gitea app.ini [mailer]). +# Set CRAWLER_SMTP_* instead to configure SMTP directly. +MAIL_CONTAINER = os.environ.get("CRAWLER_MAIL_CONTAINER", "forgejo") +MAIL_INI = os.environ.get("CRAWLER_MAIL_INI", "/data/gitea/conf/app.ini") + +WEEKLY = "--weekly" in sys.argv +DRY = "--dry-run" in sys.argv + +if not RECIPIENT and not DRY: + sys.exit("CRAWLER_RECIPIENT is not set (no --dry-run either); refusing " + "to run. See README.md.") + +# --- verified-crawler support ------------------------------------------- +# Vendors publishing machine-readable IP ranges. A UA token alone proves +# nothing: on the instance this was written for, ~83% of AI-bot-labelled +# traffic came from hosts outside these ranges. Only IP-verified hits count. +RANGE_SOURCES = { + "openai": ["https://openai.com/chatgpt-user.json", + "https://openai.com/gptbot.json", + "https://openai.com/searchbot.json"], + "anthropic": ["https://claude.com/crawling/bots.json"], + "perplexity":["https://www.perplexity.ai/perplexitybot.json"], + "apple": ["https://search.developer.apple.com/applebot.json"], + "google": ["https://developers.google.com/static/crawling/ipranges/special-crawlers.json", + "https://developers.google.com/static/crawling/ipranges/common-crawlers.json", + "https://developers.google.com/static/crawling/ipranges/user-triggered-fetchers.json", + "https://developers.google.com/static/crawling/ipranges/user-triggered-fetchers-google.json"], +} +# UA token -> vendor whose ranges must contain the source IP +BOT_VENDOR = { + "ChatGPT-User": "openai", "GPTBot": "openai", "OAI-SearchBot": "openai", + "ClaudeBot": "anthropic", "Claude-User": "anthropic", "Claude-SearchBot": "anthropic", + "PerplexityBot": "perplexity", "Perplexity-User": "perplexity", + "Applebot-Extended": "apple", "Applebot": "apple", + "Googlebot": "google", "Google-Extended": "google", "GoogleOther": "google", +} + +# --- reverse-DNS verification ------------------------------------------- +# For vendors that publish no IP ranges. The check is forward-confirmed +# (FCrDNS): PTR of the address must end in one of the vendor's domains, +# AND that hostname must resolve back to the same address. The forward +# step is what makes it meaningful - a PTR record alone is set by +# whoever controls the address block, so it proves nothing on its own. +BOT_RDNS = { + "Amazonbot": (".crawl.amazonbot.amazon",), + "meta-externalagent": (".facebook.com", ".fbsv.net"), + "meta-externalfetcher": (".facebook.com", ".fbsv.net"), + "FacebookBot": (".facebook.com", ".fbsv.net"), + "YouBot": (".search.you.com",), + "Bytespider": (".bytedance.com", ".byteoversea.com"), + "PetalBot": (".petalsearch.com", ".aspiegel.com"), + "DuckAssistBot": (".duckduckgo.com",), + # Apple and Google publish ranges, but also answer rDNS; listed so a + # range miss can still be resolved when the published file is stale. + "Applebot": (".applebot.apple.com",), + "Googlebot": (".googlebot.com", ".google.com"), +} +# rDNS is slow (two lookups per address), so only unique IPs are probed +# and results are memoised for the run. +RDNS_MAX = int(os.environ.get("CRAWLER_RDNS_MAX", "400")) +RDNS_ENABLE = os.environ.get("CRAWLER_RDNS", "1") != "0" + +# --- ASN verification, for single-tenant networks only ------------------- +# An ASN match usually proves nothing: genuine YouBot and genuine +# Amazonbot both live in AS14618, which is also every EC2 instance a +# spoofer could rent. It is only evidence when the ASN belongs to the +# vendor exclusively and sells no compute in it. Meta qualifies - +# AS32934 is Meta's own network and cannot be rented - and Meta +# publishes no IP range file (their docs say to email webmasters@meta.com), +# so without this there is nothing to check them against at all. +BOT_ASN = { + "meta-externalagent": {"32934"}, + "meta-externalfetcher": {"32934"}, + "FacebookBot": {"32934"}, + "facebookexternalhit": {"32934"}, +} +ASN_ENABLE = os.environ.get("CRAWLER_ASN", "1") != "0" +# Team Cymru's DNS interface: .origin[6].asn.cymru.com TXT +CYMRU4 = "origin.asn.cymru.com" +CYMRU6 = "origin6.asn.cymru.com" +# robots.txt to audit verified crawlers against. Fetched once per run; +# empty or unreachable simply skips the compliance check. +ROBOTS_URL = os.environ.get("CRAWLER_ROBOTS", "") +CACHE = os.environ.get("CRAWLER_CACHE", "/var/cache/crawler-alert/ranges.json") +CF_URL = "https://www.cloudflare.com/ips-v4" +# claude.com and cloudflare.com sit behind Cloudflare, which 403s the +# default Python-urllib UA. Send a real one. +UA = "Mozilla/5.0 (compatible; crawler-alert/1.0; +https://codeberg.org/)" + + +def fetch(url, timeout=20): + req = urllib.request.Request(url, headers={"User-Agent": UA}) + with urllib.request.urlopen(req, timeout=timeout) as r: + return r.read() + + +def load_ranges(): + """Fetch vendor prefixes; fall back to cache so a vendor outage + degrades the report instead of breaking the mail.""" + out, stale = {}, [] + for vendor, urls in RANGE_SOURCES.items(): + nets = [] + for u in urls: + try: + for p in json.loads(fetch(u)).get("prefixes", []): + for k, v in p.items(): + if k.startswith("ipv"): + nets.append(v) + except Exception: + stale.append(vendor) + if nets: + out[vendor] = nets + cf = [] + try: + cf = [l.strip() for l in fetch(CF_URL).decode().splitlines() if l.strip()] + except Exception: + stale.append("cloudflare") + try: + cached = json.load(open(CACHE)) + except Exception: + cached = {} + for vendor in RANGE_SOURCES: + if vendor not in out and vendor in cached.get("vendors", {}): + out[vendor] = cached["vendors"][vendor] + if not cf: + cf = cached.get("cloudflare", []) + if out: + try: + os.makedirs(os.path.dirname(CACHE), exist_ok=True) + json.dump({"vendors": out, "cloudflare": cf}, open(CACHE, "w")) + except Exception: + pass + # bucket by first octet so lookups stay cheap over ~1425 prefixes + idx = {} + for vendor, nets in out.items(): + b = {} + for s in nets: + n = ipaddress.ip_network(s) + b.setdefault(int(n.network_address) >> 24 if n.version == 4 else -1, []).append(n) + idx[vendor] = b + cfnets = [ipaddress.ip_network(s) for s in cf] + return idx, cfnets, sorted(set(stale)) + + +def in_index(idx_v, addr): + if idx_v is None: + return False + key = int(addr) >> 24 if addr.version == 4 else -1 + return any(addr in n for n in idx_v.get(key, [])) + + +def load_robots(): + """Disallow patterns from robots.txt, as (prefix, contains) pairs. + + Only the `User-agent: *` group is read: the point is to audit what + well-behaved crawlers were asked not to fetch, not to model every + per-agent rule. Returns [] when unset or unreachable, which disables + the compliance check rather than reporting false violations. + """ + if not ROBOTS_URL: + return [] + try: + txt = fetch(ROBOTS_URL, timeout=15).decode("utf-8", "replace") + except Exception: + return [] + rules, in_star = [], False + for line in txt.splitlines(): + line = line.split("#")[0].strip() + if not line: + continue + k, _, v = line.partition(":") + k, v = k.strip().lower(), v.strip() + if k == "user-agent": + in_star = (v == "*") + elif k == "disallow" and in_star and v: + # Forgejo-style /*/*/thing/ means "contains /thing/". + if v.startswith("/*"): + rules.append(("", v.lstrip("/*"))) + else: + rules.append((v.rstrip("*"), "")) + return rules + + +def robots_blocked(path, rules): + for prefix, contains in rules: + if prefix and path.startswith(prefix): + return True + if contains and contains in path: + return True + return False + + +_asn_cache = {} + + +def asn_of(ip): + """Origin ASN for an address via Team Cymru's DNS interface. + + Returns the ASN as a string, or "" if it cannot be determined. + Needs `dig`; absence degrades to no ASN evidence, never an error. + """ + if ip in _asn_cache: + return _asn_cache[ip] + asn = "" + try: + a = ipaddress.ip_address(ip) + if a.version == 4: + q = ".".join(reversed(ip.split("."))) + "." + CYMRU4 + else: + nibbles = a.exploded.replace(":", "") + q = ".".join(reversed(nibbles)) + "." + CYMRU6 + out = subprocess.run(["dig", "+short", "+time=3", "+tries=1", q, "TXT"], + capture_output=True, text=True, timeout=12).stdout + # "32934 | 2a03:2880:f814::/48 | IE | ripencc | 2011-08-22" + first = out.strip().strip('"').split("|")[0].strip() + if first.split(" ")[0].isdigit(): + asn = first.split(" ")[0] + except (OSError, ValueError, subprocess.SubprocessError): + pass + _asn_cache[ip] = asn + return asn + + +_rdns_cache = {} + + +def fcrdns(ip, suffixes): + """Forward-confirmed reverse DNS. + + PTR must end in one of `suffixes`, and the name it gives must resolve + back to `ip`. Returns (ok, hostname). Without the forward step this + would only prove the address owner can write their own PTR record. + """ + key = (ip, suffixes) + if key in _rdns_cache: + return _rdns_cache[key] + result = (False, "", "mismatch") + try: + host = socket.gethostbyaddr(ip)[0].rstrip(".").lower() + if any(host.endswith(s) or host == s.lstrip(".") for s in suffixes): + _, _, addrs = socket.gethostbyname_ex(host) + try: + v6 = socket.getaddrinfo(host, None, socket.AF_INET6) + addrs = addrs + [a[4][0] for a in v6] + except OSError: + pass + if ip in addrs: + result = (True, host, "ok") + else: + result = (False, host, "mismatch") + else: + result = (False, host, "mismatch") + except OSError: + # No PTR at all. This is absence of evidence, not evidence of + # forgery: Meta's IPv6 crawler space, for one, publishes no PTR + # records. Kept distinct so a real mismatch stays visible. + result = (False, "", "no-ptr") + _rdns_cache[key] = result + return result + +# --- --metrics: Prometheus counters for Grafana -------------------------- +# Run every few minutes from a timer. Reads only what the live log gained +# since the last run (byte offset + inode in a state file, so rotation and +# truncation restart at 0), classifies each request the same way as the +# weekly report, and writes cumulative counters to node_exporter's +# textfile directory. Verdicts per (bot, IP) are cached for a week, so DNS +# is only asked about addresses it hasn't seen. +METRICS = "--metrics" in sys.argv +TEXTFILE = os.environ.get("CRAWLER_TEXTFILE", "/var/lib/node_exporter/textfile/crawler.prom") +STATE = os.environ.get("CRAWLER_STATE", "/var/cache/crawler-alert/metrics.json") +LIVE_LOG = os.environ.get("CRAWLER_LIVE_LOG", sorted(glob.glob(LOG_GLOB) or [""])[0]) +ALL_BOTS = sorted(set(BOT_VENDOR) | set(BOT_RDNS) | set(BOT_ASN), key=len, reverse=True) +GENERIC_BOT = re.compile(r"bot|crawler|spider|scrapy|externalagent", re.I) +UA_RE = re.compile(r"\"[^\"]*\" \"([^\"]*)\" \d+ \"") +# The mail reports watch one router (Forgejo); the dashboard wants them all. +METRICS_ROUTER = os.environ.get("CRAWLER_METRICS_ROUTER", ROUTER) + + +def vendor_of(bot): + if bot in BOT_VENDOR: + return BOT_VENDOR[bot] + if bot in BOT_ASN: + return "meta" + return bot.lower() + + +def index_ranges(vendors, cf): + idx = {} + for vendor, nets in vendors.items(): + b = {} + for s in nets: + n = ipaddress.ip_network(s) + b.setdefault(int(n.network_address) >> 24 if n.version == 4 else -1, []).append(n) + idx[vendor] = b + return idx, [ipaddress.ip_network(s) for s in cf] + + +def cached_ranges(max_age=86400): + """Range files change rarely: refetch once a day, not every run.""" + import time + try: + if time.time() - os.path.getmtime(CACHE) < max_age: + c = json.load(open(CACHE)) + return index_ranges(c["vendors"], c.get("cloudflare", [])) + except Exception: + pass + idx, cf, _stale = load_ranges() + return idx, cf + + +def judge(bot, ip, ranges, cfnets, cache, budget): + """verified | spoofed | proxied | private | unknown, like the report: + IP ranges first, then forward-confirmed rDNS, then single-tenant ASN.""" + try: + addr = ipaddress.ip_address(ip) + except ValueError: + return "unknown" + if addr.is_private: + return "private" + if any(addr in n for n in cfnets): + return "proxied" + if bot in BOT_VENDOR and in_index(ranges.get(BOT_VENDOR[bot]), addr): + return "verified" + if bot not in BOT_RDNS and bot not in BOT_ASN: + return "spoofed" # range-only vendor, address outside ranges + key = f"{bot}|{ip}" + if key in cache: + return cache[key][0] + if budget[0] <= 0: + return "unknown" # over this run's DNS budget; retried next run + budget[0] -= 1 + v = "unknown" + ok, why = False, "no-ptr" + if bot in BOT_RDNS: + ok, _host, why = fcrdns(ip, BOT_RDNS[bot]) + if ok: + v = "verified" + elif why == "no-ptr": + if ASN_ENABLE and bot in BOT_ASN and asn_of(ip) in BOT_ASN[bot]: + v = "verified" + else: + v = "spoofed" # a PTR exists and points elsewhere + cache[key] = [v, int(date.today().toordinal())] + return v + + +def run_metrics(): + try: + st = json.load(open(STATE)) + except Exception: + st = {} + counts = Counter(st.get("counts", {})) + cache = {k: v for k, v in st.get("verdicts", {}).items() + if v[1] > date.today().toordinal() - 7} + try: + fs = os.stat(LIVE_LOG) + except OSError: + sys.exit(f"cannot read {LIVE_LOG}") + if "inode" not in st: + offset = fs.st_size # first run: start at the end, not the backlog + elif st["inode"] != fs.st_ino or fs.st_size < st.get("offset", 0): + offset = 0 # rotated or truncated + else: + offset = st["offset"] + ranges, cfnets = cached_ranges() + socket.setdefaulttimeout(3) + budget = [RDNS_MAX] + with open(LIVE_LOG, "rb") as f: + f.seek(offset) + for raw in f: + if not raw.endswith(b"\n"): + break # half-written line: take it next run + offset += len(raw) + line = raw.decode("utf-8", "replace") + if METRICS_ROUTER and METRICS_ROUTER not in line: + continue + parts = line.split() + counts["requests"] += 1 + m = UA_RE.search(line) + u = m.group(1) if m else "-" + bot = next((b for b in ALL_BOTS if b in u), None) + if bot: + v = judge(bot, parts[0], ranges, cfnets, cache, budget) + counts[f"ai|{vendor_of(bot)}|{bot}|{v}"] += 1 + if v == "verified" and len(parts) > 9 and parts[9].isdigit(): + counts[f"bytes|{vendor_of(bot)}"] += int(parts[9]) + elif u == "-": + counts["class|none"] += 1 + elif GENERIC_BOT.search(u): + counts["class|other-bot"] += 1 + else: + counts["class|browser-like"] += 1 + if len(cache) > 50000: # keep the newest verdicts only + cache = dict(sorted(cache.items(), key=lambda kv: kv[1][1])[-50000:]) + os.makedirs(os.path.dirname(STATE), exist_ok=True) + json.dump({"inode": fs.st_ino, "offset": offset, "counts": counts, + "verdicts": cache}, open(STATE + ".tmp", "w")) + os.replace(STATE + ".tmp", STATE) + + out = ["# HELP crawler_requests_total Requests seen in the Traefik access log.", + "# TYPE crawler_requests_total counter", + f"crawler_requests_total {counts['requests']}", + "# HELP crawler_class_requests_total Requests without an AI-bot user agent, by user-agent class.", + "# TYPE crawler_class_requests_total counter"] + for k, c in sorted(counts.items()): + if k.startswith("class|"): + out.append(f'crawler_class_requests_total{{class="{k[6:]}"}} {c}') + out += ["# HELP crawler_ai_requests_total Requests claiming an AI-bot user agent, by verification verdict.", + "# TYPE crawler_ai_requests_total counter"] + for k, c in sorted(counts.items()): + if k.startswith("ai|"): + _, vendor, bot, v = k.split("|") + out.append(f'crawler_ai_requests_total{{vendor="{vendor}",bot="{bot}",verdict="{v}"}} {c}') + out += ["# HELP crawler_ai_verified_bytes_total Bytes served to verified AI crawlers.", + "# TYPE crawler_ai_verified_bytes_total counter"] + for k, c in sorted(counts.items()): + if k.startswith("bytes|"): + out.append(f'crawler_ai_verified_bytes_total{{vendor="{k[6:]}"}} {c}') + import time + out += ["# HELP crawler_metrics_last_run_timestamp_seconds Last successful --metrics run.", + "# TYPE crawler_metrics_last_run_timestamp_seconds gauge", + f"crawler_metrics_last_run_timestamp_seconds {int(time.time())}"] + with open(TEXTFILE + ".tmp", "w") as f: + f.write("\n".join(out) + "\n") + os.replace(TEXTFILE + ".tmp", TEXTFILE) + + +if METRICS: + run_metrics() + sys.exit(0) + +days = [date.today() - timedelta(days=i) for i in range(7 if WEEKLY else 1, 0, -1)] +stamps = [d.strftime("%d/%b/%Y") for d in days] + +RANGES, CFNETS, STALE = (load_ranges() if WEEKLY else ({}, [], [])) + +per_day = {s: [0, set()] for s in stamps} +repos = Counter() +uas = Counter() +verified = Counter() # bot -> IP-verified hits +spoofed = Counter() # bot -> UA claimed, IP outside vendor ranges +proxied = Counter() # bot -> arrived via Cloudflare, unverifiable +ver_paths = Counter() # paths fetched by verified bots +ver_ips = {} # bot -> set of verified source IPs +# What the verified crawlers actually did, once confirmed: status mix, +# bytes served, and any path robots.txt asked them not to fetch. +ver_status = Counter() +ver_bytes = [0] +ver_violations = Counter() # path -> hits, robots.txt disallowed +ver_bot_bytes = Counter() # bot -> bytes served +# Repository *content* fetched by verified crawlers, as opposed to +# policy files and chrome. This is the question a permissive robots.txt +# is asking: now that they may read the code, do they? Counting top +# paths cannot answer it - robots.txt and sitemap.xml drown everything. +ver_content = Counter() # bot -> content hits +ver_content_paths = Counter() +CONTENT_RE = re.compile(r"/(src|raw|commit|commits|media|blame|archive|compare)/") +# Which repositories each vendor is actually interested in. +ver_repos = {} # bot -> Counter(owner/repo) +ver_pkgs = Counter() # "type/name" -> hits, registry artifacts +ver_pkg_index = Counter() # owner -> hits on the bare package index +# Forge paths are /owner/repo/...; these first segments are not owners, +# and a two-segment path like /pix/photo.jpg on another vhost is a file, +# not a repository - hence the extension check. +NOT_OWNER = {"assets", "fonts", "explore", "user", "api", "avatars", + "repo-avatars", "swagger.v1.json", "attachments", "notifications", + "issues", "pulls", "milestones", "admin", "org", "repo", "login", + "-", "favicon.ico", "robots.txt", "sitemap.xml", "pix", "static"} + + +# Container/package registry: /{owner}/-/packages/{type}/{name}[/{version}] +# Worth counting separately from repositories - it says which published +# artifacts crawlers are indexing, not which source they are reading. +PKG_RE = re.compile(r"^/([^/]+)/-/packages(?:/([^/?]+)/([^/?]+))?") + + +def package_of(path): + """(owner, 'type/name') for a registry path, else None. Bare + /owner/-/packages (the index) returns name None.""" + m = PKG_RE.match(path.split("?")[0]) + if not m: + return None + owner, ptype, name = m.group(1), m.group(2), m.group(3) + return (owner, f"{ptype}/{name}" if ptype and name else None) + + +def repo_of(path): + """owner/repo for a forge path, else None.""" + seg = path.lstrip("/").split("?")[0].split("/") + if len(seg) < 2 or not seg[0] or not seg[1]: + return None + if seg[0].lower() in NOT_OWNER or seg[1].lower() in NOT_OWNER: + return None + if "." in seg[1] and len(seg) == 2: # /pix/photo.jpg -> a file + return None + return f"{seg[0]}/{seg[1]}" +# rDNS-verified vendors: {bot: {ip: hits}}, resolved after the log pass +rdns_hits = {b: Counter() for b in BOT_RDNS} +rdns_proxied = Counter() +# {bot: {ip: Counter(path)}} - kept so that once an address is confirmed +# by DNS/ASN its paths can join the verified-path breakdown, which +# otherwise only ever showed IP-range-verified vendors. +rdns_paths = {b: {} for b in BOT_RDNS} +ROBOTS_RULES = load_robots() if WEEKLY else [] + + +def record_verified(bot, path, status, nbytes): + """Log what a confirmed crawler did. Called only after verification, + so these counters describe legitimate traffic and nothing else.""" + ver_paths[path] += 1 + ver_status[status] += 1 + ver_bytes[0] += nbytes + ver_bot_bytes[bot] += nbytes + if CONTENT_RE.search(path): + ver_content[bot] += 1 + ver_content_paths[path] += 1 + pkg = package_of(path) + if pkg: + owner, name = pkg + if name: + ver_pkgs[f"{owner}/{name}"] += 1 + else: + ver_pkg_index[owner] += 1 + r = repo_of(path) + if r: + ver_repos.setdefault(bot, Counter())[r] += 1 + if ROBOTS_RULES and robots_blocked(path, ROBOTS_RULES): + ver_violations[path] += 1 + + +for path in sorted(glob.glob(LOG_GLOB)): + opener = gzip.open if path.endswith(".gz") else open + with opener(path, "rt", errors="replace") as f: + for line in f: + if ROUTER and ROUTER not in line: + continue + for s in stamps: + if s in line: + per_day[s][0] += 1 + per_day[s][1].add(line.split(" ", 1)[0]) + parts = line.split() + if len(parts) > 6 and parts[6].count("/") >= 2: + repos["/".join(parts[6].split("/")[1:3])] += 1 + # Traefik CLF: ... "" "" "" ... + # Anchor on the request counter so this works whatever + # the router is called. + ua = re.search(r"\"[^\"]*\" \"([^\"]*)\" \d+ \"", line) + if ua: + u = ua.group(1) + m = re.search(r"(bot|crawler|spider|scrapy|externalagent|gpt|claude|perplexity)[\w./-]*", u, re.I) + uas[m.group(0) if m else ("(none)" if u == "-" else "(browser-like)")] += 1 + if WEEKLY: + # longest token first so Applebot-Extended wins over Applebot + bot = next((b for b in sorted(BOT_VENDOR, key=len, reverse=True) if b in u), None) + if bot: + try: + addr = ipaddress.ip_address(parts[0]) + except ValueError: + addr = None + if addr is None: + pass + elif any(addr in n for n in CFNETS): + proxied[bot] += 1 + elif in_index(RANGES.get(BOT_VENDOR[bot]), addr): + verified[bot] += 1 + ver_ips.setdefault(bot, set()).add(parts[0]) + if len(parts) > 9: + record_verified( + bot, parts[6][:60], parts[8], + int(parts[9]) if parts[9].isdigit() else 0) + else: + spoofed[bot] += 1 + if WEEKLY and RDNS_ENABLE: + rb = next((b for b in sorted(BOT_RDNS, key=len, reverse=True) + if b in u), None) + # skip if already counted by IP-range check + if rb and not (rb in BOT_VENDOR and rb == bot): + try: + a2 = ipaddress.ip_address(parts[0]) + except ValueError: + a2 = None + if a2 is None: + pass + elif any(a2 in n for n in CFNETS): + rdns_proxied[rb] += 1 + else: + rdns_hits[rb][parts[0]] += 1 + if len(parts) > 9 and not a2.is_private: + rdns_paths[rb].setdefault(parts[0], []).append( + (parts[6][:60], parts[8], + int(parts[9]) if parts[9].isdigit() else 0)) + break + +total = sum(v[0] for v in per_day.values()) +all_ips = set().union(*(v[1] for v in per_day.values())) + +# --- resolve rDNS candidates --------------------------------------------- +# One pass over unique addresses, busiest first, capped by RDNS_MAX so a +# flood of distinct forgeries cannot stall the report on DNS timeouts. +rdns_ok = Counter() # bot -> forward-confirmed by PTR +rdns_mismatch = Counter() # bot -> PTR exists but points elsewhere: forgery +rdns_noptr = Counter() # bot -> no PTR at all: cannot be judged by DNS +rdns_asn = Counter() # bot -> no PTR, but origin ASN is the vendor's +rdns_skipped = Counter() # bot -> hits left unresolved by the cap +rdns_private = Counter() # bot -> hits from RFC1918/loopback (see below) +rdns_ok_ips = {} +if WEEKLY and RDNS_ENABLE: + socket.setdefaulttimeout(3) + for bot, counter in rdns_hits.items(): + budget = RDNS_MAX + for ip, hits in counter.most_common(): + # A private source address means the real client IP never + # reached the log: something in front (Docker's bridge + # gateway, a local proxy) is rewriting it. Neither verified + # nor spoofed - the evidence simply is not there. + if ipaddress.ip_address(ip).is_private: + rdns_private[bot] += hits + continue + if budget <= 0: + rdns_skipped[bot] += hits + continue + budget -= 1 + ok, _host, why = fcrdns(ip, BOT_RDNS[bot]) + confirmed = False + if ok: + rdns_ok[bot] += hits + rdns_ok_ips.setdefault(bot, set()).add(ip) + confirmed = True + elif why == "no-ptr": + # Fall back to ASN, but only for vendors whose network is + # single-tenant (see BOT_ASN). Otherwise leave it unknown. + if ASN_ENABLE and bot in BOT_ASN and asn_of(ip) in BOT_ASN[bot]: + rdns_asn[bot] += hits + rdns_ok_ips.setdefault(bot, set()).add(ip) + confirmed = True + else: + rdns_noptr[bot] += hits + else: + rdns_mismatch[bot] += hits + if confirmed: + for p, st, nb in rdns_paths.get(bot, {}).get(ip, ()): + record_verified(bot, p, st, nb) + socket.setdefaulttimeout(None) + +if not WEEKLY: + s0 = stamps[0] + count, ips = per_day[s0][0], len(per_day[s0][1]) + print(f"{s0}: {count} requests, {ips} unique IPs (threshold {THRESHOLD})") + if DRY or count <= THRESHOLD: + sys.exit(0) + subject = f"{SITE}: {count} requests on {s0} (over {THRESHOLD}/day threshold)" + body = (f"Forgejo served {count} requests from {ips} unique IPs on {s0} - " + f"above the {THRESHOLD}/day watch threshold.\n\n" + "Time to consider Anubis (PoW challenge) in front of Forgejo.\n") +else: + lines = [f"{SITE} weekly crawler report ({stamps[0]} - {stamps[-1]})", ""] + lines.append(f"Total: {total} requests, {len(all_ips)} unique IPs") + lines.append(f"Daily threshold alert fires above {THRESHOLD} req/day (none = quiet week)") + lines.append("") + lines.append("Per day:") + for s in stamps: + lines.append(f" {s}: {per_day[s][0]:>7} requests, {len(per_day[s][1]):>6} unique IPs") + lines.append("") + lines.append("Top repos:") + for r, c in repos.most_common(5): + lines.append(f" {c:>7} {r}") + lines.append("") + lines.append("User-agent classes (browser-like = mostly the spoofing swarm):") + for u, c in uas.most_common(8): + lines.append(f" {c:>7} {u}") + lines.append("") + + # --- legitimate (IP-verified) crawlers ------------------------------- + lines.append("=" * 62) + lines.append("LEGITIMATE CRAWLERS (source IP inside vendor's published ranges)") + lines.append("=" * 62) + if STALE: + lines.append(f"NOTE: range fetch failed for {', '.join(STALE)} - used cache") + tv, ts, tp = sum(verified.values()), sum(spoofed.values()), sum(proxied.values()) + claimed = tv + ts + tp + if not claimed: + lines.append(" No AI-bot user-agents seen this week.") + else: + lines.append(f" {'bot':<20}{'verified':>9}{'spoofed':>9}{'via CF':>8} {'IPs':>4}") + for bot in sorted(set(verified) | set(spoofed) | set(proxied), + key=lambda b: -(verified[b] + spoofed[b] + proxied[b])): + lines.append(f" {bot:<20}{verified[bot]:>9}{spoofed[bot]:>9}" + f"{proxied[bot]:>8} {len(ver_ips.get(bot, ())):>4}") + pct = tv / claimed * 100 + lines.append("") + lines.append(f" {claimed} requests claimed an AI-bot identity; {tv} verified ({pct:.1f}%).") + lines.append(f" {ts} failed IP verification (spoofed). {tp} arrived via Cloudflare") + lines.append(" and cannot be verified by IP - not counted either way.") + # --- vendors verified by reverse DNS --------------------------------- + if RDNS_ENABLE and (rdns_ok or rdns_mismatch or rdns_noptr or rdns_asn + or rdns_proxied or rdns_private): + lines.append("") + lines.append("-" * 62) + lines.append("VERIFIED BY DNS / ASN (vendors publishing no IP ranges)") + lines.append("-" * 62) + lines.append(f" {'bot':<20}{'PTR ok':>7}{'ASN ok':>7}{'FORGED':>8}" + f"{'no-PTR':>7}{'CF':>6}{'priv':>7} {'IPs':>4}") + allbots = (set(rdns_ok) | set(rdns_mismatch) | set(rdns_noptr) + | set(rdns_asn) | set(rdns_proxied) | set(rdns_private)) + for bot in sorted(allbots, key=lambda b: -(rdns_ok[b] + rdns_mismatch[b] + + rdns_noptr[b] + rdns_asn[b] + + rdns_proxied[b] + rdns_private[b])): + lines.append(f" {bot:<20}{rdns_ok[bot]:>7}{rdns_asn[bot]:>7}" + f"{rdns_mismatch[bot]:>8}{rdns_noptr[bot]:>7}" + f"{rdns_proxied[bot]:>6}{rdns_private[bot]:>7}" + f" {len(rdns_ok_ips.get(bot, ())):>4}") + if rdns_skipped: + sk = ", ".join(f"{b} {c}" for b, c in rdns_skipped.most_common(4)) + lines.append(f" (unresolved, over CRAWLER_RDNS_MAX={RDNS_MAX}: {sk})") + lines.append("") + lines.append(" PTR ok forward-confirmed: PTR ends in a vendor domain AND") + lines.append(" that hostname resolves back to the same address.") + lines.append(" ASN ok no PTR, but the address sits in an ASN belonging") + lines.append(" solely to the vendor (Meta's AS32934). Only used") + lines.append(" where the ASN sells no compute - never for clouds.") + lines.append(" FORGED a PTR exists and points somewhere else. This is") + lines.append(" the only column that is evidence of forgery.") + lines.append(" no-PTR no PTR record and no usable ASN: unknown, not bad.") + if sum(rdns_private.values()): + lines.append(" priv logged source was RFC1918: a proxy or Docker") + lines.append(" bridge masked the client. Unjudgeable. See README.") + + # --- what the verified crawlers actually fetched --------------------- + # Last, because it spans both tables above: an address only counts here + # once it has been confirmed, whether by IP range, PTR or ASN. + if ver_paths: + lines.append("") + lines.append("=" * 62) + lines.append("WHAT THE VERIFIED CRAWLERS DID (all methods)") + lines.append("=" * 62) + tot_v = sum(ver_paths.values()) + mb = ver_bytes[0] / 1048576 + lines.append(f" {tot_v} requests, {mb:.1f} MB served.") + if ver_status: + mix = " ".join(f"{s}:{c}" for s, c in ver_status.most_common(6)) + lines.append(f" Status: {mix}") + if ver_bot_bytes: + top = " ".join(f"{b} {v/1048576:.1f}MB" + for b, v in ver_bot_bytes.most_common(4)) + lines.append(f" Bandwidth: {top}") + lines.append("") + if not ROBOTS_RULES: + lines.append(" robots.txt compliance: not checked " + "(set CRAWLER_ROBOTS to enable)") + elif ver_violations: + n = sum(ver_violations.values()) + lines.append(f" ROBOTS.TXT VIOLATIONS: {n} requests to disallowed paths") + for p, c in ver_violations.most_common(6): + lines.append(f" {c:>6} {p}") + lines.append(" A verified crawler ignoring robots.txt is a policy") + lines.append(" problem, not a security one - the identity is genuine.") + else: + lines.append(f" robots.txt compliance: clean, 0 violations in " + f"{tot_v} requests") + lines.append("") + # Repository content vs everything else. If robots.txt permits + # /src/ and /raw/, this is what says whether anyone took it up. + nc = sum(ver_content.values()) + pct_c = nc / tot_v * 100 if tot_v else 0 + lines.append(f" Repository content fetched: {nc} of {tot_v} requests " + f"({pct_c:.1f}%)") + if nc: + by_bot = " ".join(f"{b} {c}" for b, c in ver_content.most_common(5)) + lines.append(f" by: {by_bot}") + for p, c in ver_content_paths.most_common(8): + lines.append(f" {c:>6} {p}") + else: + lines.append(" none - crawlers indexed the site but read no code") + # Which repositories each vendor cares about. Grouped by vendor + # rather than by UA token: OpenAI alone sends three tokens, and + # "what is OpenAI reading" is the useful question. + if ver_repos: + groups = {} + for b, c in ver_repos.items(): + if b in BOT_VENDOR: + v = BOT_VENDOR[b] # openai, anthropic, ... + elif b in BOT_ASN: + v = "meta" + elif b in BOT_RDNS: + v = b.lower() # amazonbot, youbot, ... + else: + v = b.lower() + groups.setdefault(v, Counter()).update(c) + lines.append("") + lines.append(" Repositories by vendor:") + for v in sorted(groups, key=lambda x: -sum(groups[x].values())): + tot = sum(groups[v].values()) + top = ", ".join(f"{r} ({n})" for r, n in groups[v].most_common(3)) + lines.append(f" {v:<12} {tot:>5} hits {top}") + if ver_pkgs or ver_pkg_index: + np = sum(ver_pkgs.values()) + sum(ver_pkg_index.values()) + lines.append("") + lines.append(f" Package registry: {np} requests") + for p, c in ver_pkgs.most_common(6): + lines.append(f" {c:>6} {p}") + if ver_pkg_index: + idx = ", ".join(f"{o} ({n})" for o, n in ver_pkg_index.most_common(4)) + lines.append(f" index pages: {idx}") + lines.append("") + lines.append(" Top paths overall:") + for p, c in ver_paths.most_common(12): + lines.append(f" {c:>6} {p}") + body = "\n".join(lines) + "\n" + subject = f"{SITE} weekly crawler report: {total} requests, {len(all_ips)} IPs" + if DRY: + print(subject); print(); print(body) + sys.exit(0) + +# SMTP settings: use CRAWLER_SMTP_* if given, otherwise borrow them from +# a Forgejo/Gitea app.ini [mailer] section so there is no second copy of +# the credentials to keep in sync. +if os.environ.get("CRAWLER_SMTP_ADDR"): + addr = os.environ["CRAWLER_SMTP_ADDR"] + port = int(os.environ.get("CRAWLER_SMTP_PORT", "587")) + user = os.environ.get("CRAWLER_SMTP_USER", "") + passwd = os.environ.get("CRAWLER_SMTP_PASSWORD", "") + sender = os.environ.get("CRAWLER_SMTP_FROM", user or RECIPIENT) + proto = os.environ.get("CRAWLER_SMTP_PROTOCOL", "smtp+starttls") +else: + ini = subprocess.run(["docker", "exec", MAIL_CONTAINER, "cat", MAIL_INI], + capture_output=True, text=True).stdout + if not ini.strip(): + sys.exit(f"could not read {MAIL_INI} from container " + f"'{MAIL_CONTAINER}' and CRAWLER_SMTP_ADDR is unset") + cp = configparser.ConfigParser(interpolation=None, strict=False) + cp.read_string("[DEFAULT]\n" + ini) + m = cp["mailer"] + proto = m.get("PROTOCOL", "smtps").strip() + addr, port = m.get("SMTP_ADDR").strip(), int(m.get("SMTP_PORT", "465").strip()) + user, passwd = m.get("USER", "").strip(), m.get("PASSWD", "").strip().strip("`\"") + sender = m.get("FROM", user).strip() + +msg = MIMEText(body) +msg["Subject"], msg["From"], msg["To"] = subject, sender, RECIPIENT +if proto == "smtps": + s = smtplib.SMTP_SSL(addr, port, timeout=30) +else: + s = smtplib.SMTP(addr, port, timeout=30) + if proto != "smtp": # plain smtp = no TLS (local relay) + s.starttls() +if user: # unauthenticated local relays exist + s.login(user, passwd) +s.sendmail(sender, [RECIPIENT], msg.as_string()) +s.quit() +print(f"mailed to {RECIPIENT}") diff --git a/nixos/hosts/asxpio-ops/crawler.nix b/nixos/hosts/asxpio-ops/crawler.nix new file mode 100644 index 0000000..ad3d73f --- /dev/null +++ b/nixos/hosts/asxpio-ops/crawler.nix @@ -0,0 +1,82 @@ +# Crawler watch for Forgejo: separates real AI crawlers from traffic that +# only claims to be one, from Traefik's access log. A daily mail when +# yesterday crossed the threshold, a weekly summary, and metrics every +# five minutes for the Crawlers dashboard. +{ + config, + lib, + pkgs, + ... +}: +let + # flag: "" (daily alert), "--weekly" or "--metrics" + run = flag: extra: { + description = "Crawler report ${flag}"; + after = [ "network-online.target" ]; + wants = [ "network-online.target" ]; + environment = { + CRAWLER_SITE = "git.asxp.io"; + CRAWLER_THRESHOLD = "100000"; + CRAWLER_ROBOTS = "https://git.czsk.it/robots.txt"; + CRAWLER_LOG = "/var/log/traefik/access.log*"; + CRAWLER_LIVE_LOG = "/var/log/traefik/access.log"; + CRAWLER_ROUTER = "forgejo@file"; + CRAWLER_TEXTFILE = "/var/lib/node_exporter/textfile/crawler.prom"; + CRAWLER_SMTP_ADDR = "smtp.fastmail.com"; + CRAWLER_SMTP_PORT = "587"; + CRAWLER_SMTP_FROM = "Czechoslovakia Git "; + } + // extra; + serviceConfig = { + Type = "oneshot"; + EnvironmentFile = config.sops.templates."crawler.env".path; + CacheDirectory = "crawler-alert"; + ExecStart = "${pkgs.python3}/bin/python3 ${./crawler-alert.py} ${flag}"; + }; + }; +in +{ + sops.templates."crawler.env".content = '' + CRAWLER_RECIPIENT=${config.sops.placeholder."alert/recipient"} + CRAWLER_SMTP_USER=${config.sops.placeholder."alert/smtp_user"} + CRAWLER_SMTP_PASSWORD=${config.sops.placeholder."alert/smtp_password"} + ''; + + systemd.services = { + crawler-alert = run "" { }; + crawler-weekly = run "--weekly" { }; + # Every router, not only Forgejo's; fewer DNS lookups per run + crawler-metrics = lib.recursiveUpdate (run "--metrics" { + CRAWLER_METRICS_ROUTER = ""; + CRAWLER_RDNS_MAX = "100"; + }) { + serviceConfig = { + Nice = 10; + TimeoutStartSec = "4min"; + }; + }; + }; + systemd.timers = { + crawler-alert = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = "*-*-* 00:15:00"; + Persistent = true; + }; + }; + crawler-weekly = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = "Mon *-*-* 12:00:00"; + Persistent = true; + }; + }; + crawler-metrics = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = "*:0/5"; + RandomizedDelaySec = 30; + }; + }; + }; +} diff --git a/nixos/hosts/asxpio-ops/default.nix b/nixos/hosts/asxpio-ops/default.nix new file mode 100644 index 0000000..217a176 --- /dev/null +++ b/nixos/hosts/asxpio-ops/default.nix @@ -0,0 +1,74 @@ +# asxpio-ops: Traefik, Forgejo, storage, the app stacks. +# Services are added here as they move over from ../../ansible (see +# MIGRATION.md at the repo root); until then this is the base system only. +{ lib, ... }: +{ + imports = [ + ./apps.nix + ./crawler.nix + ./forgejo.nix + ./garage.nix + ./monitoring + ./options.nix + ./postgres.nix + ./traefik.nix + ./xmpp-cert-sync.nix + ]; + + networking.hostName = lib.mkDefault "asxpio-ops"; + networking.domain = "asxp.io"; + asxpio.privateIPv4 = "10.10.0.10"; + system.stateVersion = "26.05"; + + systemd.network.networks."10-public".address = [ "2a01:4f9:c013:3258::1/64" ]; + + sops.defaultSopsFile = lib.mkDefault ../../secrets/asxpio-ops.yaml; + + # --- WireGuard hub ------------------------------------------------------- + asxpio.wireguard = { + interface = "wg0"; + address = [ + "10.20.0.10/24" + "fd69:69:69::1/64" + ]; + listenPort = 60101; + hub = true; + peers = lib.mkDefault ( + map + (p: { + inherit (p) name publicKey; + allowedIPs = [ + "10.20.0.${toString p.id}/32" + "fd69:69:69::${toString p.id}/128" + ]; + }) + [ + { id = 20; name = "asxpio-services"; publicKey = "I2D4RvGHm0bW2mMlq9lPvbINHvnP9MsZg4XGMKTLiSU="; } + { id = 2; name = "laptop"; publicKey = "6xYBPCiAa1MBusj7ilHGvwIoj26cXymvVksrOQLY52g="; } + { id = 3; name = "aleks"; publicKey = "Csqd94oo6eRLUrlzeEkFxlW2IZtQG61ASXdK+ZjKzGI="; } + { id = 4; name = "zerrtika"; publicKey = "uBRSmDuM25ciVaS9GxlCbjNPMUlmtphPDvtcEFzs8kI="; } + { id = 5; name = "sanya"; publicKey = "tegWIorm7PjagnixbzQjCGLqDKVImynLNgk/bfx2PEk="; } + ] + ); + }; + + swapDevices = [ + { + device = "/swapfile"; + size = 2048; + } + ]; + + # --- Backup --------------------------------------------------------------- + # Each service adds its own paths and hooks next to its definition: + # Postgres as a dump, Garage with a metadata snapshot, Forgejo's SQLite + # through the online backup API. + asxpio.backup = { + hostName = "asxpio-ops"; + schedule = "*-*-* 03:30:00"; + paths = [ + "/etc/ssh" # the host key decrypts this host's secrets + "/opt" + ]; + }; +} diff --git a/nixos/hosts/asxpio-ops/forgejo.nix b/nixos/hosts/asxpio-ops/forgejo.nix new file mode 100644 index 0000000..d496706 --- /dev/null +++ b/nixos/hosts/asxpio-ops/forgejo.nix @@ -0,0 +1,136 @@ +# Forgejo at git.asxp.io (git.czsk.it is an alias), with its package +# registry and Actions. It runs as user git, so git@git.asxp.io reaches +# it through the host's sshd with no passthrough. +# +# State: /var/lib/forgejo (repositories/, data/forgejo.db, data/lfs, ...). +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.services.forgejo; + secret = name: config.sops.secrets."forgejo/${name}".path; +in +{ + sops.secrets = lib.genAttrs (map (n: "forgejo/${n}") [ + "secret_key" + "internal_token" + "jwt_secret" + "lfs_jwt_secret" + "smtp_user" + "smtp_password" + "metrics_token" + ]) (_: { owner = cfg.user; }); + + users.users.git = { + isSystemUser = true; + group = "git"; + home = cfg.stateDir; + # Forgejo's SSH commands run through it; not the zsh default + shell = pkgs.bashInteractive; + }; + users.groups.git = { }; + # Anyone may try a key against git; Forgejo decides what it may do + services.openssh.settings.AllowUsers = [ "git" ]; + asxpio.security.loginUsers = [ "git" ]; + # HTTP for Traefik and, over the private network, for the runners + asxpio.security.ports = [ "tcp/3000/.forgejo-wrappe" ]; + asxpio.security.forgejoDb = "${cfg.stateDir}/data/forgejo.db"; + + services.forgejo = { + enable = true; + package = pkgs.forgejo; # the current release, not the LTS: the data is from 17 + user = "git"; + group = "git"; + database.type = "sqlite3"; + lfs.enable = true; + + secrets = { + security.SECRET_KEY = lib.mkForce (secret "secret_key"); + security.INTERNAL_TOKEN = lib.mkForce (secret "internal_token"); + oauth2.JWT_SECRET = lib.mkForce (secret "jwt_secret"); + server.LFS_JWT_SECRET = lib.mkForce (secret "lfs_jwt_secret"); + mailer.USER = secret "smtp_user"; + mailer.PASSWD = secret "smtp_password"; + metrics.TOKEN = secret "metrics_token"; + }; + + settings = { + DEFAULT.APP_NAME = "Git with a cup of tea"; + server = { + DOMAIN = "git.asxp.io"; + ROOT_URL = "https://git.asxp.io/"; + HTTP_PORT = 3000; + SSH_DOMAIN = "git.asxp.io"; + SSH_PORT = 22; + LANDING_PAGE = "explore"; + }; + repository = { + DEFAULT_BRANCH = "main"; + DEFAULT_PRIVATE = "private"; + ENABLE_PUSH_CREATE_USER = true; + ENABLE_PUSH_CREATE_ORG = false; + DEFAULT_REPO_UNITS = "repo.code,repo.releases,repo.issues,repo.pulls,repo.wiki,repo.projects,repo.packages,repo.actions"; + }; + "repository.pull-request".DEFAULT_MERGE_STYLE = "merge"; + "repository.signing".DEFAULT_TRUST_MODEL = "collaborator"; + ui = { + THEMES = "forgejo-auto,forgejo-light,forgejo-dark,gitea-auto,gitea-light,gitea-dark"; + DEFAULT_THEME = "forgejo-auto"; + }; + security.PASSWORD_HASH_ALGO = "pbkdf2"; + service = { + DISABLE_REGISTRATION = true; + REQUIRE_SIGNIN_VIEW = false; + REGISTER_EMAIL_CONFIRM = false; + ENABLE_NOTIFY_MAIL = true; + DEFAULT_KEEP_EMAIL_PRIVATE = true; + DEFAULT_ALLOW_CREATE_ORGANIZATION = true; + DEFAULT_ENABLE_TIMETRACKING = true; + NO_REPLY_ADDRESS = "noreply.git.asxp.io"; + }; + oauth2.ENABLED = true; + mailer = { + ENABLED = lib.mkDefault true; + FROM = "Czechoslovakia Git "; + PROTOCOL = "smtp+starttls"; + SMTP_ADDR = "smtp.fastmail.com"; + SMTP_PORT = 587; + }; + session.PROVIDER = "file"; + log.LEVEL = "Info"; + actions = { + ENABLED = true; + DEFAULT_ACTIONS_URL = "https://github.com"; + ARTIFACT_RETENTION_DAYS = 365; + }; + packages.ENABLED = true; + other = { + SHOW_FOOTER_VERSION = false; + SHOW_FOOTER_TEMPLATE_LOAD_TIME = false; + SHOW_FOOTER_POWERED_BY = false; + }; + metrics.ENABLED = true; + }; + }; + asxpio.waitForData = [ + "forgejo" + "forgejo-secrets" + ]; + + # `forgejo-admin regenerate keys`, `forgejo-admin user list`, ... + environment.systemPackages = [ + (pkgs.writeShellScriptBin "forgejo-admin" '' + exec ${pkgs.util-linux}/bin/runuser -u ${cfg.user} -- env \ + HOME=${cfg.stateDir} FORGEJO_WORK_DIR=${cfg.stateDir} FORGEJO_CUSTOM=${cfg.customDir} \ + ${lib.getExe cfg.package} --config ${cfg.customDir}/conf/app.ini admin "$@" + '') + ]; + + asxpio.backup.paths = [ "/var/lib/forgejo" ]; + asxpio.backup.hooks = [ + ''sqlite3 /var/lib/forgejo/data/forgejo.db ".backup '$STAGE/forgejo.db'"'' + ]; +} diff --git a/nixos/hosts/asxpio-ops/garage.nix b/nixos/hosts/asxpio-ops/garage.nix new file mode 100644 index 0000000..6b68686 --- /dev/null +++ b/nixos/hosts/asxpio-ops/garage.nix @@ -0,0 +1,174 @@ +# Garage (S3) for the apps, single node. Buckets, keys and grants are set +# on every start from sops. +# +# asxpio-invoices asxpio rw +# datacenterbingo-photos asxpio rw, bingo ro +# public a website (anonymous reads through Traefik); +# asxpio and public-upload write only +# +# Garage only takes keys in its own format (GK + 24 hex, 64 hex). The +# apps' keys predate it and are hashed into that format, here and in each +# app's deploy workflow: keep the two in step. +{ + config, + lib, + pkgs, + ... +}: +let + garage = pkgs.garage_2; + rpcSecret = config.sops.secrets."garage/rpc_secret".path; + keys = [ + "asxpio" + "bingo" + "public" + ]; +in +{ + sops.secrets = { + "garage/rpc_secret" = { }; + } + // lib.listToAttrs ( + lib.concatMap (k: [ + (lib.nameValuePair "garage/${k}_access_key" { }) + (lib.nameValuePair "garage/${k}_secret_key" { }) + ]) keys + ); + + services.garage = { + enable = true; + package = garage; + # The RPC secret is a systemd credential: mode 0440, but in a + # directory only this service can enter + extraEnvironment.GARAGE_ALLOW_WORLD_READABLE_SECRETS = "true"; + settings = { + # One node and no replica to repair from, so prefer the engine that + # survives an unclean stop, sync writes, and keep metadata snapshots + db_engine = "sqlite"; + metadata_fsync = true; + data_fsync = true; + metadata_auto_snapshot_interval = "6h"; + replication_factor = 1; + + rpc_bind_addr = "[::]:3901"; + rpc_public_addr = "127.0.0.1:3901"; + rpc_secret_file = "/run/credentials/garage.service/rpc_secret"; + + # The apps sign for us-east-1, as they did against MinIO + s3_api = { + s3_region = "us-east-1"; + api_bind_addr = "[::]:3900"; + }; + # Anonymous reads: a bucket marked as a website is served here, + # picked by Host: .web.garage + s3_web = { + bind_addr = "[::]:3902"; + root_domain = ".web.garage"; + index = "index.html"; + }; + }; + }; + asxpio.waitForData = [ + "garage" + "garage-bootstrap" + ]; + systemd.services.garage = { + serviceConfig = { + LoadCredential = [ "rpc_secret:${rpcSecret}" ]; + ExecStart = lib.mkForce "${garage}/bin/garage server --single-node"; + }; + }; + networking.firewall.interfaces."podman*".allowedTCPPorts = [ 3900 ]; + asxpio.security.ports = [ "tcp/3900-3902/garage" ]; + + # `garage` for root, e.g. garage status, garage bucket list + environment.systemPackages = [ + (pkgs.writeShellScriptBin "garage" '' + export GARAGE_RPC_SECRET_FILE=${rpcSecret} + exec ${garage}/bin/garage -c /etc/garage.toml "$@" + '') + ]; + + systemd.services.garage-bootstrap = { + description = "Garage buckets, keys and grants"; + after = [ "garage.service" ]; + requires = [ "garage.service" ]; + wantedBy = [ "multi-user.target" ]; + path = [ + garage + pkgs.gnugrep + pkgs.coreutils + ]; + environment.GARAGE_RPC_SECRET_FILE = rpcSecret; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + script = '' + set -eu + g() { garage -c /etc/garage.toml "$@"; } + secret() { cat "/run/secrets/garage/$1"; } + + key_id() { + if printf '%s' "$1" | grep -Eq '^GK[0-9a-f]{24}$'; then printf '%s' "$1" + else printf 'GK%s' "$(printf '%s' "$1" | sha256sum | cut -c1-24)"; fi + } + key_secret() { + if printf '%s' "$1" | grep -Eq '^[0-9a-f]{64}$'; then printf '%s' "$1" + else printf '%s' "$1" | sha256sum | cut -c1-64; fi + } + + i=0 + until g status >/dev/null 2>&1; do + i=$((i + 1)) + [ "$i" -le 60 ] || { echo "garage did not come up" >&2; exit 1; } + sleep 1 + done + + ensure_bucket() { g bucket info "$1" >/dev/null 2>&1 || g bucket create "$1" >/dev/null; } + # ensure_key : prints the key id + ensure_key() { + id="$(key_id "$(secret "$2_access_key")")" + sec="$(key_secret "$(secret "$2_secret_key")")" + if g key info --show-secret "$id" >/dev/null 2>&1; then + if ! g key info --show-secret "$id" | grep -q "$sec"; then + g key delete --yes "$id" >/dev/null + g key import --yes -n "$1" "$id" "$sec" >/dev/null + fi + else + g key import --yes -n "$1" "$id" "$sec" >/dev/null + fi + printf '%s' "$id" + } + grant() { + case "$3" in + rw) g bucket allow --read --write "$1" --key "$2" >/dev/null + g bucket deny --owner "$1" --key "$2" >/dev/null ;; + ro) g bucket allow --read "$1" --key "$2" >/dev/null + g bucket deny --write --owner "$1" --key "$2" >/dev/null ;; + wo) g bucket allow --write "$1" --key "$2" >/dev/null + g bucket deny --read --owner "$1" --key "$2" >/dev/null ;; + esac + } + + ensure_bucket asxpio-invoices + ensure_bucket datacenterbingo-photos + ensure_bucket public + g bucket website --allow public >/dev/null + + asxpio="$(ensure_key asxpio asxpio)" + grant asxpio-invoices "$asxpio" rw + grant datacenterbingo-photos "$asxpio" rw + grant public "$asxpio" wo + + bingo="$(ensure_key bingo bingo)" + grant datacenterbingo-photos "$bingo" ro + + uploader="$(ensure_key public-upload public)" + grant public "$uploader" wo + ''; + }; + + asxpio.backup.paths = [ "/var/lib/garage" ]; + asxpio.backup.hooks = [ "/run/current-system/sw/bin/garage meta snapshot --all" ]; +} diff --git a/nixos/hosts/asxpio-ops/monitoring/alert-rules.yaml b/nixos/hosts/asxpio-ops/monitoring/alert-rules.yaml new file mode 100644 index 0000000..37725cf --- /dev/null +++ b/nixos/hosts/asxpio-ops/monitoring/alert-rules.yaml @@ -0,0 +1,544 @@ +# 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\\S+) from (?P\\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)" } diff --git a/nixos/hosts/asxpio-ops/monitoring/dashboards/Infrastructure/containers.json b/nixos/hosts/asxpio-ops/monitoring/dashboards/Infrastructure/containers.json new file mode 100644 index 0000000..06f43b0 --- /dev/null +++ b/nixos/hosts/asxpio-ops/monitoring/dashboards/Infrastructure/containers.json @@ -0,0 +1,781 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": 14282, + "graphTooltip": 0, + "id": null, + "iteration": 1617715580880, + "links": [], + "panels": [ + { + "collapsed": false, + "datasource": "prometheus", + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 8, + "panels": [], + "title": "CPU", + "type": "row" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 1 + }, + "hiddenSeries": false, + "id": 15, + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "max": true, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null as zero", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.4.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "sum(rate(container_cpu_usage_seconds_total{instance=~\"$host\",name=~\"$container\",name=~\".+\"}[5m])) by (name) *100", + "hide": false, + "interval": "", + "legendFormat": "{{name}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "CPU Usage", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:606", + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:607", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "collapsed": false, + "datasource": "prometheus", + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 8 + }, + "id": 11, + "panels": [], + "title": "Memory", + "type": "row" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 9 + }, + "hiddenSeries": false, + "id": 9, + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "max": true, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null as zero", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.4.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "sum(container_memory_rss{instance=~\"$host\",name=~\"$container\",name=~\".+\"}) by (name)", + "hide": false, + "interval": "", + "legendFormat": "{{name}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Memory Usage", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:606", + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:607", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 9 + }, + "hiddenSeries": false, + "id": 14, + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "max": true, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null as zero", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.4.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "sum(container_memory_cache{instance=~\"$host\",name=~\"$container\",name=~\".+\"}) by (name)", + "hide": false, + "interval": "", + "legendFormat": "{{name}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Memory Cached", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:606", + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:607", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "collapsed": false, + "datasource": "prometheus", + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 17 + }, + "id": 2, + "panels": [], + "title": "Network", + "type": "row" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 18 + }, + "hiddenSeries": false, + "id": 4, + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "hideEmpty": false, + "hideZero": false, + "max": true, + "min": false, + "rightSide": true, + "show": true, + "sideWidth": null, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.4.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(rate(container_network_receive_bytes_total{instance=~\"$host\",name=~\"$container\",name=~\".+\"}[5m])) by (name)", + "hide": false, + "interval": "", + "legendFormat": "{{name}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Received Network Traffic", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:674", + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:675", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 18 + }, + "hiddenSeries": false, + "id": 6, + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "max": true, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.4.5", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(rate(container_network_transmit_bytes_total{instance=~\"$host\",name=~\"$container\",name=~\".+\"}[5m])) by (name)", + "interval": "", + "legendFormat": "{{name}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Sent Network Traffic", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:832", + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:833", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "collapsed": false, + "datasource": "prometheus", + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 26 + }, + "id": 19, + "panels": [], + "title": "Misc", + "type": "row" + }, + { + "datasource": "prometheus", + "fieldConfig": { + "defaults": { + "custom": { + "align": null, + "filterable": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "id" + }, + "properties": [ + { + "id": "custom.width", + "value": 260 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Running" + }, + "properties": [ + { + "id": "unit", + "value": "d" + }, + { + "id": "decimals", + "value": 1 + }, + { + "id": "custom.displayMode", + "value": "color-text" + }, + { + "id": "color", + "value": { + "fixedColor": "dark-green", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 24, + "x": 0, + "y": 27 + }, + "id": 17, + "options": { + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "7.4.5", + "targets": [ + { + "expr": "(time() - container_start_time_seconds{instance=~\"$host\",name=~\"$container\",name=~\".+\"})/86400", + "format": "table", + "instant": true, + "interval": "", + "legendFormat": "{{name}}", + "refId": "A" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Containers Info", + "transformations": [ + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "container_label_com_docker_compose_project", + "container_label_com_docker_compose_project_working_dir", + "image", + "instance", + "name", + "Value", + "container_label_com_docker_compose_service" + ] + } + } + }, + { + "id": "organize", + "options": { + "excludeByName": {}, + "indexByName": {}, + "renameByName": { + "Value": "Running", + "container_label_com_docker_compose_project": "Label", + "container_label_com_docker_compose_project_working_dir": "Working dir", + "container_label_com_docker_compose_service": "Service", + "image": "Registry Image", + "instance": "Instance", + "name": "Name" + } + } + } + ], + "type": "table" + } + ], + "schemaVersion": 27, + "style": "dark", + "tags": [ + "cadvisor", + "docker" + ], + "templating": { + "list": [ + { + "allValue": ".*", + "current": {}, + "datasource": "prometheus", + "definition": "label_values({__name__=~\"container.*\"},instance)", + "description": null, + "error": null, + "hide": 0, + "includeAll": true, + "label": "Host", + "multi": false, + "name": "host", + "options": [], + "query": { + "query": "label_values({__name__=~\"container.*\"},instance)", + "refId": "Prometheus-host-Variable-Query" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 5, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": ".*", + "current": {}, + "datasource": "prometheus", + "definition": "label_values({__name__=~\"container.*\", instance=~\"$host\"},name)", + "description": null, + "error": null, + "hide": 0, + "includeAll": true, + "label": "Container", + "multi": false, + "name": "container", + "options": [], + "query": { + "query": "label_values({__name__=~\"container.*\", instance=~\"$host\"},name)", + "refId": "Prometheus-container-Variable-Query" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Cadvisor exporter", + "uid": "gnet-14282", + "version": 1, + "description": "Simple exporter for cadvisor only" +} \ No newline at end of file diff --git a/nixos/hosts/asxpio-ops/monitoring/dashboards/Infrastructure/hosts.json b/nixos/hosts/asxpio-ops/monitoring/dashboards/Infrastructure/hosts.json new file mode 100644 index 0000000..db45e83 --- /dev/null +++ b/nixos/hosts/asxpio-ops/monitoring/dashboards/Infrastructure/hosts.json @@ -0,0 +1,15517 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 1, + "id": null, + "links": [ + { + "icon": "external link", + "tags": [], + "targetBlank": true, + "title": "GitHub", + "type": "link", + "url": "https://github.com/rfmoz/grafana-dashboards" + }, + { + "icon": "external link", + "tags": [], + "targetBlank": true, + "title": "Grafana", + "type": "link", + "url": "https://grafana.com/grafana/dashboards/1860" + } + ], + "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 261, + "panels": [], + "title": "Quick CPU / Mem / Disk", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Resource pressure via PSI", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "decimals": 1, + "links": [], + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green" + }, + { + "color": "dark-yellow", + "value": 70 + }, + { + "color": "dark-red", + "value": 90 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 0, + "y": 1 + }, + "id": 323, + "options": { + "displayMode": "basic", + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "maxVizHeight": 300, + "minVizHeight": 10, + "minVizWidth": 0, + "namePlacement": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showUnfilled": true, + "sizing": "auto", + "text": {}, + "valueMode": "color" + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "exemplar": false, + "expr": "rate(node_pressure_cpu_waiting_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "instant": true, + "legendFormat": "CPU", + "range": false, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "exemplar": false, + "expr": "rate(node_pressure_memory_waiting_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "instant": true, + "legendFormat": "Mem", + "range": false, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "exemplar": false, + "expr": "rate(node_pressure_io_waiting_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "instant": true, + "legendFormat": "I/O", + "range": false, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "exemplar": false, + "expr": "rate(node_pressure_irq_stalled_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "instant": true, + "legendFormat": "Irq", + "range": false, + "refId": "D", + "step": 240 + } + ], + "title": "Pressure", + "type": "bargauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Overall CPU busy percentage (averaged across all cores)", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "decimals": 1, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" + } + ], + "max": 100, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "dark-green" + }, + { + "color": "orange", + "value": 85 + }, + { + "color": "red", + "value": 95 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 3, + "y": 1 + }, + "id": 20, + "options": { + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "sizing": "auto" + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "exemplar": false, + "expr": "100 * (1 - avg(rate(node_cpu_seconds_total{mode=\"idle\",instance=\"$node\",job=\"$job\"}[$__rate_interval])))", + "instant": true, + "legendFormat": "", + "range": false, + "refId": "A", + "step": 240 + } + ], + "title": "CPU Busy", + "type": "gauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Tasks running or waiting (CPU, I/O) per core", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "decimals": 1, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" + } + ], + "max": 100, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "dark-green" + }, + { + "color": "orange", + "value": 85 + }, + { + "color": "red", + "value": 95 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 6, + "y": 1 + }, + "id": 155, + "options": { + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "sizing": "auto" + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "exemplar": false, + "expr": "scalar(node_load1{instance=\"$node\",job=\"$job\"}) * 100 / count(count(node_cpu_seconds_total{instance=\"$node\",job=\"$job\"}) by (cpu))", + "format": "time_series", + "instant": true, + "range": false, + "refId": "A", + "step": 240 + } + ], + "title": "Sys Load", + "type": "gauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Real RAM usage excluding cache and reclaimable memory", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "decimals": 1, + "mappings": [], + "max": 100, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "dark-green" + }, + { + "color": "orange", + "value": 80 + }, + { + "color": "red", + "value": 90 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 9, + "y": 1 + }, + "id": 16, + "options": { + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "sizing": "auto" + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "exemplar": false, + "expr": "clamp_min((1 - (node_memory_MemAvailable_bytes{instance=\"$node\", job=\"$job\"} / node_memory_MemTotal_bytes{instance=\"$node\", job=\"$job\"})) * 100, 0)", + "format": "time_series", + "instant": true, + "range": false, + "refId": "B", + "step": 240 + } + ], + "title": "RAM Used", + "type": "gauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Percentage of swap space currently used by the system", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "decimals": 1, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" + } + ], + "max": 100, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "dark-green" + }, + { + "color": "orange", + "value": 10 + }, + { + "color": "red", + "value": 25 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 12, + "y": 1 + }, + "id": 21, + "options": { + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "sizing": "auto" + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "exemplar": false, + "expr": "((node_memory_SwapTotal_bytes{instance=\"$node\",job=\"$job\"} - node_memory_SwapFree_bytes{instance=\"$node\",job=\"$job\"}) / (node_memory_SwapTotal_bytes{instance=\"$node\",job=\"$job\"} > 0)) * 100", + "instant": true, + "range": false, + "refId": "A", + "step": 240 + } + ], + "title": "SWAP Used", + "type": "gauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Percentage of root filesystem space currently used", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "decimals": 1, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" + } + ], + "max": 100, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "dark-green" + }, + { + "color": "orange", + "value": 80 + }, + { + "color": "red", + "value": 90 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 15, + "y": 1 + }, + "id": 154, + "options": { + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "sizing": "auto" + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "exemplar": false, + "expr": "(\n (node_filesystem_size_bytes{instance=\"$node\", job=\"$job\", mountpoint=\"/\", fstype!=\"rootfs\"}\n - node_filesystem_avail_bytes{instance=\"$node\", job=\"$job\", mountpoint=\"/\", fstype!=\"rootfs\"})\n / node_filesystem_size_bytes{instance=\"$node\", job=\"$job\", mountpoint=\"/\", fstype!=\"rootfs\"}\n) * 100\n", + "format": "time_series", + "instant": true, + "range": false, + "refId": "A", + "step": 240 + } + ], + "title": "Root FS Used", + "type": "gauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short", + "displayName": "CPU Cores" + }, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 2, + "x": 18, + "y": 1 + }, + "id": 14, + "maxDataPoints": 100, + "options": { + "colorMode": "none", + "graphMode": "none", + "justifyMode": "center", + "orientation": "horizontal", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "value_and_name", + "wideLayout": false, + "text": { + "titleSize": 12, + "valueSize": 20 + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "exemplar": false, + "expr": "count(count(node_cpu_seconds_total{instance=\"$node\",job=\"$job\"}) by (cpu))", + "instant": true, + "legendFormat": "__auto", + "range": false, + "refId": "A" + } + ], + "title": "", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "decimals": 0, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "bytes", + "displayName": "RAM Total" + }, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 2, + "x": 20, + "y": 1 + }, + "id": 75, + "maxDataPoints": 100, + "options": { + "colorMode": "none", + "graphMode": "none", + "justifyMode": "center", + "orientation": "horizontal", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "value_and_name", + "wideLayout": false, + "text": { + "titleSize": 12, + "valueSize": 20 + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "exemplar": false, + "expr": "node_memory_MemTotal_bytes{instance=\"$node\",job=\"$job\"}", + "instant": true, + "range": false, + "refId": "A", + "step": 240 + } + ], + "title": "", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "decimals": 0, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "bytes", + "displayName": "SWAP Total" + }, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 2, + "x": 22, + "y": 1 + }, + "id": 18, + "maxDataPoints": 100, + "options": { + "colorMode": "none", + "graphMode": "none", + "justifyMode": "center", + "orientation": "horizontal", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "value_and_name", + "wideLayout": false, + "text": { + "titleSize": 12, + "valueSize": 20 + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "exemplar": false, + "expr": "node_memory_SwapTotal_bytes{instance=\"$node\",job=\"$job\"}", + "instant": true, + "range": false, + "refId": "A", + "step": 240 + } + ], + "title": "", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "decimals": 0, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "bytes", + "displayName": "RootFS Total" + }, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 18, + "y": 3 + }, + "id": 23, + "maxDataPoints": 100, + "options": { + "colorMode": "none", + "graphMode": "none", + "justifyMode": "center", + "orientation": "horizontal", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "value_and_name", + "wideLayout": false, + "text": { + "titleSize": 12, + "valueSize": 20 + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "exemplar": false, + "expr": "node_filesystem_size_bytes{instance=\"$node\",job=\"$job\",mountpoint=\"/\",fstype!=\"rootfs\"}", + "format": "time_series", + "instant": true, + "range": false, + "refId": "A", + "step": 240 + } + ], + "title": "", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "decimals": 1, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "s", + "displayName": "Uptime" + }, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 3, + "x": 21, + "y": 3 + }, + "id": 15, + "maxDataPoints": 100, + "options": { + "colorMode": "none", + "graphMode": "none", + "justifyMode": "center", + "orientation": "horizontal", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "value_and_name", + "wideLayout": false, + "text": { + "titleSize": 12, + "valueSize": 20 + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "exemplar": false, + "expr": "node_time_seconds{instance=\"$node\",job=\"$job\"} - node_boot_time_seconds{instance=\"$node\",job=\"$job\"}", + "instant": true, + "range": false, + "refId": "A", + "step": 240 + } + ], + "title": "", + "type": "stat" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 5 + }, + "id": 263, + "panels": [], + "title": "Basic CPU / Mem / Net / Disk", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "CPU time spent busy vs idle, split by activity type", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 40, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "percent" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "percentunit" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Busy Iowait" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#890F02", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Idle" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#052B51", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Busy System" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#EAB839", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Busy User" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#0A437C", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Busy Other" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#6D1F62", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 6 + }, + "id": 77, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true, + "width": 250 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "exemplar": false, + "expr": "avg(rate(node_cpu_seconds_total{instance=\"$node\",job=\"$job\", mode=\"system\"}[$__rate_interval]))", + "format": "time_series", + "instant": false, + "legendFormat": "Busy System", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "avg(rate(node_cpu_seconds_total{instance=\"$node\",job=\"$job\", mode=\"user\"}[$__rate_interval]))", + "format": "time_series", + "legendFormat": "Busy User", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "avg(rate(node_cpu_seconds_total{instance=\"$node\",job=\"$job\", mode=\"iowait\"}[$__rate_interval]))", + "format": "time_series", + "legendFormat": "Busy Iowait", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "avg(sum without(mode) (rate(node_cpu_seconds_total{instance=\"$node\",job=\"$job\", mode=~\".*irq\"}[$__rate_interval])))", + "format": "time_series", + "legendFormat": "Busy IRQs", + "range": true, + "refId": "D", + "step": 240 + }, + { + "editorMode": "code", + "expr": "avg(sum without (mode) (rate(node_cpu_seconds_total{instance=\"$node\",job=\"$job\", mode!='idle',mode!='user',mode!='system',mode!='iowait',mode!='irq',mode!='softirq'}[$__rate_interval])))", + "format": "time_series", + "legendFormat": "Busy Other", + "range": true, + "refId": "E", + "step": 240 + }, + { + "editorMode": "code", + "expr": "avg(rate(node_cpu_seconds_total{instance=\"$node\",job=\"$job\", mode=\"idle\"}[$__rate_interval]))", + "format": "time_series", + "legendFormat": "Idle", + "range": true, + "refId": "F", + "step": 240 + } + ], + "title": "CPU Basic", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "RAM and swap usage overview, including caches", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 40, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Swap used" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#BF1B00", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Total" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#E0F9D7", + "mode": "fixed" + } + }, + { + "id": "custom.fillOpacity", + "value": 0 + }, + { + "id": "custom.stacking", + "value": { + "group": false, + "mode": "normal" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Cache + Buffer" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#052B51", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Free" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#7EB26D", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 6 + }, + "id": 78, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true, + "width": 350 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_memory_MemTotal_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Total", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_MemTotal_bytes{instance=\"$node\",job=\"$job\"} - node_memory_MemFree_bytes{instance=\"$node\",job=\"$job\"} - (node_memory_Cached_bytes{instance=\"$node\",job=\"$job\"} + node_memory_Buffers_bytes{instance=\"$node\",job=\"$job\"} + node_memory_SReclaimable_bytes{instance=\"$node\",job=\"$job\"})", + "format": "time_series", + "legendFormat": "Used", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_Cached_bytes{instance=\"$node\",job=\"$job\"} + node_memory_Buffers_bytes{instance=\"$node\",job=\"$job\"} + node_memory_SReclaimable_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Cache + Buffer", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_MemFree_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Free", + "range": true, + "refId": "D", + "step": 240 + }, + { + "editorMode": "code", + "expr": "(node_memory_SwapTotal_bytes{instance=\"$node\",job=\"$job\"} - node_memory_SwapFree_bytes{instance=\"$node\",job=\"$job\"})", + "format": "time_series", + "legendFormat": "Swap used", + "range": true, + "refId": "E", + "step": 240 + } + ], + "title": "Memory Basic", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Per-interface network traffic (receive and transmit) in bits per second", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 40, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*Tx.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 13 + }, + "id": 74, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_network_receive_bytes_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])*8", + "format": "time_series", + "legendFormat": "Rx {{device}}", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_network_transmit_bytes_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])*8", + "format": "time_series", + "legendFormat": "Tx {{device}}", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Network Traffic Basic", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Percentage of filesystem space used for each mounted filesystem", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 40, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "max": 100, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 13 + }, + "id": 152, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "((node_filesystem_size_bytes{instance=\"$node\", job=\"$job\", fstype!~'rootfs'} - node_filesystem_avail_bytes{instance=\"$node\", job=\"$job\", fstype!~'rootfs'}) / node_filesystem_size_bytes{instance=\"$node\", job=\"$job\", fstype!~'rootfs'}) * 100", + "format": "time_series", + "legendFormat": "{{mountpoint}}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Disk Space Used Basic", + "type": "timeseries" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 20 + }, + "id": 265, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "CPU time usage split by state, normalized across all CPU cores", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 70, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "percent" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "percentunit" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Idle - Waiting for something to happen" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#052B51", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Iowait - Waiting for I/O to complete" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#890F02", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Irq - Servicing interrupts" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#BF1B00", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Nice - Niced processes executing in user mode" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#6D1F62", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Softirq - Servicing softirqs" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#A06D99", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Steal - Time spent in other operating systems when running in a virtualized environment" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#CCB1C8", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "System - Processes executing in kernel mode" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#EAB839", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "User - Normal processes executing in user mode" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#0A437C", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Guest - Running virtual CPUs, included in User/Nice" + }, + "properties": [ + { + "id": "custom.fillOpacity", + "value": 0 + }, + { + "id": "custom.lineStyle", + "value": { + "dash": [ + 10, + 10 + ], + "fill": "dash" + } + }, + { + "id": "custom.stacking", + "value": { + "group": "A", + "mode": "none" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 21 + }, + "id": 3, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 250 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "sum(rate(node_cpu_seconds_total{mode=\"system\",instance=\"$node\",job=\"$job\"}[$__rate_interval])) / scalar(count(count(node_cpu_seconds_total{instance=\"$node\",job=\"$job\"}) by (cpu)))", + "format": "time_series", + "interval": "", + "legendFormat": "System - Processes executing in kernel mode", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "sum(rate(node_cpu_seconds_total{mode=\"user\",instance=\"$node\",job=\"$job\"}[$__rate_interval])) / scalar(count(count(node_cpu_seconds_total{instance=\"$node\",job=\"$job\"}) by (cpu)))", + "format": "time_series", + "legendFormat": "User - Normal processes executing in user mode", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "sum(rate(node_cpu_seconds_total{mode=\"nice\",instance=\"$node\",job=\"$job\"}[$__rate_interval])) / scalar(count(count(node_cpu_seconds_total{instance=\"$node\",job=\"$job\"}) by (cpu)))", + "format": "time_series", + "legendFormat": "Nice - Niced processes executing in user mode", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "sum(rate(node_cpu_seconds_total{mode=\"iowait\",instance=\"$node\",job=\"$job\"}[$__rate_interval])) / scalar(count(count(node_cpu_seconds_total{instance=\"$node\",job=\"$job\"}) by (cpu)))", + "format": "time_series", + "legendFormat": "Iowait - Waiting for I/O to complete", + "range": true, + "refId": "D", + "step": 240 + }, + { + "editorMode": "code", + "expr": "sum(rate(node_cpu_seconds_total{mode=\"irq\",instance=\"$node\",job=\"$job\"}[$__rate_interval])) / scalar(count(count(node_cpu_seconds_total{instance=\"$node\",job=\"$job\"}) by (cpu)))", + "format": "time_series", + "legendFormat": "Irq - Servicing interrupts", + "range": true, + "refId": "E", + "step": 240 + }, + { + "editorMode": "code", + "expr": "sum(rate(node_cpu_seconds_total{mode=\"softirq\",instance=\"$node\",job=\"$job\"}[$__rate_interval])) / scalar(count(count(node_cpu_seconds_total{instance=\"$node\",job=\"$job\"}) by (cpu)))", + "format": "time_series", + "legendFormat": "Softirq - Servicing softirqs", + "range": true, + "refId": "F", + "step": 240 + }, + { + "editorMode": "code", + "expr": "sum(rate(node_cpu_seconds_total{mode=\"steal\",instance=\"$node\",job=\"$job\"}[$__rate_interval])) / scalar(count(count(node_cpu_seconds_total{instance=\"$node\",job=\"$job\"}) by (cpu)))", + "format": "time_series", + "legendFormat": "Steal - Time spent in other operating systems when running in a virtualized environment", + "range": true, + "refId": "G", + "step": 240 + }, + { + "editorMode": "code", + "expr": "sum(rate(node_cpu_seconds_total{mode=\"idle\",instance=\"$node\",job=\"$job\"}[$__rate_interval])) / scalar(count(count(node_cpu_seconds_total{instance=\"$node\",job=\"$job\"}) by (cpu)))", + "format": "time_series", + "legendFormat": "Idle - Waiting for something to happen", + "range": true, + "refId": "H", + "step": 240 + }, + { + "editorMode": "code", + "expr": "sum by(instance) (rate(node_cpu_guest_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])) / on(instance) group_left sum by (instance)((rate(node_cpu_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval]))) > 0", + "format": "time_series", + "legendFormat": "Guest - Running virtual CPUs, included in User/Nice", + "range": true, + "refId": "I", + "step": 240 + } + ], + "title": "CPU", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Breakdown of physical memory and swap usage. Hardware-detected memory errors are also displayed", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 40, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Hardware Corrupted - Amount of RAM that the kernel identified as corrupted / not working" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#CFFAFF", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Unused - Free memory unassigned" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#7EB26D", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Apps - Memory used by user-space applications" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#EAB839", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "PageTables - Memory used to map between virtual and physical memory addresses" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#0A50A1", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "SwapCache - Memory that keeps track of pages that have been fetched from swap but not yet been modified" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#E24D42", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Slab - Memory used by the kernel to cache data structures for its own use (caches like inode, dentry, etc)" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#806EB7", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Cache - Parked file data (file content) cache" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#052B51", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Buffers - Block device (e.g. harddisk) cache" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#698097", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Swap - Swap space used" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#BF1B00", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/.*Hardware Corrupted - *./" + }, + "properties": [ + { + "id": "custom.stacking", + "value": { + "group": false, + "mode": "normal" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 21 + }, + "id": 24, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 350 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_memory_MemTotal_bytes{instance=\"$node\",job=\"$job\"} - node_memory_MemFree_bytes{instance=\"$node\",job=\"$job\"} - node_memory_Buffers_bytes{instance=\"$node\",job=\"$job\"} - node_memory_Cached_bytes{instance=\"$node\",job=\"$job\"} - node_memory_Slab_bytes{instance=\"$node\",job=\"$job\"} - node_memory_PageTables_bytes{instance=\"$node\",job=\"$job\"} - node_memory_SwapCached_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Apps - Memory used by user-space applications", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_PageTables_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "PageTables - Memory used to map between virtual and physical memory addresses", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_SwapCached_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "SwapCache - Memory that keeps track of pages that have been fetched from swap but not yet been modified", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_Slab_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Slab - Memory used by the kernel to cache data structures for its own use (caches like inode, dentry, etc)", + "range": true, + "refId": "D", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_Cached_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Cache - Parked file data (file content) cache", + "range": true, + "refId": "E", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_Buffers_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Buffers - Block device (e.g. harddisk) cache", + "range": true, + "refId": "F", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_MemFree_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Unused - Free memory unassigned", + "range": true, + "refId": "G", + "step": 240 + }, + { + "editorMode": "code", + "expr": "(node_memory_SwapTotal_bytes{instance=\"$node\",job=\"$job\"} - node_memory_SwapFree_bytes{instance=\"$node\",job=\"$job\"})", + "format": "time_series", + "legendFormat": "Swap - Swap space used", + "range": true, + "refId": "H", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_HardwareCorrupted_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Hardware Corrupted - Amount of RAM that the kernel identified as corrupted / not working", + "range": true, + "refId": "I", + "step": 240 + } + ], + "title": "Memory", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Incoming and outgoing network traffic per interface", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "out (-) / in (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 40, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*out.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 31 + }, + "id": 84, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_network_receive_bytes_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])*8", + "format": "time_series", + "legendFormat": "{{device}} - Rx in", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_network_transmit_bytes_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])*8", + "format": "time_series", + "legendFormat": "{{device}} - Tx out", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Network Traffic", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Network interface utilization as a percentage of its maximum capacity", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "out (-) / in (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 40, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "percentunit" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*out.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 31 + }, + "id": 338, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "(node_network_speed_bytes{instance=\"$node\",job=\"$job\"} > bool 0) * (rate(node_network_receive_bytes_total{instance=\"$node\",job=\"$job\"}[$__rate_interval]) / node_network_speed_bytes{instance=\"$node\",job=\"$job\"})", + "format": "time_series", + "legendFormat": "{{device}} - Rx in", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "(node_network_speed_bytes{instance=\"$node\",job=\"$job\"} > bool 0) * (rate(node_network_transmit_bytes_total{instance=\"$node\",job=\"$job\"}[$__rate_interval]) / node_network_speed_bytes{instance=\"$node\",job=\"$job\"})", + "format": "time_series", + "legendFormat": "{{device}} - Tx out", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Network Saturation", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Disk I/O operations per second for each device", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "write (\u2013) / read (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "iops" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*Write.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 41 + }, + "id": 229, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_disk_reads_completed_total{instance=\"$node\",job=\"$job\",device=~\"[a-z]+|nvme[0-9]+n[0-9]+|mmcblk[0-9]+\"}[$__rate_interval])", + "legendFormat": "{{device}} - Read", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_disk_writes_completed_total{instance=\"$node\",job=\"$job\",device=~\"[a-z]+|nvme[0-9]+n[0-9]+|mmcblk[0-9]+\"}[$__rate_interval])", + "legendFormat": "{{device}} - Write", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Disk IOps", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Disk I/O throughput per device", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "write (\u2013) / read (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 40, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "Bps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*Write.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 41 + }, + "id": 42, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_disk_read_bytes_total{instance=\"$node\",job=\"$job\",device=~\"[a-z]+|nvme[0-9]+n[0-9]+|mmcblk[0-9]+\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "{{device}} - Read", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_disk_written_bytes_total{instance=\"$node\",job=\"$job\",device=~\"[a-z]+|nvme[0-9]+n[0-9]+|mmcblk[0-9]+\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "{{device}} - Write", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Disk Throughput", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Amount of available disk space per mounted filesystem, excluding rootfs. Based on block availability to non-root users", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 51 + }, + "id": 43, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_filesystem_avail_bytes{instance=\"$node\",job=\"$job\",fstype!~'rootfs'}", + "format": "time_series", + "legendFormat": "{{mountpoint}}", + "metric": "", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_filesystem_free_bytes{instance=\"$node\",job=\"$job\",fstype!~'rootfs'}", + "format": "time_series", + "hide": true, + "legendFormat": "{{mountpoint}} - Free", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_filesystem_size_bytes{instance=\"$node\",job=\"$job\",fstype!~'rootfs'}", + "format": "time_series", + "hide": true, + "legendFormat": "{{mountpoint}} - Size", + "range": true, + "refId": "C", + "step": 240 + } + ], + "title": "Filesystem Space Available", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Disk usage (used = total - available) per mountpoint", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 51 + }, + "id": 156, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_filesystem_size_bytes{instance=\"$node\",job=\"$job\",fstype!~'rootfs'} - node_filesystem_avail_bytes{instance=\"$node\",job=\"$job\",fstype!~'rootfs'}", + "format": "time_series", + "legendFormat": "{{mountpoint}}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Filesystem Used", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Percentage of time the disk was actively processing I/O operations", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 40, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 61 + }, + "id": 127, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_disk_io_time_seconds_total{instance=\"$node\",job=\"$job\",device=~\"[a-z]+|nvme[0-9]+n[0-9]+|mmcblk[0-9]+\"} [$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "{{device}}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Disk I/O Utilization", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "How often tasks experience CPU, memory, or I/O delays. 'Some' indicates partial slowdown; 'Full' indicates all tasks are stalled. Based on Linux PSI metrics:\nhttps://docs.kernel.org/accounting/psi.html", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "some (-) / full (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "percentunit" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*Some.*/" + }, + "properties": [ + { + "id": "custom.fillOpacity", + "value": 0 + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/.*Some.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 61 + }, + "id": 322, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_pressure_cpu_waiting_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "CPU - Some", + "range": true, + "refId": "CPU some", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_pressure_memory_waiting_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "Memory - Some", + "range": true, + "refId": "Memory some", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_pressure_memory_stalled_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "Memory - Full", + "range": true, + "refId": "Memory full", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_pressure_io_waiting_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "I/O - Some", + "range": true, + "refId": "I/O some", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_pressure_io_stalled_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "I/O - Full", + "range": true, + "refId": "I/O full", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_pressure_irq_stalled_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "IRQ - Full", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Pressure Stall Information", + "type": "timeseries" + } + ], + "title": "CPU / Memory / Net / Disk", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 21 + }, + "id": 266, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Displays committed memory usage versus the system's commit limit. Exceeding the limit is allowed under Linux overcommit policies but may increase OOM risks under high load", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*CommitLimit - *./" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + }, + { + "id": "custom.fillOpacity", + "value": 0 + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 752 + }, + "id": 135, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 350 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_memory_Committed_AS_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Committed_AS \u2013 Memory promised to processes (not necessarily used)", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_CommitLimit_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "CommitLimit - Max allowable committed memory", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Memory Committed", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Memory currently dirty (modified but not yet written to disk), being actively written back, or held by writeback buffers. High dirty or writeback memory may indicate disk I/O pressure or delayed flushing", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 762 + }, + "id": 130, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_memory_Writeback_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Writeback \u2013 Memory currently being flushed to disk", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_WritebackTmp_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "WritebackTmp \u2013 FUSE temporary writeback buffers", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_Dirty_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Dirty \u2013 Memory marked dirty (pending write to disk)", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_NFS_Unstable_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "NFS Unstable \u2013 Pages sent to NFS server, awaiting storage commit", + "range": true, + "refId": "D", + "step": 240 + } + ], + "title": "Memory Writeback and Dirty", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Memory used by anonymous pages (not backed by files), including standard and huge page allocations. Includes heap, stack, and memory-mapped anonymous regions", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 732 + }, + "id": 129, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_memory_AnonHugePages_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "AnonHugePages \u2013 Anonymous memory using HugePages", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_AnonPages_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "AnonPages \u2013 Anonymous memory (non-file-backed)", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Memory Anonymous", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Memory used for mapped files (such as libraries) and shared memory (shmem and tmpfs), including variants backed by huge pages", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 732 + }, + "id": 138, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 350 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_memory_Mapped_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Mapped \u2013 Memory mapped from files (e.g., libraries, mmap)", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_Shmem_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Shmem \u2013 Shared memory used by processes and tmpfs", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_ShmemHugePages_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "ShmemHugePages \u2013 Shared memory (shmem/tmpfs) allocated with HugePages", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_ShmemPmdMapped_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "PMD Mapped \u2013 Shmem/tmpfs backed by Transparent HugePages (PMD)", + "range": true, + "refId": "D", + "step": 240 + } + ], + "title": "Memory Shared and Mapped", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Proportion of memory pages in the kernel's active and inactive LRU lists relative to total RAM. Active pages have been recently used, while inactive pages are less recently accessed but still resident in memory", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "percentunit" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*Active.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "green", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/.*Inactive.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-blue", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 772 + }, + "id": 136, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 350 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "(node_memory_Inactive_bytes{instance=\"$node\",job=\"$job\"}) \n/ \n(node_memory_MemTotal_bytes{instance=\"$node\",job=\"$job\"})", + "format": "time_series", + "legendFormat": "Inactive \u2013 Less recently used memory, more likely to be reclaimed", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "(node_memory_Active_bytes{instance=\"$node\",job=\"$job\"}) \n/ \n(node_memory_MemTotal_bytes{instance=\"$node\",job=\"$job\"})\n", + "format": "time_series", + "legendFormat": "Active \u2013 Recently used memory, retained unless under pressure", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Memory LRU Active / Inactive (%)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Breakdown of memory pages in the kernel's active and inactive LRU lists, separated by anonymous (heap, tmpfs) and file-backed (caches, mmap) pages.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 772 + }, + "id": 191, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 350 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_memory_Inactive_file_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Inactive_file - File-backed memory on inactive LRU list", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_Inactive_anon_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Inactive_anon \u2013 Anonymous memory on inactive LRU (incl. tmpfs & swap cache)", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_Active_file_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Active_file - File-backed memory on active LRU list", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_Active_anon_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Active_anon \u2013 Anonymous memory on active LRU (incl. tmpfs & swap cache)", + "range": true, + "refId": "D", + "step": 240 + } + ], + "title": "Memory LRU Active / Inactive Detail", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Kernel slab memory usage, separated into reclaimable and non-reclaimable categories. Reclaimable memory can be freed under memory pressure (e.g., caches), while unreclaimable memory is locked by the kernel for core functions", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 792 + }, + "id": 131, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_memory_SUnreclaim_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "SUnreclaim \u2013 Non-reclaimable slab memory (kernel objects)", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_SReclaimable_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "SReclaimable \u2013 Potentially reclaimable slab memory (e.g., inode cache)", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Memory Slab", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Usage of the kernel's vmalloc area, which provides virtual memory allocations for kernel modules and drivers. Includes total, used, and largest free block sizes", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*Total.*/" + }, + "properties": [ + { + "id": "custom.fillOpacity", + "value": 0 + }, + { + "id": "custom.lineStyle", + "value": { + "dash": [ + 10, + 10 + ], + "fill": "dash" + } + }, + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 792 + }, + "id": 70, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_memory_VmallocChunk_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Vmalloc Free Chunk \u2013 Largest available block in vmalloc area", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_VmallocTotal_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Vmalloc Total \u2013 Total size of the vmalloc memory area", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_VmallocUsed_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Vmalloc Used \u2013 Portion of vmalloc area currently in use", + "range": true, + "refId": "C", + "step": 240 + } + ], + "title": "Memory Vmalloc", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Tracks kernel memory used for CPU-local structures and per-thread stacks. These areas are typically small but critical for low-level operations", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 802 + }, + "id": 160, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 350 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_memory_KernelStack_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "KernelStack \u2013 Kernel stack memory (per-thread, non-reclaimable)", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_Percpu_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "PerCPU \u2013 Dynamically allocated per-CPU memory (used by kernel modules)", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Memory Kernel / CPU", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "How much memory is directly mapped in the kernel using different page sizes (4K, 2M, 1G). Helps monitor large page utilization in the direct map region", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 802 + }, + "id": 128, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_memory_DirectMap1G_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "DirectMap 1G \u2013 Memory mapped with 1GB pages", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_DirectMap2M_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "DirectMap 2M \u2013 Memory mapped with 2MB pages", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_DirectMap4k_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "DirectMap 4K \u2013 Memory mapped with 4KB pages", + "range": true, + "refId": "C", + "step": 240 + } + ], + "title": "Memory DirectMap", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Memory that is locked in RAM and cannot be swapped out. Includes both kernel-unevictable memory and user-level memory locked with mlock()", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 742 + }, + "id": 137, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 350 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_memory_Unevictable_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Unevictable \u2013 Kernel-pinned memory (not swappable)", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_Mlocked_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Mlocked \u2013 Application-locked memory via mlock()", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Memory Unevictable and MLocked", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Displays HugePages memory usage in bytes, including allocated, free, reserved, and surplus memory. All values are calculated based on the number of huge pages multiplied by their configured size", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 742 + }, + "id": 140, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "(node_memory_HugePages_Total{instance=\"$node\",job=\"$job\"} - node_memory_HugePages_Free{instance=\"$node\",job=\"$job\"}) * node_memory_Hugepagesize_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "HugePages Used \u2013 Currently allocated", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_HugePages_Rsvd{instance=\"$node\",job=\"$job\"} * node_memory_Hugepagesize_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "HugePages Reserved \u2013 Promised but unused", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_HugePages_Surp{instance=\"$node\",job=\"$job\"} * node_memory_Hugepagesize_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "HugePages Surplus \u2013 Dynamic pool extension", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_HugePages_Total{instance=\"$node\",job=\"$job\"} * node_memory_Hugepagesize_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "HugePages Total \u2013 Preallocated pool size", + "range": true, + "refId": "D", + "step": 240 + } + ], + "title": "Memory HugePages", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Zswap is a compressed RAM cache for swap pages. Zswap stores compressed pages that would otherwise be written to swap, reducing disk I/O. Zswapped shows the amount of data stored in the Zswap pool before compression", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 762 + }, + "id": 342, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_memory_Zswap_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Zswap \u2013 Compressed pool size in RAM", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_memory_Zswapped_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Zswapped \u2013 Original data size before compression", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Memory Zswap", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of data read from and written to block devices. Despite the historical name, it covers all block I/O, not only memory paging", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "out (-) / in (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "Bps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*out.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 0, + "y": 782 + }, + "id": 176, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_vmstat_pgpgin{instance=\"$node\",job=\"$job\"}[$__rate_interval]) * 1024", + "format": "time_series", + "legendFormat": "Pagesin - Data paged in", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_vmstat_pgpgout{instance=\"$node\",job=\"$job\"}[$__rate_interval]) * 1024", + "format": "time_series", + "legendFormat": "Pagesout - Data paged out", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Memory Pages In / Out", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate at which memory pages are being swapped in from or out to disk. High swap-out activity may indicate memory pressure", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "out (-) / in (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "ops" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*out.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 8, + "y": 782 + }, + "id": 22, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_vmstat_pswpin{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "Pswpin - Pages swapped in", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_vmstat_pswpout{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "Pswpout - Pages swapped out", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Memory Pages Swap In / Out", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of memory page faults, split into total, major (disk-backed), and derived minor (non-disk) faults. High major fault rates may indicate memory pressure or insufficient RAM", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "ops" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Pgfault - Page major and minor fault ops" + }, + "properties": [ + { + "id": "custom.fillOpacity", + "value": 0 + }, + { + "id": "custom.stacking", + "value": { + "group": false, + "mode": "none" + } + }, + { + "id": "custom.lineStyle", + "value": { + "dash": [ + 10, + 10 + ], + "fill": "dash" + } + }, + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 16, + "y": 782 + }, + "id": 175, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 350 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_vmstat_pgfault{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "Pgfault - Page major and minor fault ops", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_vmstat_pgmajfault{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "Pgmajfault - Major page fault ops", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_vmstat_pgfault{instance=\"$node\",job=\"$job\"}[$__rate_interval]) - rate(node_vmstat_pgmajfault{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "Pgminfault - Minor page fault ops", + "range": true, + "refId": "C", + "step": 240 + } + ], + "title": "Memory Page Faults", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of Out-of-Memory (OOM) kill events. A non-zero value indicates the kernel has terminated one or more processes due to memory exhaustion", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "ops" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "OOM Kills" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 752 + }, + "id": 307, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_vmstat_oom_kill{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "OOM Kills", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "OOM Killer", + "type": "timeseries" + } + ], + "title": "Memory Details", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 23 + }, + "id": 312, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "System load average over 1, 5, and 15 minutes. Reflects the number of active or waiting processes. Values above CPU core count may indicate overload", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "CPU Core Count" + }, + "properties": [ + { + "id": "custom.fillOpacity", + "value": 0 + }, + { + "id": "custom.lineStyle", + "value": { + "dash": [ + 10, + 10 + ], + "fill": "dash" + } + }, + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 735 + }, + "id": 7, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_load1{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Load 1m", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_load5{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Load 5m", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_load15{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Load 15m", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "count(count(node_cpu_seconds_total{instance=\"$node\",job=\"$job\"}) by (cpu))", + "format": "time_series", + "legendFormat": "CPU Core Count", + "range": true, + "refId": "D", + "step": 240 + } + ], + "title": "System Load", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Running and blocked processes, plus kernel hung tasks detected (processes stuck in uninterruptible D state beyond the kernel timeout threshold)", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 745 + }, + "id": 62, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_procs_blocked{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Blocked (I/O Wait)", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_procs_running{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Runnable (Ready for CPU)", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "increase(node_kernel_hung_tasks_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "Hung Tasks Detected (D state > timeout)", + "range": true, + "refId": "C", + "step": 240 + } + ], + "title": "Processes Status", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Current number of processes in each state (e.g., running, sleeping, zombie). Requires --collector.processes to be enabled in node_exporter", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "D" + }, + "properties": [ + { + "id": "displayName", + "value": "Uninterruptible Sleeping" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "I" + }, + "properties": [ + { + "id": "displayName", + "value": "Idle Kernel Thread" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "R" + }, + "properties": [ + { + "id": "displayName", + "value": "Running" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "S" + }, + "properties": [ + { + "id": "displayName", + "value": "Interruptible Sleeping" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "T" + }, + "properties": [ + { + "id": "displayName", + "value": "Stopped" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "X" + }, + "properties": [ + { + "id": "displayName", + "value": "Dead" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Z" + }, + "properties": [ + { + "id": "displayName", + "value": "Zombie" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 745 + }, + "id": 315, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_processes_state{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "{{ state }}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Processes Detailed States", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of new processes being created on the system (forks/sec).", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 735 + }, + "id": 148, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_forks_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "Process Forks per second", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Processes Forks", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of active PIDs on the system and the configured maximum allowed. Useful for detecting PID exhaustion risk. Requires --collector.processes in node_exporter", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "PIDs limit" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + }, + { + "id": "custom.fillOpacity", + "value": 0 + }, + { + "id": "custom.lineStyle", + "value": { + "dash": [ + 10, + 10 + ], + "fill": "dash" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 0, + "y": 755 + }, + "id": 313, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_processes_pids{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "Number of PIDs", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_processes_max_processes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "PIDs limit", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "PIDs Number and Limit", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of active threads on the system and the configured thread limit. Useful for monitoring thread pressure. Requires --collector.processes in node_exporter", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Threads limit" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + }, + { + "id": "custom.fillOpacity", + "value": 0 + }, + { + "id": "custom.lineStyle", + "value": { + "dash": [ + 10, + 10 + ], + "fill": "dash" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 8, + "y": 755 + }, + "id": 314, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_processes_threads{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "Allocated threads", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_processes_max_threads{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "Threads limit", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Threads Number and Limit", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of file descriptors currently allocated system-wide versus the system limit. Important for detecting descriptor exhaustion risks", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*Max.*/" + }, + "properties": [ + { + "id": "custom.fillOpacity", + "value": 0 + }, + { + "id": "custom.lineStyle", + "value": { + "dash": [ + 10, + 10 + ], + "fill": "dash" + } + }, + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 16, + "y": 755 + }, + "id": 28, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_filefd_maximum{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Max open files", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_filefd_allocated{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Open files", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "File Descriptor", + "type": "timeseries" + } + ], + "title": "Processes", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 24 + }, + "id": 269, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Per-second rate of context switches and hardware interrupts. High values may indicate intense CPU or I/O activity", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 816 + }, + "id": 8, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_context_switches_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "Context switches", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_intr_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "Interrupts", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Context Switches / Interrupts", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Shows CPU saturation per core, calculated as the proportion of time spent waiting to run relative to total time demanded (running + waiting).", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "CPU saturation (%)", + "axisPlacement": "left", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 0.8 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 826 + }, + "id": 305, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_schedstat_running_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "hide": true, + "interval": "", + "legendFormat": "CPU {{ cpu }} - Running", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_schedstat_waiting_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "hide": true, + "interval": "", + "legendFormat": "CPU {{cpu}} - Waiting Queue", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_schedstat_waiting_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval]) / ((rate(node_schedstat_running_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval]) + rate(node_schedstat_waiting_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])) > 0)", + "format": "time_series", + "interval": "", + "legendFormat": "CPU {{cpu}}", + "range": true, + "refId": "C", + "step": 240 + } + ], + "title": "CPU Saturation per Core", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Real-time CPU frequency scaling per core, including average minimum and maximum allowed scaling frequencies", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "hertz" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Max" + }, + "properties": [ + { + "id": "custom.lineStyle", + "value": { + "dash": [ + 10, + 10 + ], + "fill": "dash" + } + }, + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + }, + { + "id": "custom.hideFrom", + "value": { + "legend": true, + "tooltip": false, + "viz": false + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Min" + }, + "properties": [ + { + "id": "custom.lineStyle", + "value": { + "dash": [ + 10, + 10 + ], + "fill": "dash" + } + }, + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + }, + { + "id": "custom.hideFrom", + "value": { + "legend": true, + "tooltip": false, + "viz": false + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 836 + }, + "id": 321, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_cpu_scaling_frequency_hertz{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "CPU {{ cpu }}", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "avg(node_cpu_scaling_frequency_max_hertz{instance=\"$node\",job=\"$job\"})", + "format": "time_series", + "interval": "", + "legendFormat": "Max", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "avg(node_cpu_scaling_frequency_min_hertz{instance=\"$node\",job=\"$job\"})", + "format": "time_series", + "interval": "", + "legendFormat": "Min", + "range": true, + "refId": "C", + "step": 240 + } + ], + "title": "CPU Frequency Scaling", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of scheduling timeslices executed per CPU. Reflects how frequently the scheduler switches tasks on each core", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 826 + }, + "id": 306, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_schedstat_timeslices_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "CPU {{ cpu }}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "CPU Schedule Timeslices", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Breaks down hardware interrupts by type and device. Useful for diagnosing IRQ load on network, disk, or CPU interfaces. Requires --collector.interrupts to be enabled in node_exporter", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 816 + }, + "id": 259, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "sum without (cpu) (rate(node_interrupts_total{instance=\"$node\",job=\"$job\"}[$__rate_interval]))", + "format": "time_series", + "interval": "", + "legendFormat": "{{ type }} - {{ info }}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "IRQ Detail", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of bits of entropy currently available to the system's random number generators (e.g., /dev/random). Low values may indicate that random number generation could block or degrade performance of cryptographic operations", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "decbits" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Entropy pool max" + }, + "properties": [ + { + "id": "custom.fillOpacity", + "value": 0 + }, + { + "id": "custom.lineStyle", + "value": { + "dash": [ + 10, + 10 + ], + "fill": "dash" + } + }, + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 836 + }, + "id": 151, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_entropy_available_bits{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Entropy available", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_entropy_pool_size_bits{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "Entropy pool max", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Entropy", + "type": "timeseries" + } + ], + "title": "CPU & Scheduler", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 25 + }, + "id": 304, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Monitors hardware sensor temperatures and critical thresholds as exposed by Linux hwmon. Includes CPU, GPU, and motherboard sensors where available", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "celsius" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*Critical.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + }, + { + "id": "custom.fillOpacity", + "value": 0 + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 737 + }, + "id": 158, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_hwmon_temp_celsius{instance=\"$node\",job=\"$job\"} * on(chip) group_left(chip_name) node_hwmon_chip_names{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "{{ chip_name }} {{ sensor }}", + "range": true, + "refId": "A", + "step": 240 + }, + { + "expr": "node_hwmon_temp_crit_alarm_celsius{instance=\"$node\",job=\"$job\"} * on(chip) group_left(chip_name) node_hwmon_chip_names{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "hide": true, + "interval": "", + "legendFormat": "{{ chip_name }} {{ sensor }} Critical Alarm", + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_hwmon_temp_crit_celsius{instance=\"$node\",job=\"$job\"} * on(chip) group_left(chip_name) node_hwmon_chip_names{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "{{ chip_name }} {{ sensor }} Critical", + "range": true, + "refId": "C", + "step": 240 + }, + { + "expr": "node_hwmon_temp_crit_hyst_celsius{instance=\"$node\",job=\"$job\"} * on(chip) group_left(chip_name) node_hwmon_chip_names{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "hide": true, + "interval": "", + "legendFormat": "{{ chip_name }} {{ sensor }} Critical Hysteresis", + "refId": "D", + "step": 240 + }, + { + "expr": "node_hwmon_temp_max_celsius{instance=\"$node\",job=\"$job\"} * on(chip) group_left(chip_name) node_hwmon_chip_names{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "hide": true, + "interval": "", + "legendFormat": "{{ chip_name }} {{ sensor }} Max", + "refId": "E", + "step": 240 + } + ], + "title": "Hardware Temperature Monitor", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Shows how hard each cooling device (fan/throttle) is working relative to its maximum capacity", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "percent" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*Max.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + }, + { + "id": "custom.fillOpacity", + "value": 0 + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 747 + }, + "id": 300, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "100 * node_cooling_device_cur_state{instance=\"$node\",job=\"$job\"} / (node_cooling_device_max_state{instance=\"$node\",job=\"$job\"} > 0)", + "format": "time_series", + "interval": "", + "legendFormat": "{{name}} - {{type}}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Cooling Device Utilization", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Displays the current fan speeds (RPM) from hardware sensors via the hwmon interface", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "rotrpm" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 737 + }, + "id": 325, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_hwmon_fan_rpm{instance=\"$node\",job=\"$job\"} * on(chip) group_left(chip_name) node_hwmon_chip_names{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "{{ chip_name }} {{ sensor }}", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_hwmon_fan_min_rpm{instance=\"$node\",job=\"$job\"} * on(chip) group_left(chip_name) node_hwmon_chip_names{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "hide": true, + "interval": "", + "legendFormat": "{{ chip_name }} {{ sensor }} rpm min", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Hardware Fan Speed", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Core-level CPU thermal throttling events per package. Values above zero indicate cores were throttled during the interval. Requires hardware that exposes thermal_throttle counters (mostly Intel); absent on AMD and most virtual machines.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "throttle events", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "decimals": 0, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 747 + }, + "id": 344, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": true, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "sum by (package) (increase(node_cpu_core_throttles_total{instance=\"$node\",job=\"$job\"}[$__rate_interval]))", + "format": "time_series", + "legendFormat": "Package {{package}}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "CPU Throttling", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Tracks the system clock's estimated and maximum error, as well as its offset from the reference clock (e.g., via NTP). Useful for detecting synchronization drift", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 0, + "y": 767 + }, + "id": 260, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_timex_estimated_error_seconds{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "Estimated error", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_timex_offset_seconds{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "Offset local vs reference", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_timex_maxerror_seconds{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "Maximum error", + "range": true, + "refId": "C", + "step": 240 + } + ], + "title": "Time Synchronized Drift", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "NTP phase-locked loop (PLL) time constant used by the kernel to control time adjustments. Lower values mean faster correction but less stability", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 8, + "y": 767 + }, + "id": 291, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_timex_loop_time_constant{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "PLL Time Constant", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Time PLL Adjust", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Shows whether the system clock is synchronized to a reliable time source, and the current frequency correction ratio applied by the kernel to maintain synchronization", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 16, + "y": 767 + }, + "id": 168, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_timex_sync_status{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "Sync status (1 = ok)", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_timex_frequency_adjustment_ratio{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "Frequency Adjustment", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_timex_tick_seconds{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "hide": true, + "interval": "", + "legendFormat": "Tick Interval", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_timex_tai_offset_seconds{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "hide": true, + "interval": "", + "legendFormat": "TAI Offset", + "range": true, + "refId": "D", + "step": 240 + } + ], + "title": "Time Synchronized Status", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Correctable and uncorrectable ECC memory errors reported by EDAC. Correctable errors indicate a degrading DIMM; uncorrectable errors can cause data corruption. Only available on bare metal hosts that expose EDAC.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/ - Correctable$/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/ - Uncorrectable$/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + }, + { + "id": "custom.fillOpacity", + "value": 30 + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 757 + }, + "id": 302, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "increase(node_edac_correctable_errors_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "{{controller}} - Correctable", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "increase(node_edac_uncorrectable_errors_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "{{controller}} - Uncorrectable", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "ECC Memory Errors", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Online and present state of each power supply exposed by /sys/class/power_supply. 1 = OK, 0 = failed or missing. Only available on hardware that exposes node_power_supply_online or node_power_supply_present; absent on most virtual machines.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "state (1 = OK)", + "axisPlacement": "left", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "decimals": 0, + "links": [], + "mappings": [ + { + "options": { + "0": { + "color": "red", + "index": 1, + "text": "DOWN" + }, + "1": { + "color": "green", + "index": 0, + "text": "OK" + } + }, + "type": "value" + } + ], + "max": 1, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red" + }, + { + "color": "green", + "value": 0.5 + } + ] + }, + "unit": "bool_yes_no" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 757 + }, + "id": 345, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_power_supply_online{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "{{power_supply}} online", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_power_supply_present{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "{{power_supply}} present", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Power Supply Status", + "type": "timeseries" + } + ], + "title": "Hardware & Time", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 26 + }, + "id": 296, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Current number of systemd units in each operational state, such as active, failed, inactive, or transitioning", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Failed" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#F2495C", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Active" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#73BF69", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Activating" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#C8F2C2", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Deactivating" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Inactive" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-blue", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 4228 + }, + "id": 298, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_systemd_units{instance=\"$node\",job=\"$job\",state=\"activating\"}", + "format": "time_series", + "interval": "", + "legendFormat": "Activating", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_systemd_units{instance=\"$node\",job=\"$job\",state=\"active\"}", + "format": "time_series", + "interval": "", + "legendFormat": "Active", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_systemd_units{instance=\"$node\",job=\"$job\",state=\"deactivating\"}", + "format": "time_series", + "interval": "", + "legendFormat": "Deactivating", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_systemd_units{instance=\"$node\",job=\"$job\",state=\"failed\"}", + "format": "time_series", + "interval": "", + "legendFormat": "Failed", + "range": true, + "refId": "D", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_systemd_units{instance=\"$node\",job=\"$job\",state=\"inactive\"}", + "format": "time_series", + "interval": "", + "legendFormat": "Inactive", + "range": true, + "refId": "E", + "step": 240 + } + ], + "title": "Systemd Units State", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Current number of active connections per systemd socket, as reported by the Node Exporter systemd collector", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 4228 + }, + "id": 331, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_systemd_socket_current_connections{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "{{ name }}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Systemd Sockets Current", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of accepted connections per second for each systemd socket", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "eps" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 4238 + }, + "id": 297, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_systemd_socket_accepted_connections_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "{{ name }}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Systemd Sockets Accepted", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of systemd socket connection refusals per second, typically due to service unavailability or backlog overflow", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "eps" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 4238 + }, + "id": 332, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_systemd_socket_refused_connections_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "{{ name }}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Systemd Sockets Refused", + "type": "timeseries" + } + ], + "title": "Systemd", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 27 + }, + "id": 270, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of I/O operations completed per second for the device (after merges), including both reads and writes", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "write (\u2013) / read (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "iops" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*Write.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/sda.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 29 + }, + "id": 9, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_disk_reads_completed_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "legendFormat": "{{device}} - Read", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_disk_writes_completed_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "legendFormat": "{{device}} - Write", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Disk Read/Write IOps", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of bytes read from or written to the device per second", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "write (\u2013) / read (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "Bps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*Write.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/sda.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 29 + }, + "id": 33, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_disk_read_bytes_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "{{device}} - Read", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "exemplar": false, + "expr": "rate(node_disk_written_bytes_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "instant": false, + "legendFormat": "{{device}} - Write", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Disk Read/Write Data", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Average time for requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "write (\u2013) / read (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "s" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*Write.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/sda.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 39 + }, + "id": 37, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_disk_read_time_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval]) / (rate(node_disk_reads_completed_total{instance=\"$node\",job=\"$job\"}[$__rate_interval]) > 0)", + "interval": "", + "legendFormat": "{{device}} - Read", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_disk_write_time_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval]) / (rate(node_disk_writes_completed_total{instance=\"$node\",job=\"$job\"}[$__rate_interval]) > 0)", + "interval": "", + "legendFormat": "{{device}} - Write", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Disk Average Wait Time", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Percentage of time the disk spent actively processing I/O operations, including general I/O, discards (TRIM), and write cache flushes", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "percentunit" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/sda.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 39 + }, + "id": 36, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_disk_io_time_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "interval": "", + "legendFormat": "{{device}} - General IO", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_disk_discard_time_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "interval": "", + "legendFormat": "{{device}} - Discard/TRIM", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_disk_flush_requests_time_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "interval": "", + "legendFormat": "{{device}} - Flush (write cache)", + "range": true, + "refId": "C", + "step": 240 + } + ], + "title": "Time Spent Doing I/Os", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Average queue length of the requests that were issued to the device", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/sda.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 49 + }, + "id": 35, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_disk_io_time_weighted_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "interval": "", + "legendFormat": "{{device}}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Average Queue Size", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of in-progress I/O requests at the time of sampling (active requests in the disk queue)", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/sda.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 49 + }, + "id": 34, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_disk_io_now{instance=\"$node\",job=\"$job\"}", + "interval": "", + "legendFormat": "{{device}}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Instantaneous Queue Size", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of read and write requests merged per second that were queued to the device", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "write (\u2013) / read (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "iops" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*Write.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/sda.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 0, + "y": 59 + }, + "id": 133, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_disk_reads_merged_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "legendFormat": "{{device}} - Read", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_disk_writes_merged_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "legendFormat": "{{device}} - Write", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Disk R/W Merged", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Per-second rate of discard (TRIM) and flush (write cache) operations. Useful for monitoring low-level disk activity on SSDs and advanced storage", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "ops" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/sda.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 8, + "y": 59 + }, + "id": 301, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_disk_discards_completed_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "interval": "", + "legendFormat": "{{device}} - Discards completed", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_disk_discards_merged_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "interval": "", + "legendFormat": "{{device}} - Discards merged", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_disk_flush_requests_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "interval": "", + "legendFormat": "{{device}} - Flush", + "range": true, + "refId": "C", + "step": 240 + } + ], + "title": "Disk Ops Discards / Flush", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Shows how many disk sectors are discarded (TRIMed) per second. Useful for monitoring SSD behavior and storage efficiency", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/sda.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 16, + "y": 59 + }, + "id": 326, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_disk_discarded_sectors_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "interval": "", + "legendFormat": "{{device}}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Disk Sectors Discarded Successfully", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of free file nodes (inodes) available per mounted filesystem. A low count may prevent file creation even if disk space is available", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 0, + "y": 69 + }, + "id": 41, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_filesystem_files_free{instance=\"$node\",job=\"$job\",fstype!~'rootfs'}", + "format": "time_series", + "legendFormat": "{{mountpoint}}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "File Nodes Free", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Indicates filesystems mounted in read-only mode or reporting device-level I/O errors.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bool_yes_no" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 16, + "y": 69 + }, + "id": 44, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_filesystem_readonly{instance=\"$node\",job=\"$job\",fstype!~'rootfs'}", + "format": "time_series", + "legendFormat": "{{mountpoint}} - ReadOnly", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_filesystem_device_error{instance=\"$node\",job=\"$job\",fstype!~'rootfs|tmpfs'}", + "format": "time_series", + "interval": "", + "legendFormat": "{{mountpoint}} - Device error", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Filesystem in ReadOnly / Error", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of file nodes (inodes) available per mounted filesystem. Reflects maximum file capacity regardless of disk size", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 8, + "y": 69 + }, + "id": 219, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_filesystem_files{instance=\"$node\",job=\"$job\",fstype!~'rootfs'}", + "format": "time_series", + "legendFormat": "{{mountpoint}}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "File Nodes Size", + "type": "timeseries" + } + ], + "title": "Storage", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 28 + }, + "id": 272, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of network packets received and transmitted per second, by interface.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "out (-) / in (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "pps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*out.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 31 + }, + "id": 60, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_network_receive_packets_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "{{device}} - Rx in", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_network_transmit_packets_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "{{device}} - Tx out", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Network Traffic by Packets", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of packet-level errors for each network interface. Receive errors may indicate physical or driver issues; transmit errors may reflect collisions or hardware faults", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "out (-) / in (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "pps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*out.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 31 + }, + "id": 142, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_network_receive_errs_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "{{device}} - Rx in", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_network_transmit_errs_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "{{device}} - Tx out", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Network Traffic Errors", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of dropped packets per network interface. Receive drops can indicate buffer overflow or driver issues; transmit drops may result from outbound congestion or queuing limits", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "out (-) / in (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "pps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*out.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 41 + }, + "id": 143, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_network_receive_drop_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "{{device}} - Rx in", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_network_transmit_drop_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "{{device}} - Tx out", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Network Traffic Drop", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of received packets that could not be processed due to missing protocol or handler in the kernel. May indicate unsupported traffic or misconfiguration", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "pps" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 41 + }, + "id": 327, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_network_receive_nohandler_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "{{device}} - Rx in", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Network Traffic NoHandler", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of frame errors on received packets, typically caused by physical layer issues such as bad cables, duplex mismatches, or hardware problems", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "pps" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 51 + }, + "id": 145, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_network_receive_frame_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "{{device}} - Rx in", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Network Traffic Frame", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Tracks FIFO buffer overrun errors on network interfaces. These occur when incoming or outgoing packets are dropped due to queue or buffer overflows, often indicating congestion or hardware limits", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "out (-) / in (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "pps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*out.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 51 + }, + "id": 144, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_network_receive_fifo_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "{{device}} - Rx in", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_network_transmit_fifo_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "{{device}} - Tx out", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Network Traffic Fifo", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of packet collisions detected during transmission. Mostly relevant on half-duplex or legacy Ethernet networks", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "pps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*out.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 61 + }, + "id": 232, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_network_transmit_colls_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "{{device}} - Tx out", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Network Traffic Collision", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of carrier errors during transmission. These typically indicate physical layer issues like faulty cabling or duplex mismatches", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "pps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*out.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 61 + }, + "id": 231, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_network_transmit_carrier_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "{{device}} - Tx out", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Network Traffic Carrier Errors", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of compressed network packets received and transmitted per interface. These are common in low-bandwidth or special interfaces like PPP or SLIP", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "out (-) / in (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "pps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*out.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 71 + }, + "id": 141, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_network_receive_compressed_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "{{device}} - Rx in", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_network_transmit_compressed_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "{{device}} - Tx out", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Network Traffic Compressed", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of incoming multicast packets received per network interface. Multicast is used by protocols such as mDNS, SSDP, and some streaming or cluster services", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "pps" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 71 + }, + "id": 146, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_network_receive_multicast_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "{{device}} - Rx in", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Network Traffic Multicast", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of ARP entries per interface. Useful for detecting excessive ARP traffic or table growth due to scanning or misconfiguration", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 81 + }, + "id": 230, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_arp_entries{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "{{ device }} ARP Table", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "ARP Entries", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Current and maximum connection tracking entries used by Netfilter (nf_conntrack). High usage approaching the limit may cause packet drops or connection issues", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "NF conntrack limit" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + }, + { + "id": "custom.fillOpacity", + "value": 0 + }, + { + "id": "custom.lineStyle", + "value": { + "dash": [ + 10, + 10 + ], + "fill": "dash" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 81 + }, + "id": 61, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_nf_conntrack_entries{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "NF conntrack entries", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_nf_conntrack_entries_limit{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "NF conntrack limit", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "NF Conntrack", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of link-down transitions (flaps) per interface. Repeated flaps usually indicate a faulty cable, SFP, or switch port. The negative series shows link-down state: 0 when the carrier is present and -1 when it is absent.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "down (-) / flaps (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "decimals": 0, + "links": [], + "mappings": [], + "min": -1, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*Down state.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "red" + } + }, + { + "id": "custom.lineWidth", + "value": 2 + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 91 + }, + "id": 343, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": true, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "increase(node_network_carrier_down_changes_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "{{device}} - Link flaps", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_network_carrier{instance=\"$node\",job=\"$job\"} - 1", + "format": "time_series", + "legendFormat": "{{device}} - Down state", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Network Link Flaps", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Maximum speed of each network interface as reported by the operating system. This is a static hardware capability, not current throughput. A value of -1 means unknown speed", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "decimals": 0, + "fieldMinMax": false, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bps" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 6, + "x": 12, + "y": 91 + }, + "id": 280, + "options": { + "displayMode": "basic", + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "maxVizHeight": 30, + "minVizHeight": 16, + "minVizWidth": 8, + "namePlacement": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showUnfilled": true, + "sizing": "manual", + "valueMode": "color" + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_network_speed_bytes{instance=\"$node\",job=\"$job\"} * 8", + "format": "time_series", + "legendFormat": "{{ device }}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Speed", + "type": "bargauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "MTU (Maximum Transmission Unit) in bytes for each network interface. Affects packet size and transmission efficiency", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "decimals": 0, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 6, + "x": 18, + "y": 91 + }, + "id": 288, + "options": { + "displayMode": "basic", + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "maxVizHeight": 30, + "minVizHeight": 16, + "minVizWidth": 8, + "namePlacement": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showUnfilled": true, + "sizing": "manual", + "valueMode": "color" + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_network_mtu_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "{{ device }}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "MTU", + "type": "bargauge" + } + ], + "title": "Network Traffic", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 29 + }, + "id": 273, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Tracks TCP socket usage per node", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 32 + }, + "id": 63, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_sockstat_TCP_alloc{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 Allocated Sockets", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_sockstat_TCP_inuse{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 In-Use Sockets", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_sockstat_TCP_orphan{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 Orphaned Sockets", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_sockstat_TCP_tw{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 TIME_WAIT Sockets", + "range": true, + "refId": "D", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_sockstat_TCP6_inuse{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "IPv6 In-Use Sockets", + "range": true, + "refId": "E", + "step": 240 + } + ], + "title": "Sockstat TCP", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of UDP and UDPLite sockets currently in use", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 32 + }, + "id": 124, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_sockstat_UDPLITE_inuse{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 UDPLite - In-Use Sockets", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_sockstat_UDP_inuse{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 UDP - In-Use Sockets", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_sockstat_UDPLITE6_inuse{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "IPv6 UDPLite - In-Use Sockets", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_sockstat_UDP6_inuse{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "IPv6 UDP - In-Use Sockets", + "range": true, + "refId": "D", + "step": 240 + } + ], + "title": "Sockstat UDP", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Total number of sockets currently in use across all protocols (TCP, UDP, UNIX, etc.), as reported by /proc/net/sockstat", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 42 + }, + "id": 126, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_sockstat_sockets_used{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "Total sockets", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Sockstat Used", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of FRAG and RAW sockets currently in use. RAW sockets are used for custom protocols or tools like ping; FRAG sockets are used internally for IP packet defragmentation", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 42 + }, + "id": 125, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_sockstat_FRAG_inuse{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 FRAG - In-Use Sockets", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_sockstat_RAW_inuse{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 RAW - In-Use Sockets", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_sockstat_FRAG6_inuse{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "IPv6 FRAG - In-Use Sockets", + "range": true, + "refId": "D", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_sockstat_RAW6_inuse{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "IPv6 RAW - In-Use Sockets", + "range": true, + "refId": "E", + "step": 240 + } + ], + "title": "Sockstat FRAG / RAW", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Kernel memory used by TCP, UDP, and IP fragmentation buffers", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 0, + "y": 52 + }, + "id": 220, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_sockstat_TCP_mem_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "TCP", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_sockstat_UDP_mem_bytes{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "UDP", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_sockstat_FRAG_memory{instance=\"$node\",job=\"$job\"}", + "interval": "", + "legendFormat": "Fragmentation", + "range": true, + "refId": "C" + } + ], + "title": "Sockstat Memory Size", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Average memory used per socket (TCP/UDP). Helps tune net.ipv4.tcp_rmem / tcp_wmem", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 8, + "y": 52 + }, + "id": 339, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_sockstat_TCP_mem_bytes{instance=\"$node\",job=\"$job\"} / (node_sockstat_TCP_inuse{instance=\"$node\",job=\"$job\"} > 0)", + "format": "time_series", + "interval": "", + "legendFormat": "TCP", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_sockstat_UDP_mem_bytes{instance=\"$node\",job=\"$job\"} / (node_sockstat_UDP_inuse{instance=\"$node\",job=\"$job\"} > 0)", + "format": "time_series", + "interval": "", + "legendFormat": "UDP", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Sockstat Average Socket Memory", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "TCP/UDP socket memory usage in kernel (in pages)", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 16, + "y": 52 + }, + "id": 336, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_sockstat_TCP_mem{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "TCP", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_sockstat_UDP_mem{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "UDP", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "TCP/UDP Kernel Buffer Memory Pages", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Packets processed and dropped by the softnet network stack per CPU. Drops may indicate CPU saturation or network driver limitations", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "drop (-) / process (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "pps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*Dropped.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 0, + "y": 62 + }, + "id": 290, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_softnet_processed_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "CPU {{cpu}} - Processed", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_softnet_dropped_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "CPU {{cpu}} - Dropped", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Softnet Packets", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "How often the kernel was unable to process all packets in the softnet queue before time ran out. Frequent squeezes may indicate CPU contention or driver inefficiency", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "eps" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 8, + "y": 62 + }, + "id": 310, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_softnet_times_squeezed_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "CPU {{cpu}} - Times Squeezed", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Softnet Out of Quota", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Times each CPU was woken up by Receive Packet Steering (RPS) to process packets steered from other CPUs, and packets dropped for exceeding the flow limit", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "pps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*Dropped.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + }, + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 16, + "y": 62 + }, + "id": 330, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_softnet_received_rps_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "CPU {{cpu}} - RPS Wakeups", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_softnet_flow_limit_count_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "CPU {{cpu}} - Dropped", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Softnet RPS", + "type": "timeseries" + } + ], + "title": "Network Sockstat", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 30 + }, + "id": 274, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of octets sent and received at the IP layer, as reported by /proc/net/netstat", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "out (-) / in (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "Bps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*out.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 163 + }, + "id": 221, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "width": 300 + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_netstat_IpExt_InOctets{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 Rx in", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_IpExt_OutOctets{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "IPv4 Tx out", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Ip6_InOctets{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "IPv6 Rx in", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Ip6_OutOctets{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "IPv6 Tx out", + "range": true, + "refId": "D", + "step": 240 + } + ], + "title": "Netstat IP In / Out Octets", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of TCP segments sent and received per second, including data and control segments", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "out (-) / in (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "pps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*out.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 173 + }, + "id": 299, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_netstat_Tcp_InSegs{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "instant": false, + "interval": "", + "legendFormat": "TCP Rx in", + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Tcp_OutSegs{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "TCP Tx out", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "TCP In / Out", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of UDP datagrams sent and received per second, based on /proc/net/snmp", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "out (-) / in (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "pps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*out.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 183 + }, + "id": 55, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_netstat_Udp_InDatagrams{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 UDP Rx in", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Udp_OutDatagrams{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 UDP Tx out", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Udp6_InDatagrams{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "IPv6 UDP Rx in", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Udp6_OutDatagrams{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "IPv6 UDP Tx out", + "range": true, + "refId": "D", + "step": 240 + } + ], + "title": "UDP In / Out", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of ICMP messages sent and received per second, including error and control messages", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "out (-) / in (+)", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "pps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*out.*/" + }, + "properties": [ + { + "id": "custom.transform", + "value": "negative-Y" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 193 + }, + "id": 115, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_netstat_Icmp_InMsgs{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 ICMP Rx in", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Icmp_OutMsgs{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 ICMP Tx out", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Icmp6_InMsgs{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "IPv6 ICMP Rx in", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Icmp6_OutMsgs{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "IPv6 ICMP Tx out", + "range": true, + "refId": "D", + "step": 240 + } + ], + "title": "ICMP In / Out", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Tracks various TCP error and congestion-related events, including retransmissions, timeouts, dropped connections, and buffer issues", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "pps" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 173 + }, + "id": 104, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_netstat_TcpExt_ListenOverflows{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "Listen Overflows", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_TcpExt_ListenDrops{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "Listen Drops", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_TcpExt_TCPSynRetrans{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "SYN Retransmits", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Tcp_RetransSegs{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "interval": "", + "legendFormat": "Segment Retransmits", + "range": true, + "refId": "D" + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Tcp_InErrs{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "interval": "", + "legendFormat": "Receive Errors", + "range": true, + "refId": "E" + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Tcp_OutRsts{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "interval": "", + "legendFormat": "RST Sent", + "range": true, + "refId": "F" + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_TcpExt_TCPRcvQDrop{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "interval": "", + "legendFormat": "Receive Queue Drops", + "range": true, + "refId": "G" + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_TcpExt_TCPOFOQueue{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "interval": "", + "legendFormat": "Out-of-order Queued", + "range": true, + "refId": "H" + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_TcpExt_TCPTimeouts{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "interval": "", + "legendFormat": "TCP Timeouts", + "range": true, + "refId": "I" + } + ], + "title": "TCP Errors", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of UDP and UDPLite datagram delivery errors, including missing listeners, buffer overflows, and protocol-specific issues", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "pps" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 183 + }, + "id": 109, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_netstat_Udp_InErrors{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 UDP Rx in Errors", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Udp_NoPorts{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 UDP No Listener", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_UdpLite_InErrors{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "interval": "", + "legendFormat": "IPv4 UDPLite Rx in Errors", + "range": true, + "refId": "C" + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Udp_RcvbufErrors{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 UDP Rx in Buffer Errors", + "range": true, + "refId": "D", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Udp_SndbufErrors{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 UDP Tx out Buffer Errors", + "range": true, + "refId": "E", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Udp6_InErrors{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "IPv6 UDP Rx in Errors", + "range": true, + "refId": "F", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Udp6_NoPorts{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "IPv6 UDP No Listener", + "range": true, + "refId": "G", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_UdpLite6_InErrors{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "IPv6 UDPLite Rx in Errors", + "range": true, + "refId": "H", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Udp6_RcvbufErrors{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "IPv6 UDP Rx in Buffer Errors", + "range": true, + "refId": "I", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Udp6_SndbufErrors{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "IPv6 UDP Tx out Buffer Errors", + "range": true, + "refId": "J", + "step": 240 + } + ], + "title": "UDP Errors", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of incoming ICMP messages that contained protocol-specific errors, such as bad checksums or invalid lengths", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "pps" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 193 + }, + "id": 50, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_netstat_Icmp_InErrors{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 ICMP Rx In", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Icmp6_InErrors{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "legendFormat": "IPv6 ICMP Rx In", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "ICMP Errors", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of TCP SYN cookies sent, validated, and failed. These are used to protect against SYN flood attacks and manage TCP handshake resources under load", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "eps" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*Failed.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 8, + "y": 203 + }, + "id": 91, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_netstat_TcpExt_SyncookiesFailed{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "SYN Cookies Failed", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_TcpExt_SyncookiesRecv{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "SYN Cookies Validated", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_TcpExt_SyncookiesSent{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "SYN Cookies Sent", + "range": true, + "refId": "C", + "step": 240 + } + ], + "title": "TCP SynCookie", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of currently established TCP connections", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 163 + }, + "id": 85, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_netstat_Tcp_CurrEstab{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "Current Connections", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "TCP Connections", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Memory currently queued in the UDP receive (RX) and transmit (TX) buffers. A growing queue may indicate a bottleneck", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 16, + "y": 203 + }, + "id": 337, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_udp_queues{instance=\"$node\",job=\"$job\",ip=\"v4\",queue=\"rx\"}", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 UDP Rx in Queue", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_udp_queues{instance=\"$node\",job=\"$job\",ip=\"v4\",queue=\"tx\"}", + "format": "time_series", + "interval": "", + "legendFormat": "IPv4 UDP Tx out Queue", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_udp_queues{instance=\"$node\",job=\"$job\",ip=\"v6\",queue=\"rx\"}", + "format": "time_series", + "legendFormat": "IPv6 UDP Rx in Queue", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_udp_queues{instance=\"$node\",job=\"$job\",ip=\"v6\",queue=\"tx\"}", + "format": "time_series", + "legendFormat": "IPv6 UDP Tx out Queue", + "range": true, + "refId": "D", + "step": 240 + } + ], + "title": "UDP Queue", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of TCP connection initiations per second. 'Active' opens are initiated by this host. 'Passive' opens are accepted from incoming connections", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "eps" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 0, + "y": 203 + }, + "id": 82, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(node_netstat_Tcp_ActiveOpens{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "Active Opens", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "rate(node_netstat_Tcp_PassiveOpens{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "Passive Opens", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "TCP Direct Transition", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of TCP sockets in key connection states. Requires the --collector.tcpstat flag on node_exporter", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 0, + "y": 213 + }, + "id": 320, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_tcp_connection_states{state=\"established\",instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "Established", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_tcp_connection_states{state=\"fin_wait2\",instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "FIN_WAIT2", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_tcp_connection_states{state=\"listen\",instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "Listen", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_tcp_connection_states{state=\"time_wait\",instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "TIME_WAIT", + "range": true, + "refId": "D", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_tcp_connection_states{state=\"close_wait\", instance=\"$node\", job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "CLOSE_WAIT", + "range": true, + "refId": "E", + "step": 240 + } + ], + "title": "TCP Stat Persistent", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Transient TCP connection states. These are typically short-lived during connection establishment and teardown", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 8, + "y": 213 + }, + "id": 341, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_tcp_connection_states{state=\"syn_sent\",instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "SYN_SENT", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_tcp_connection_states{state=\"syn_recv\",instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "SYN_RECV", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_tcp_connection_states{state=\"fin_wait1\",instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "FIN_WAIT1", + "range": true, + "refId": "C", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_tcp_connection_states{state=\"close\",instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "CLOSE", + "range": true, + "refId": "D", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_tcp_connection_states{state=\"last_ack\",instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "LAST_ACK", + "range": true, + "refId": "E", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_tcp_connection_states{state=\"closing\",instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "CLOSING", + "range": true, + "refId": "F", + "step": 240 + } + ], + "title": "TCP Stat Transient", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "TCP socket queue sizes. High rx_queued_bytes indicates application not reading fast enough. High tx_queued_bytes indicates network congestion or slow receiver", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 8, + "x": 16, + "y": 213 + }, + "id": 340, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_tcp_connection_states{state=\"rx_queued_bytes\",instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "RX Queued (waiting to be read)", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "node_tcp_connection_states{state=\"tx_queued_bytes\",instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "legendFormat": "TX Queued (waiting to be sent)", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "TCP Socket Queue", + "type": "timeseries" + } + ], + "title": "Network Netstat", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 31 + }, + "id": 279, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Duration of each individual collector executed during a Node Exporter scrape. Useful for identifying slow or failing collectors", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 164 + }, + "id": 40, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_scrape_collector_duration_seconds{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "{{collector}}", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Node Exporter Scrape Time", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Rate of CPU time used by the process exposing this metric (user + system mode)", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 164 + }, + "id": 308, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "rate(process_cpu_seconds_total{instance=\"$node\",job=\"$job\"}[$__rate_interval])", + "format": "time_series", + "interval": "", + "legendFormat": "Process CPU Usage", + "range": true, + "refId": "A", + "step": 240 + } + ], + "title": "Exporter Process CPU Usage", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Tracks the memory usage of the process exposing this metric (e.g., node_exporter), including resident memory (RSS), current virtual memory and maximum virtual memory limit. The limit is shown in the legend and tooltip but hidden from the graph to preserve scale.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "bytes" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Virtual Memory Limit" + }, + "properties": [ + { + "id": "custom.fillOpacity", + "value": 0 + }, + { + "id": "custom.lineStyle", + "value": { + "dash": [ + 10, + 10 + ], + "fill": "dash" + } + }, + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Virtual Memory Limit" + }, + "properties": [ + { + "id": "custom.hideFrom", + "value": { + "legend": false, + "tooltip": false, + "viz": true + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 10, + "x": 0, + "y": 174 + }, + "id": 149, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "process_virtual_memory_bytes{instance=\"$node\",job=\"$job\"}", + "interval": "", + "legendFormat": "Virtual Memory", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "process_virtual_memory_max_bytes{instance=\"$node\",job=\"$job\"}", + "interval": "", + "legendFormat": "Virtual Memory Limit", + "range": true, + "refId": "B", + "step": 240 + }, + { + "editorMode": "code", + "expr": "process_resident_memory_bytes{instance=\"$node\",job=\"$job\"}", + "interval": "", + "legendFormat": "Resident Memory (RSS)", + "range": true, + "refId": "C", + "step": 240 + } + ], + "title": "Exporter Processes Memory", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Number of file descriptors used by the exporter process versus its configured limit. The limit is shown in the legend and tooltip but hidden from the graph to preserve scale.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*Max.*/" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + }, + { + "id": "custom.fillOpacity", + "value": 0 + }, + { + "id": "custom.lineStyle", + "value": { + "dash": [ + 10, + 10 + ], + "fill": "dash" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Maximum open file descriptors" + }, + "properties": [ + { + "id": "custom.hideFrom", + "value": { + "legend": false, + "tooltip": false, + "viz": true + } + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 10, + "x": 10, + "y": 174 + }, + "id": 64, + "options": { + "legend": { + "calcs": [ + "min", + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "process_max_fds{instance=\"$node\",job=\"$job\"}", + "interval": "", + "legendFormat": "Maximum open file descriptors", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "process_open_fds{instance=\"$node\",job=\"$job\"}", + "interval": "", + "legendFormat": "Open file descriptors", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Exporter File Descriptor Usage", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "description": "Shows whether each Node Exporter collector scraped successfully (1 = success, 0 = failure), and whether the textfile collector returned an error.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "dark-red", + "value": 0 + }, + { + "color": "green", + "value": 1 + } + ] + }, + "unit": "bool" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 4, + "x": 20, + "y": 174 + }, + "id": 157, + "options": { + "displayMode": "basic", + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "maxVizHeight": 300, + "minVizHeight": 16, + "minVizWidth": 8, + "namePlacement": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showUnfilled": true, + "sizing": "auto", + "valueMode": "color" + }, + "pluginVersion": "11.6.1", + "targets": [ + { + "editorMode": "code", + "expr": "node_scrape_collector_success{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "{{collector}}", + "range": true, + "refId": "A", + "step": 240 + }, + { + "editorMode": "code", + "expr": "1 - node_textfile_scrape_error{instance=\"$node\",job=\"$job\"}", + "format": "time_series", + "interval": "", + "legendFormat": "textfile", + "range": true, + "refId": "B", + "step": 240 + } + ], + "title": "Node Exporter Scrape", + "type": "bargauge" + } + ], + "title": "Node Exporter", + "type": "row" + } + ], + "refresh": "1m", + "schemaVersion": 41, + "tags": [ + "linux" + ], + "templating": { + "list": [ + { + "current": {}, + "includeAll": false, + "label": "Datasource", + "name": "ds_prometheus", + "options": [], + "query": "prometheus", + "refresh": 1, + "regex": "", + "type": "datasource" + }, + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "definition": "", + "includeAll": false, + "label": "Job", + "name": "job", + "options": [], + "query": { + "query": "label_values(node_uname_info, job)", + "refId": "Prometheus-job-Variable-Query" + }, + "refresh": 1, + "regex": "", + "sort": 1, + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "definition": "label_values(node_uname_info{job=\"$job\"}, nodename)", + "includeAll": false, + "label": "Nodename", + "name": "nodename", + "options": [], + "query": { + "query": "label_values(node_uname_info{job=\"$job\"}, nodename)", + "refId": "Prometheus-nodename-Variable-Query" + }, + "refresh": 1, + "regex": "", + "sort": 1, + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${ds_prometheus}" + }, + "definition": "label_values(node_uname_info{job=\"$job\", nodename=\"$nodename\"}, instance)", + "includeAll": false, + "label": "Instance", + "name": "node", + "options": [], + "query": { + "query": "label_values(node_uname_info{job=\"$job\", nodename=\"$nodename\"}, instance)", + "refId": "Prometheus-node-Variable-Query" + }, + "refresh": 1, + "regex": "", + "sort": 1, + "type": "query" + } + ] + }, + "time": { + "from": "now-24h", + "to": "now" + }, + "timepicker": {}, + "timezone": "browser", + "title": "Node Exporter Full", + "uid": "gnet-1860", + "version": 105, + "weekStart": "", + "gnetId": 1860 +} \ No newline at end of file diff --git a/nixos/hosts/asxpio-ops/monitoring/dashboards/Logs/logs.json b/nixos/hosts/asxpio-ops/monitoring/dashboards/Logs/logs.json new file mode 100644 index 0000000..5f78183 --- /dev/null +++ b/nixos/hosts/asxpio-ops/monitoring/dashboards/Logs/logs.json @@ -0,0 +1,248 @@ +{ + "annotations": { + "list": [ + { + "$$hashKey": "object:75", + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "Log Viewer Dashboard for Loki", + "editable": false, + "gnetId": 13639, + "graphTooltip": 0, + "id": null, + "iteration": 1608932746420, + "links": [ + { + "$$hashKey": "object:59", + "icon": "bolt", + "includeVars": true, + "keepTime": true, + "tags": [], + "targetBlank": true, + "title": "View In Explore", + "type": "link", + "url": "/explore?orgId=1&left=[\"now-1h\",\"now\",\"Loki\",{\"expr\":\"{job=\\\"$app\\\"}\"},{\"ui\":[true,true,true,\"none\"]}]" + }, + { + "$$hashKey": "object:61", + "icon": "external link", + "tags": [], + "targetBlank": true, + "title": "Learn LogQL", + "type": "link", + "url": "https://grafana.com/docs/loki/latest/logql/" + } + ], + "panels": [ + { + "aliasColors": {}, + "bars": true, + "dashLength": 10, + "dashes": false, + "datasource": "loki", + "fieldConfig": { + "defaults": { + "custom": {}, + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 3, + "w": 24, + "x": 0, + "y": 0 + }, + "hiddenSeries": false, + "id": 6, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": false, + "linewidth": 1, + "nullPointMode": "null", + "percentage": false, + "pluginVersion": "7.1.0", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(count_over_time({job=\"$app\"} |= \"$search\" [$__interval]))", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:168", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + }, + { + "$$hashKey": "object:169", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "datasource": "loki", + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "gridPos": { + "h": 25, + "w": 24, + "x": 0, + "y": 3 + }, + "id": 2, + "maxDataPoints": "", + "options": { + "showLabels": false, + "showTime": true, + "sortOrder": "Descending", + "wrapLogMessage": false + }, + "targets": [ + { + "expr": "{job=\"$app\"} |= \"$search\" | logfmt", + "hide": false, + "legendFormat": "", + "refId": "A" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "", + "transparent": true, + "type": "logs" + } + ], + "refresh": false, + "schemaVersion": 26, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "allValue": null, + "current": {}, + "datasource": "loki", + "definition": "label_values(job)", + "hide": 0, + "includeAll": false, + "label": "App", + "multi": false, + "name": "app", + "options": [], + "query": "label_values(job)", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "current": { + "selected": false, + "text": "", + "value": "" + }, + "hide": 0, + "label": "String Match", + "name": "search", + "options": [ + { + "selected": true, + "text": "", + "value": "" + } + ], + "query": "", + "skipUrlSync": false, + "type": "textbox" + } + ] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": { + "hidden": false, + "refresh_intervals": [ + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "Logs / App", + "uid": "gnet-13639", + "version": 13 +} \ No newline at end of file diff --git a/nixos/hosts/asxpio-ops/monitoring/dashboards/Security/security.json b/nixos/hosts/asxpio-ops/monitoring/dashboards/Security/security.json new file mode 100644 index 0000000..3e7fbe3 --- /dev/null +++ b/nixos/hosts/asxpio-ops/monitoring/dashboards/Security/security.json @@ -0,0 +1,2168 @@ +{ + "uid": "asxpio-security", + "title": "Security", + "tags": [ + "asxpio", + "security" + ], + "timezone": "browser", + "editable": false, + "refresh": "1m", + "time": { + "from": "now-24h", + "to": "now" + }, + "schemaVersion": 39, + "graphTooltip": 1, + "links": [ + { + "title": "Dashboards", + "type": "dashboards", + "asDropdown": true, + "includeVars": false, + "keepTime": true, + "tags": [] + } + ], + "panels": [ + { + "type": "row", + "title": "Unexpected (each of these alerts)", + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "panels": [], + "id": 1 + }, + { + "type": "stat", + "title": "WireGuard peers", + "description": "Peers not in wireguard_clients", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "count(security_wg_peer_info{known=\"false\"}) or vector(0)", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 4, + "w": 3, + "x": 0, + "y": 1 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "background", + "graphMode": "none", + "textMode": "value" + }, + "id": 2 + }, + { + "type": "stat", + "title": "VPC devices, servers", + "description": "Addresses answering ping on the private network that are not in security_vpc_hosts, plus servers in the Hetzner project that are not in monitoring_hcloud_servers", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "(count(group by (ip) (security_vpc_host_info{known=\"false\"})) or vector(0)) + (count(up{job=\"hcloud\",known=\"false\"}) or vector(0))", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 4, + "w": 3, + "x": 3, + "y": 1 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "background", + "graphMode": "none", + "textMode": "value" + }, + "id": 3 + }, + { + "type": "stat", + "title": "Accounts", + "description": "Login accounts, and members of sudo or docker, outside the baseline", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "count(security_user_info{known=\"false\"} or security_group_member_info{known=\"false\"}) or vector(0)", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 4, + "w": 3, + "x": 6, + "y": 1 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "background", + "graphMode": "none", + "textMode": "value" + }, + "id": 4 + }, + { + "type": "stat", + "title": "Listening ports", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "count(security_listening_port_info{known=\"false\"}) or vector(0)", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 4, + "w": 3, + "x": 9, + "y": 1 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "background", + "graphMode": "none", + "textMode": "value" + }, + "id": 5 + }, + { + "type": "stat", + "title": "Containers", + "description": "Privileged, host network or PID, host root or the Docker socket, outside the baseline", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "count(security_container_privileged_info{known=\"false\"}) or vector(0)", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 4, + "w": 3, + "x": 12, + "y": 1 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "background", + "graphMode": "none", + "textMode": "value" + }, + "id": 6 + }, + { + "type": "stat", + "title": "File changes (24 h)", + "description": "accounts, sudoers, sshd, wireguard, authorized_keys", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum(changes(security_fileset_hash[24h]))", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 4, + "w": 3, + "x": 15, + "y": 1 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "background", + "graphMode": "none", + "textMode": "value" + }, + "id": 7 + }, + { + "type": "stat", + "title": "SSH logins (24 h)", + "description": "", + "datasource": { + "type": "loki", + "uid": "loki" + }, + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "loki" + }, + "expr": "sum(count_over_time({job=\"journal\", unit=\"ssh.service\"} |~ `Accepted \\S+ for ` [24h]))", + "refId": "A", + "instant": true, + "range": false, + "queryType": "instant" + } + ], + "gridPos": { + "h": 4, + "w": 3, + "x": 18, + "y": 1 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "blue", + "value": null + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "background", + "graphMode": "none", + "textMode": "value" + }, + "id": 8 + }, + { + "type": "stat", + "title": "Failed SSH (24 h)", + "description": "", + "datasource": { + "type": "loki", + "uid": "loki" + }, + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "loki" + }, + "expr": "sum(count_over_time({job=\"journal\", unit=\"ssh.service\"} |~ `Failed \\S+ for |Invalid user |Connection closed by (authenticating|invalid) user ` [24h]))", + "refId": "A", + "instant": true, + "range": false, + "queryType": "instant" + } + ], + "gridPos": { + "h": 4, + "w": 3, + "x": 21, + "y": 1 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "blue", + "value": null + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "background", + "graphMode": "none", + "textMode": "value" + }, + "id": 9 + }, + { + "type": "row", + "title": "Networks", + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 5 + }, + "panels": [], + "id": 10 + }, + { + "type": "table", + "title": "WireGuard peers", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "security_wg_peer_last_handshake_seconds * 1000 * on (host, interface, peer) group_left (allowed_ips, known) security_wg_peer_info", + "refId": "A", + "instant": true, + "range": false, + "format": "table" + } + ], + "gridPos": { + "h": 8, + "w": 10, + "x": 0, + "y": 6 + }, + "fieldConfig": { + "defaults": { + "custom": { + "filterable": true + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "known" + }, + "properties": [ + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "true": { + "text": "yes", + "color": "green" + }, + "false": { + "text": "NO", + "color": "red" + } + } + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "custom.width", + "value": 80 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Value" + }, + "properties": [ + { + "id": "displayName", + "value": "last handshake" + }, + { + "id": "unit", + "value": "dateTimeFromNow" + }, + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "0": { + "text": "never" + } + } + } + ] + } + ] + } + ] + }, + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "__name__": true, + "instance": true, + "job": true + }, + "indexByName": { + "host": 0, + "interface": 1, + "peer": 2, + "allowed_ips": 3, + "known": 4, + "Value": 5 + } + } + } + ], + "options": { + "showHeader": true, + "cellHeight": "sm" + }, + "id": 11 + }, + { + "type": "table", + "title": "WireGuard endpoints", + "description": "Where each peer last connected from. A network (/16) not seen for that peer in 14 days alerts.", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "security_wg_peer_endpoint_info", + "refId": "A", + "instant": true, + "range": false, + "format": "table" + } + ], + "gridPos": { + "h": 8, + "w": 7, + "x": 10, + "y": 6 + }, + "fieldConfig": { + "defaults": { + "custom": { + "filterable": true + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "known" + }, + "properties": [ + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "true": { + "text": "yes", + "color": "green" + }, + "false": { + "text": "NO", + "color": "red" + } + } + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "custom.width", + "value": 80 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Value" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + } + ] + }, + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "__name__": true, + "instance": true, + "job": true + }, + "indexByName": { + "host": 0, + "peer": 1, + "endpoint": 2, + "net": 3 + } + } + } + ], + "options": { + "showHeader": true, + "cellHeight": "sm" + }, + "id": 12 + }, + { + "type": "table", + "title": "Private network (VPC) devices", + "description": "Ping sweep of the VPC from both hosts, every minute. A device that drops ICMP is not seen.", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "group by (ip, known) (security_vpc_host_info)", + "refId": "A", + "instant": true, + "range": false, + "format": "table" + } + ], + "gridPos": { + "h": 8, + "w": 7, + "x": 17, + "y": 6 + }, + "fieldConfig": { + "defaults": { + "custom": { + "filterable": true + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "known" + }, + "properties": [ + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "true": { + "text": "yes", + "color": "green" + }, + "false": { + "text": "NO", + "color": "red" + } + } + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "custom.width", + "value": 80 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Value" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + } + ] + }, + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "__name__": true, + "instance": true, + "job": true + }, + "indexByName": { + "ip": 0, + "known": 1 + } + } + } + ], + "options": { + "showHeader": true, + "cellHeight": "sm" + }, + "id": 13 + }, + { + "type": "table", + "title": "Hetzner project servers", + "description": "Servers the Hetzner API lists for the project, refreshed every minute. Catches a server that drops ping or is not attached to the VPC.", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "group by (server, type, status, public_ip, private_ip, known) (up{job=\"hcloud\"})", + "refId": "A", + "instant": true, + "range": false, + "format": "table" + } + ], + "gridPos": { + "h": 4, + "w": 24, + "x": 0, + "y": 14 + }, + "fieldConfig": { + "defaults": { + "custom": { + "filterable": true + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "known" + }, + "properties": [ + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "true": { + "text": "yes", + "color": "green" + }, + "false": { + "text": "NO", + "color": "red" + } + } + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "custom.width", + "value": 80 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Value" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + } + ] + }, + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "__name__": true, + "instance": true, + "job": true + }, + "indexByName": { + "server": 0, + "type": 1, + "status": 2, + "public_ip": 3, + "private_ip": 4, + "known": 5 + } + } + } + ], + "options": { + "showHeader": true, + "cellHeight": "sm" + }, + "id": 31 + }, + { + "type": "table", + "title": "Listening ports", + "description": "Outside loopback. Known entries show the allowlist entry (a range or *), others the port.", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "security_listening_port_info", + "refId": "A", + "instant": true, + "range": false, + "format": "table" + } + ], + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 18 + }, + "fieldConfig": { + "defaults": { + "custom": { + "filterable": true + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "known" + }, + "properties": [ + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "true": { + "text": "yes", + "color": "green" + }, + "false": { + "text": "NO", + "color": "red" + } + } + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "custom.width", + "value": 80 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Value" + }, + "properties": [ + { + "id": "displayName", + "value": "sockets" + } + ] + } + ] + }, + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "__name__": true, + "instance": true, + "job": true + }, + "indexByName": { + "host": 0, + "scope": 1, + "proto": 2, + "port": 3, + "process": 4, + "known": 5, + "Value": 6 + } + } + } + ], + "options": { + "showHeader": true, + "cellHeight": "sm" + }, + "id": 14 + }, + { + "type": "row", + "title": "Accounts and keys", + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 27 + }, + "panels": [], + "id": 15 + }, + { + "type": "table", + "title": "Login accounts", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "security_user_info", + "refId": "A", + "instant": true, + "range": false, + "format": "table" + } + ], + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 28 + }, + "fieldConfig": { + "defaults": { + "custom": { + "filterable": true + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "known" + }, + "properties": [ + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "true": { + "text": "yes", + "color": "green" + }, + "false": { + "text": "NO", + "color": "red" + } + } + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "custom.width", + "value": 80 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Value" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + } + ] + }, + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "__name__": true, + "instance": true, + "job": true + }, + "indexByName": { + "host": 0, + "user": 1, + "uid": 2, + "shell": 3, + "known": 4 + } + } + } + ], + "options": { + "showHeader": true, + "cellHeight": "sm" + }, + "id": 16 + }, + { + "type": "table", + "title": "sudo and docker members", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "security_group_member_info", + "refId": "A", + "instant": true, + "range": false, + "format": "table" + } + ], + "gridPos": { + "h": 8, + "w": 6, + "x": 8, + "y": 28 + }, + "fieldConfig": { + "defaults": { + "custom": { + "filterable": true + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "known" + }, + "properties": [ + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "true": { + "text": "yes", + "color": "green" + }, + "false": { + "text": "NO", + "color": "red" + } + } + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "custom.width", + "value": 80 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Value" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + } + ] + }, + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "__name__": true, + "instance": true, + "job": true + }, + "indexByName": { + "host": 0, + "group": 1, + "user": 2, + "known": 3 + } + } + } + ], + "options": { + "showHeader": true, + "cellHeight": "sm" + }, + "id": 17 + }, + { + "type": "table", + "title": "authorized_keys", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "security_authorized_keys", + "refId": "A", + "instant": true, + "range": false, + "format": "table" + } + ], + "gridPos": { + "h": 8, + "w": 10, + "x": 14, + "y": 28 + }, + "fieldConfig": { + "defaults": { + "custom": { + "filterable": true + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "known" + }, + "properties": [ + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "true": { + "text": "yes", + "color": "green" + }, + "false": { + "text": "NO", + "color": "red" + } + } + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "custom.width", + "value": 80 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Value" + }, + "properties": [ + { + "id": "displayName", + "value": "keys" + } + ] + } + ] + }, + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "__name__": true, + "instance": true, + "job": true + }, + "indexByName": { + "host": 0, + "user": 1, + "file": 2, + "Value": 3 + } + } + } + ], + "options": { + "showHeader": true, + "cellHeight": "sm" + }, + "id": 18 + }, + { + "type": "table", + "title": "Watched files: last change", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "security_fileset_mtime_seconds * 1000", + "refId": "A", + "instant": true, + "range": false, + "format": "table" + } + ], + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 36 + }, + "fieldConfig": { + "defaults": { + "custom": { + "filterable": true + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "known" + }, + "properties": [ + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "true": { + "text": "yes", + "color": "green" + }, + "false": { + "text": "NO", + "color": "red" + } + } + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "custom.width", + "value": 80 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Value" + }, + "properties": [ + { + "id": "displayName", + "value": "changed" + }, + { + "id": "unit", + "value": "dateTimeFromNow" + }, + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "0": { + "text": "never" + } + } + } + ] + } + ] + } + ] + }, + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "__name__": true, + "instance": true, + "job": true + }, + "indexByName": { + "host": 0, + "set": 1, + "Value": 2 + } + } + } + ], + "options": { + "showHeader": true, + "cellHeight": "sm" + }, + "id": 19 + }, + { + "type": "table", + "title": "Open sessions", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "security_sessions", + "refId": "A", + "instant": true, + "range": false, + "format": "table" + } + ], + "gridPos": { + "h": 7, + "w": 6, + "x": 8, + "y": 36 + }, + "fieldConfig": { + "defaults": { + "custom": { + "filterable": true + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "known" + }, + "properties": [ + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "true": { + "text": "yes", + "color": "green" + }, + "false": { + "text": "NO", + "color": "red" + } + } + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "custom.width", + "value": 80 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Value" + }, + "properties": [ + { + "id": "displayName", + "value": "sessions" + } + ] + } + ] + }, + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "__name__": true, + "instance": true, + "job": true + }, + "indexByName": { + "host": 0, + "user": 1, + "origin": 2, + "Value": 3 + } + } + } + ], + "options": { + "showHeader": true, + "cellHeight": "sm" + }, + "id": 20 + }, + { + "type": "table", + "title": "Containers with host access", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "security_container_privileged_info", + "refId": "A", + "instant": true, + "range": false, + "format": "table" + } + ], + "gridPos": { + "h": 7, + "w": 10, + "x": 14, + "y": 36 + }, + "fieldConfig": { + "defaults": { + "custom": { + "filterable": true + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "known" + }, + "properties": [ + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "true": { + "text": "yes", + "color": "green" + }, + "false": { + "text": "NO", + "color": "red" + } + } + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "custom.width", + "value": 80 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Value" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + } + ] + }, + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "__name__": true, + "instance": true, + "job": true + }, + "indexByName": { + "host": 0, + "name": 1, + "flags": 2, + "known": 3 + } + } + } + ], + "options": { + "showHeader": true, + "cellHeight": "sm" + }, + "id": 21 + }, + { + "type": "row", + "title": "SSH", + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 43 + }, + "panels": [], + "id": 22 + }, + { + "type": "timeseries", + "title": "Logins by user and source", + "datasource": { + "type": "loki", + "uid": "loki" + }, + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "loki" + }, + "expr": "sum by (host, user, src) (count_over_time({job=\"journal\", unit=\"ssh.service\"} |~ `Accepted \\S+ for ` | regexp `Accepted \\S+ for (?P\\S+) from (?P\\S+)` [$__interval]))", + "legendFormat": "{{host}}: {{user}} from {{src}}", + "refId": "A", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 44 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "drawStyle": "bars", + "fillOpacity": 60, + "stacking": { + "mode": "normal" + } + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "id": 23 + }, + { + "type": "timeseries", + "title": "Failed logins", + "datasource": { + "type": "loki", + "uid": "loki" + }, + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "loki" + }, + "expr": "sum by (host) (count_over_time({job=\"journal\", unit=\"ssh.service\"} |~ `Failed \\S+ for |Invalid user |Connection closed by (authenticating|invalid) user ` [$__interval]))", + "legendFormat": "{{host}}", + "refId": "A", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 44 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "drawStyle": "bars", + "fillOpacity": 60, + "stacking": { + "mode": "normal" + } + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "id": 24 + }, + { + "type": "logs", + "title": "Logins", + "datasource": { + "type": "loki", + "uid": "loki" + }, + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "loki" + }, + "expr": "{job=\"journal\", unit=\"ssh.service\"} |~ `Accepted \\S+ for `", + "refId": "A", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 51 + }, + "options": { + "showTime": true, + "showLabels": false, + "wrapLogMessage": true, + "sortOrder": "Descending", + "enableLogDetails": true + }, + "id": 25 + }, + { + "type": "logs", + "title": "sudo, su and account changes", + "datasource": { + "type": "loki", + "uid": "loki" + }, + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "loki" + }, + "expr": "{job=\"journal\"} |~ `sudo:.*COMMAND|su\\[\\d+\\]|useradd|usermod|userdel|groupadd|gpasswd|chpasswd|passwd\\[\\d+\\]`", + "refId": "A", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 51 + }, + "options": { + "showTime": true, + "showLabels": false, + "wrapLogMessage": true, + "sortOrder": "Descending", + "enableLogDetails": true + }, + "id": 26 + }, + { + "type": "row", + "title": "Forgejo and web logins", + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 60 + }, + "panels": [], + "id": 27 + }, + { + "type": "stat", + "title": "Forgejo", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "description": "Growth in users, admins, keys or runners alerts.", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "security_forgejo_objects", + "legendFormat": "{{kind}}", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 61 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "fixed", + "fixedColor": "blue" + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "value", + "graphMode": "none", + "textMode": "value_and_name" + }, + "id": 28 + }, + { + "type": "timeseries", + "title": "Failed web logins", + "datasource": { + "type": "loki", + "uid": "loki" + }, + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "loki" + }, + "expr": "sum(count_over_time({container=\"forgejo\"} |= `Failed authentication attempt` [$__interval]))", + "legendFormat": "Forgejo", + "refId": "A", + "instant": false, + "range": true + }, + { + "datasource": { + "type": "loki", + "uid": "loki" + }, + "expr": "sum(count_over_time({job=\"traefik-access\"} |= `\"grafana@docker\"` |~ `\"POST /login HTTP/[0-9.]+\" 401 ` [$__interval]))", + "legendFormat": "Grafana", + "refId": "B", + "instant": false, + "range": true + }, + { + "datasource": { + "type": "loki", + "uid": "loki" + }, + "expr": "sum(count_over_time({job=\"traefik-access\"} |= `\"asxpio@docker\"` |~ `\"POST /admin/login HTTP/[0-9.]+\" (401|429) ` [$__interval]))", + "legendFormat": "asxp.io admin", + "refId": "C", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 7, + "w": 16, + "x": 8, + "y": 61 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "drawStyle": "bars", + "fillOpacity": 60, + "stacking": { + "mode": "normal" + } + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "id": 29 + }, + { + "type": "logs", + "title": "Failed web logins", + "datasource": { + "type": "loki", + "uid": "loki" + }, + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "loki" + }, + "expr": "{container=\"forgejo\"} |= `Failed authentication attempt`", + "refId": "A", + "instant": false, + "range": true + }, + { + "datasource": { + "type": "loki", + "uid": "loki" + }, + "expr": "{job=\"traefik-access\"} |~ `\"POST /(admin/)?login HTTP/[0-9.]+\" (401|429) `", + "refId": "B", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 68 + }, + "options": { + "showTime": true, + "showLabels": false, + "wrapLogMessage": true, + "sortOrder": "Descending", + "enableLogDetails": true + }, + "id": 30 + } + ] +} diff --git a/nixos/hosts/asxpio-ops/monitoring/dashboards/Services/crawlers.json b/nixos/hosts/asxpio-ops/monitoring/dashboards/Services/crawlers.json new file mode 100644 index 0000000..88a1783 --- /dev/null +++ b/nixos/hosts/asxpio-ops/monitoring/dashboards/Services/crawlers.json @@ -0,0 +1,1148 @@ +{ + "uid": "asxpio-crawlers", + "title": "AI crawlers", + "tags": [ + "asxpio", + "traefik" + ], + "timezone": "browser", + "editable": false, + "refresh": "5m", + "time": { + "from": "now-24h", + "to": "now" + }, + "schemaVersion": 39, + "graphTooltip": 1, + "links": [ + { + "title": "Dashboards", + "type": "dashboards", + "asDropdown": true, + "includeVars": false, + "keepTime": true, + "tags": [] + } + ], + "panels": [ + { + "type": "piechart", + "title": "Who is asking (time range)", + "id": 1, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum(increase(crawler_ai_requests_total{verdict=\"verified\"}[$__range]))", + "legendFormat": "AI · verified", + "refId": "A", + "instant": true, + "range": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum(increase(crawler_ai_requests_total{verdict=\"spoofed\"}[$__range]))", + "legendFormat": "AI · spoofed", + "refId": "B", + "instant": true, + "range": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum(increase(crawler_ai_requests_total{verdict=~\"unknown|proxied|private\"}[$__range]))", + "legendFormat": "AI · unverifiable", + "refId": "C", + "instant": true, + "range": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum(increase(crawler_class_requests_total{class=\"other-bot\"}[$__range]))", + "legendFormat": "other bots", + "refId": "D", + "instant": true, + "range": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum(increase(crawler_class_requests_total{class=\"browser-like\"}[$__range]))", + "legendFormat": "browser-like", + "refId": "E", + "instant": true, + "range": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum(increase(crawler_class_requests_total{class=\"none\"}[$__range]))", + "legendFormat": "no user agent", + "refId": "F", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 8, + "w": 6, + "x": 0, + "y": 0 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "verified" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "green" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "spoofed" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "red" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "proxied" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "blue" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "unknown" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "yellow" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "private" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "purple" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "AI · verified" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "green" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "AI · spoofed" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "red" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "AI · unverifiable" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "yellow" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "other bots" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "orange" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "browser-like" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "purple" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "no user agent" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "text" + } + } + ] + } + ] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "pieType": "donut", + "legend": { + "displayMode": "table", + "placement": "right", + "showLegend": true, + "values": [ + "value", + "percent" + ] + }, + "tooltip": { + "mode": "single" + } + }, + "description": "From the Traefik access log, every router (crawler-alert.py --metrics, 5-minute timer). A request naming an AI bot counts as verified only if its source IP is in the vendor's published ranges, or passes forward-confirmed reverse DNS, or (Meta) sits in the vendor's own ASN. spoofed = the claim failed that check; unverifiable = via Cloudflare, no PTR, or over the DNS budget." + }, + { + "type": "timeseries", + "title": "AI crawler requests by verdict (per minute)", + "id": 2, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum by (verdict) (rate(crawler_ai_requests_total[$__rate_interval])) * 60", + "legendFormat": "{{verdict}}", + "refId": "A", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 8, + "w": 9, + "x": 6, + "y": 0 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "unit": "short", + "custom": { + "stacking": { + "mode": "normal" + }, + "fillOpacity": 40, + "lineWidth": 1 + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "verified" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "green" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "spoofed" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "red" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "proxied" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "blue" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "unknown" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "yellow" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "private" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "purple" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "AI · verified" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "green" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "AI · spoofed" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "red" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "AI · unverifiable" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "yellow" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "other bots" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "orange" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "browser-like" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "purple" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "no user agent" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "text" + } + } + ] + } + ] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "description": "From the Traefik access log, every router (crawler-alert.py --metrics, 5-minute timer). A request naming an AI bot counts as verified only if its source IP is in the vendor's published ranges, or passes forward-confirmed reverse DNS, or (Meta) sits in the vendor's own ASN. spoofed = the claim failed that check; unverifiable = via Cloudflare, no PTR, or over the DNS budget." + }, + { + "type": "bargauge", + "title": "Verified AI crawlers by vendor (time range)", + "id": 3, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sort_desc(sum by (vendor) (increase(crawler_ai_requests_total{verdict=\"verified\"}[$__range])))", + "legendFormat": "{{vendor}}", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 8, + "w": 9, + "x": 15, + "y": 0 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "unit": "short", + "decimals": 0, + "min": 0 + }, + "overrides": [] + }, + "options": { + "displayMode": "gradient", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "values": false + }, + "showUnfilled": true, + "valueMode": "color" + } + }, + { + "type": "stat", + "title": "Spoofed share of AI claims", + "id": 4, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum(increase(crawler_ai_requests_total{verdict=\"spoofed\"}[$__range])) / sum(increase(crawler_ai_requests_total[$__range]))", + "legendFormat": "spoofed", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 5, + "w": 6, + "x": 0, + "y": 8 + }, + "fieldConfig": { + "defaults": { + "unit": "percentunit", + "decimals": 1, + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 0.25 + }, + { + "color": "red", + "value": 0.5 + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "value", + "graphMode": "none", + "textMode": "value_and_name", + "justifyMode": "center", + "orientation": "auto" + } + }, + { + "type": "stat", + "title": "Served to verified AI crawlers", + "id": 5, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum(increase(crawler_ai_verified_bytes_total[$__range]))", + "legendFormat": "bytes", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 5, + "w": 6, + "x": 6, + "y": 8 + }, + "fieldConfig": { + "defaults": { + "unit": "bytes", + "color": { + "mode": "fixed", + "fixedColor": "green" + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "value", + "graphMode": "none", + "textMode": "value_and_name", + "justifyMode": "center", + "orientation": "auto" + } + }, + { + "type": "stat", + "title": "All requests (time range)", + "id": 6, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum(increase(crawler_requests_total[$__range]))", + "legendFormat": "requests", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 5, + "w": 6, + "x": 12, + "y": 8 + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0, + "color": { + "mode": "fixed", + "fixedColor": "text" + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "value", + "graphMode": "none", + "textMode": "value_and_name", + "justifyMode": "center", + "orientation": "auto" + } + }, + { + "type": "stat", + "title": "Collector last ran", + "id": 7, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "time() - crawler_metrics_last_run_timestamp_seconds", + "legendFormat": "ago", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 5, + "w": 6, + "x": 18, + "y": 8 + }, + "fieldConfig": { + "defaults": { + "unit": "s", + "decimals": 0, + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 900 + }, + { + "color": "red", + "value": 3600 + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "value", + "graphMode": "none", + "textMode": "value_and_name", + "justifyMode": "center", + "orientation": "auto" + } + }, + { + "type": "timeseries", + "title": "Verified AI requests by vendor (per minute)", + "id": 8, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum by (vendor) (rate(crawler_ai_requests_total{verdict=\"verified\"}[$__rate_interval])) * 60", + "legendFormat": "{{vendor}}", + "refId": "A", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 13 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "unit": "short", + "custom": { + "stacking": { + "mode": "normal" + }, + "fillOpacity": 40, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + } + }, + { + "type": "timeseries", + "title": "Client classes (per minute)", + "id": 9, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum(rate(crawler_ai_requests_total[$__rate_interval])) * 60", + "legendFormat": "AI-bot claims", + "refId": "A", + "instant": false, + "range": true + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum by (class) (rate(crawler_class_requests_total[$__rate_interval])) * 60", + "legendFormat": "{{class}}", + "refId": "B", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 13 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "unit": "short", + "custom": { + "stacking": { + "mode": "normal" + }, + "fillOpacity": 40, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + } + }, + { + "type": "table", + "title": "AI bots by verdict (time range)", + "id": 10, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum by (vendor, bot, verdict) (increase(crawler_ai_requests_total[$__range]))", + "legendFormat": "", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 11, + "w": 14, + "x": 0, + "y": 22 + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "decimals": 0 + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "verified" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "green" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "spoofed" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "red" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "unknown" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "yellow" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "proxied" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "blue" + } + } + ] + } + ] + }, + "options": { + "showHeader": true, + "sortBy": [ + { + "displayName": "verified", + "desc": true + } + ], + "cellHeight": "sm" + }, + "transformations": [ + { + "id": "labelsToFields", + "options": {} + }, + { + "id": "groupingToMatrix", + "options": { + "columnField": "verdict", + "rowField": "bot", + "valueField": "Value" + } + }, + { + "id": "organize", + "options": { + "renameByName": { + "bot\\verdict": "bot" + } + } + } + ] + }, + { + "type": "bargauge", + "title": "Bandwidth to verified AI crawlers (time range)", + "id": 11, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sort_desc(sum by (vendor) (increase(crawler_ai_verified_bytes_total[$__range])))", + "legendFormat": "{{vendor}}", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 11, + "w": 10, + "x": 14, + "y": 22 + }, + "fieldConfig": { + "defaults": { + "unit": "bytes", + "color": { + "mode": "continuous-BlPu" + }, + "min": 0 + }, + "overrides": [] + }, + "options": { + "displayMode": "gradient", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "values": false + }, + "showUnfilled": true + } + } + ] +} diff --git a/nixos/hosts/asxpio-ops/monitoring/dashboards/Services/postgres.json b/nixos/hosts/asxpio-ops/monitoring/dashboards/Services/postgres.json new file mode 100644 index 0000000..d54663d --- /dev/null +++ b/nixos/hosts/asxpio-ops/monitoring/dashboards/Services/postgres.json @@ -0,0 +1,3131 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "This dashboard works with postgres_exporter for prometheus", + "editable": true, + "gnetId": 9628, + "graphTooltip": 0, + "id": null, + "iteration": 1568751813814, + "links": [], + "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 34, + "panels": [], + "title": "General Counters, CPU, Memory and File Descriptor Stats", + "type": "row" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#299c46", + "#7eb26d", + "#d44a3a" + ], + "datasource": "prometheus", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 0, + "y": 1 + }, + "id": 36, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "pg_static{release=\"$release\", instance=\"$instance\"}", + "format": "time_series", + "instant": true, + "intervalFactor": 1, + "legendFormat": "{{short_version}}", + "refId": "A" + } + ], + "thresholds": "", + "title": "Version", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "name" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "prometheus", + "description": "start time of the process", + "format": "dateTimeFromNow", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 4, + "y": 1 + }, + "id": 28, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "110%", + "prefix": "", + "prefixFontSize": "110%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "pg_postmaster_start_time_seconds{release=\"$release\", instance=\"$instance\"} * 1000", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "", + "title": "Start Time", + "type": "singlestat", + "valueFontSize": "70%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": "prometheus", + "format": "decbytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 8, + "y": 1 + }, + "height": "200px", + "id": 10, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "SUM(pg_stat_database_tup_fetched{datname=~\"$datname\", instance=~\"$instance\"})", + "format": "time_series", + "intervalFactor": 2, + "refId": "A", + "step": 4 + } + ], + "thresholds": "", + "title": "Current fetch data", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": "prometheus", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 12, + "y": 1 + }, + "height": "200px", + "id": 11, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "SUM(pg_stat_database_tup_inserted{release=\"$release\", datname=~\"$datname\", instance=~\"$instance\"})", + "format": "time_series", + "intervalFactor": 2, + "refId": "A", + "step": 4 + } + ], + "thresholds": "", + "title": "Current insert data", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": "prometheus", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 16, + "y": 1 + }, + "height": "200px", + "id": 12, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "SUM(pg_stat_database_tup_updated{datname=~\"$datname\", instance=~\"$instance\"})", + "format": "time_series", + "intervalFactor": 2, + "refId": "A", + "step": 4 + } + ], + "thresholds": "", + "title": "Current update data", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "prometheus", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 20, + "y": 1 + }, + "id": 38, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "pg_settings_max_connections{release=\"$release\", instance=\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Max Connections", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "description": "Average user and system CPU time spent in seconds.", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 3 + }, + "id": 22, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "avg(rate(process_cpu_seconds_total{release=\"$release\", instance=\"$instance\"}[5m]) * 1000)", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "CPU Time", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Average CPU Usage", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "s", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "description": "Virtual and Resident memory size in bytes, averages over 5 min interval", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 8, + "x": 8, + "y": 3 + }, + "id": 24, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "avg(rate(process_resident_memory_bytes{release=\"$release\", instance=\"$instance\"}[5m]))", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "Resident Mem", + "refId": "A" + }, + { + "expr": "avg(rate(process_virtual_memory_bytes{release=\"$release\", instance=\"$instance\"}[5m]))", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "Virtual Mem", + "refId": "B" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Average Memory Usage", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "decbytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "description": "Number of open file descriptors", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 8, + "x": 16, + "y": 3 + }, + "id": 26, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "process_open_fds{release=\"$release\", instance=\"$instance\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "Open FD", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Open File Descriptors", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 10 + }, + "id": 32, + "panels": [], + "title": "Settings", + "type": "row" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "prometheus", + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 0, + "y": 11 + }, + "id": 40, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "pg_settings_shared_buffers_bytes{instance=\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Shared Buffers", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "prometheus", + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 3, + "y": 11 + }, + "id": 42, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "pg_settings_effective_cache_size_bytes{instance=\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Effective Cache", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "prometheus", + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 6, + "y": 11 + }, + "id": 44, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "pg_settings_maintenance_work_mem_bytes{instance=\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Maintenance Work Mem", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "prometheus", + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 9, + "y": 11 + }, + "id": 46, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "pg_settings_work_mem_bytes{instance=\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "", + "title": "Work Mem", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "prometheus", + "decimals": 1, + "format": "bytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 12, + "y": 11 + }, + "id": 48, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "pg_settings_max_wal_size_bytes{instance=\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Max WAL Size", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "prometheus", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 15, + "y": 11 + }, + "id": 50, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "pg_settings_random_page_cost{instance=\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Random Page Cost", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "prometheus", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 2, + "x": 18, + "y": 11 + }, + "id": 52, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "pg_settings_seq_page_cost{instance=\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Seq Page Cost", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "prometheus", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 2, + "x": 20, + "y": 11 + }, + "id": 54, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "pg_settings_max_worker_processes{instance=\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Max Worker Processes", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "prometheus", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 2, + "x": 22, + "y": 11 + }, + "id": 56, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "pg_settings_max_parallel_workers{instance=\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Max Parallel Workers", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 14 + }, + "id": 30, + "panels": [], + "title": "Database Stats", + "type": "row" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 15 + }, + "id": 1, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": false, + "rightSide": true, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": false, + "linewidth": 1, + "links": [], + "nullPointMode": "connected", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 3, + "points": true, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "pg_stat_activity_count{datname=~\"$datname\", instance=~\"$instance\", state=\"active\"} !=0", + "format": "time_series", + "interval": "", + "intervalFactor": 2, + "legendFormat": "{{datname}}, s: {{state}}", + "refId": "A", + "step": 2 + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Active sessions", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "none", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 8, + "x": 8, + "y": 15 + }, + "id": 60, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": true, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "irate(pg_stat_database_xact_commit{instance=\"$instance\", datname=~\"$datname\"}[5m])", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{datname}} commits", + "refId": "A" + }, + { + "expr": "irate(pg_stat_database_xact_rollback{instance=\"$instance\", datname=~\"$datname\"}[5m])", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{datname}} rollbacks", + "refId": "B" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Transactions", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 8, + "x": 16, + "y": 15 + }, + "id": 8, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sideWidth": null, + "sort": "current", + "sortDesc": true, + "total": true, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "pg_stat_database_tup_updated{datname=~\"$datname\", instance=~\"$instance\"} != 0", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{datname}}", + "refId": "A", + "step": 2 + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Update data", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 22 + }, + "id": 5, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sort": "current", + "sortDesc": true, + "total": true, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "pg_stat_database_tup_fetched{datname=~\"$datname\", instance=~\"$instance\"} != 0", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{datname}}", + "refId": "A", + "step": 2 + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Fetch data (SELECT)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 8, + "x": 8, + "y": 22 + }, + "id": 6, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sort": "current", + "sortDesc": true, + "total": true, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "pg_stat_database_tup_inserted{datname=~\"$datname\", instance=~\"$instance\"} != 0", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{datname}}", + "refId": "A", + "step": 2 + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Insert data", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "decimals": 0, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 8, + "x": 16, + "y": 22 + }, + "id": 3, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "hideEmpty": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sort": "current", + "sortDesc": true, + "total": true, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "pg_locks_count{datname=~\"$datname\", instance=~\"$instance\", mode=~\"$mode\"} != 0", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{datname}},{{mode}}", + "refId": "A", + "step": 2 + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Lock tables", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 29 + }, + "id": 14, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sort": "total", + "sortDesc": true, + "total": true, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "pg_stat_database_tup_returned{datname=~\"$datname\", instance=~\"$instance\"} != 0", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{datname}}", + "refId": "A", + "step": 2 + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Return data", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 8, + "x": 8, + "y": 29 + }, + "id": 4, + "legend": { + "alignAsTable": true, + "avg": false, + "current": true, + "max": true, + "min": false, + "rightSide": true, + "show": true, + "sort": "current", + "sortDesc": false, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "pg_stat_activity_count{datname=~\"$datname\", instance=~\"$instance\", state=~\"idle|idle in transaction|idle in transaction (aborted)\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{datname}}, s: {{state}}", + "refId": "A", + "step": 2 + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Idle sessions", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 8, + "x": 16, + "y": 29 + }, + "id": 7, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sort": "current", + "sortDesc": true, + "total": true, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "pg_stat_database_tup_deleted{datname=~\"$datname\", instance=~\"$instance\"} != 0", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{datname}}", + "refId": "A", + "step": 2 + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Delete data", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "decimals": 2, + "fill": 1, + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 36 + }, + "id": 62, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": {}, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "pg_stat_database_blks_hit{instance=\"$instance\", datname=~\"$datname\"} / (pg_stat_database_blks_read{instance=\"$instance\", datname=~\"$datname\"} + pg_stat_database_blks_hit{instance=\"$instance\", datname=~\"$datname\"})", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{ datname }}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Cache Hit Rate", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 4, + "format": "percentunit", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "fill": 1, + "gridPos": { + "h": 7, + "w": 8, + "x": 8, + "y": 36 + }, + "id": 64, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": {}, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "irate(pg_stat_bgwriter_buffers_backend_total{instance=\"$instance\"}[5m])", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "buffers_backend", + "refId": "A" + }, + { + "expr": "irate(pg_stat_bgwriter_buffers_alloc_total{instance=\"$instance\"}[5m])", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "buffers_alloc", + "refId": "B" + }, + { + "expr": "irate(pg_stat_bgwriter_buffers_backend_fsync_total{instance=\"$instance\"}[5m])", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "backend_fsync", + "refId": "C" + }, + { + "expr": "irate(pg_stat_bgwriter_buffers_checkpoint_total{instance=\"$instance\"}[5m])", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "buffers_checkpoint", + "refId": "D" + }, + { + "expr": "irate(pg_stat_bgwriter_buffers_clean_total{instance=\"$instance\"}[5m])", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "buffers_clean", + "refId": "E" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Buffers (bgwriter)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "decimals": 0, + "fill": 1, + "gridPos": { + "h": 7, + "w": 8, + "x": 16, + "y": 36 + }, + "id": 66, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": true, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": {}, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "irate(pg_stat_database_conflicts{instance=\"$instance\", datname=~\"$datname\"}[5m])", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{datname}} conflicts", + "refId": "B" + }, + { + "expr": "irate(pg_stat_database_deadlocks{instance=\"$instance\", datname=~\"$datname\"}[5m])", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{datname}} deadlocks", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Conflicts/Deadlocks", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "description": "Total amount of data written to temporary files by queries in this database. All temporary files are counted, regardless of why the temporary file was created, and regardless of the log_temp_files setting.", + "fill": 1, + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 43 + }, + "id": 68, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": true, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": {}, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "irate(pg_stat_database_temp_bytes{instance=\"$instance\", datname=~\"$datname\"}[5m])", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{datname}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Temp File (Bytes)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "bytes", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "prometheus", + "fill": 1, + "gridPos": { + "h": 7, + "w": 16, + "x": 8, + "y": 43 + }, + "id": 70, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": {}, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "irate(pg_stat_bgwriter_checkpoint_write_time_total{instance=\"$instance\"}[5m])", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "write_time - Total amount of time that has been spent in the portion of checkpoint processing where files are written to disk.", + "refId": "B" + }, + { + "expr": "irate(pg_stat_bgwriter_checkpoint_sync_time_total{instance=\"$instance\"}[5m])", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "sync_time - Total amount of time that has been spent in the portion of checkpoint processing where files are synchronized to disk.", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Checkpoint Stats", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": "10s", + "schemaVersion": 19, + "style": "dark", + "tags": [ + "postgres", + "db", + "stats" + ], + "templating": { + "list": [ + { + "hide": 0, + "label": "datasource", + "name": "DS_PROMETHEUS", + "options": [], + "query": "prometheus", + "refresh": 1, + "regex": "", + "type": "datasource" + }, + { + "auto": true, + "auto_count": 200, + "auto_min": "1s", + "current": { + "text": "auto", + "value": "$__auto_interval_interval" + }, + "hide": 0, + "label": "Interval", + "name": "interval", + "options": [ + { + "selected": true, + "text": "auto", + "value": "$__auto_interval_interval" + }, + { + "selected": false, + "text": "1s", + "value": "1s" + }, + { + "selected": false, + "text": "5s", + "value": "5s" + }, + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": false, + "text": "5m", + "value": "5m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + } + ], + "query": "1s,5s,1m,5m,1h,6h,1d", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + }, + { + "allValue": null, + "current": {}, + "datasource": "prometheus", + "definition": "", + "hide": 0, + "includeAll": false, + "label": "Namespace", + "multi": false, + "name": "namespace", + "options": [], + "query": "query_result(pg_exporter_last_scrape_duration_seconds)", + "refresh": 2, + "regex": "/.*kubernetes_namespace=\"([^\"]+).*/", + "skipUrlSync": false, + "sort": 1, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "prometheus", + "definition": "", + "hide": 0, + "includeAll": false, + "label": "Release", + "multi": false, + "name": "release", + "options": [], + "query": "query_result(pg_exporter_last_scrape_duration_seconds{kubernetes_namespace=\"$namespace\"})", + "refresh": 2, + "regex": "/.*release=\"([^\"]+)/", + "skipUrlSync": false, + "sort": 1, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "prometheus", + "definition": "", + "hide": 0, + "includeAll": false, + "label": "Instance", + "multi": false, + "name": "instance", + "options": [], + "query": "query_result(pg_up{release=\"$release\"})", + "refresh": 1, + "regex": "/.*instance=\"([^\"]+).*/", + "skipUrlSync": false, + "sort": 1, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "prometheus", + "definition": "", + "hide": 0, + "includeAll": true, + "label": "Database", + "multi": true, + "name": "datname", + "options": [], + "query": "label_values(datname)", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 1, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "prometheus", + "definition": "", + "hide": 0, + "includeAll": true, + "label": "Lock table", + "multi": true, + "name": "mode", + "options": [], + "query": "label_values({mode=~\"accessexclusivelock|accesssharelock|exclusivelock|rowexclusivelock|rowsharelock|sharelock|sharerowexclusivelock|shareupdateexclusivelock\"}, mode)", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "", + "title": "PostgreSQL Database", + "uid": "gnet-9628", + "version": 1 +} \ No newline at end of file diff --git a/nixos/hosts/asxpio-ops/monitoring/dashboards/Services/probes.json b/nixos/hosts/asxpio-ops/monitoring/dashboards/Services/probes.json new file mode 100644 index 0000000..5b13374 --- /dev/null +++ b/nixos/hosts/asxpio-ops/monitoring/dashboards/Services/probes.json @@ -0,0 +1,1071 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "Prometheus Blackbox Exporter Overview", + "editable": true, + "gnetId": 7587, + "graphTooltip": 0, + "id": null, + "iteration": 1534695504413, + "links": [], + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_SIGNCL-PROMETHEUS}", + "fill": 1, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 138, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "probe_duration_seconds{instance=~\"$target\"}", + "format": "time_series", + "interval": "$interval", + "intervalFactor": 1, + "legendFormat": "{{ instance }}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Global Probe Duration", + "tooltip": { + "shared": true, + "sort": 1, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "s", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 8 + }, + "id": 15, + "panels": [], + "repeat": "target", + "title": "$target status", + "type": "row" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#d44a3a", + "rgba(237, 129, 40, 0.89)", + "#299c46" + ], + "datasource": "${DS_SIGNCL-PROMETHEUS}", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 0, + "y": 9 + }, + "id": 2, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "minSpan": 3, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "repeat": null, + "repeatDirection": "v", + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "probe_success{instance=~\"$target\"}", + "format": "time_series", + "interval": "$interval", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "1,1", + "title": "Status", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + }, + { + "op": "=", + "text": "UP", + "value": "1" + }, + { + "op": "=", + "text": "DOWN", + "value": "0" + } + ], + "valueName": "current" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_SIGNCL-PROMETHEUS}", + "fill": 1, + "gridPos": { + "h": 6, + "w": 10, + "x": 4, + "y": 9 + }, + "id": 25, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "probe_http_duration_seconds{instance=~\"$target\"}", + "format": "time_series", + "interval": "$interval", + "intervalFactor": 1, + "legendFormat": "{{ phase }}", + "refId": "B" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "HTTP Duration", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "s", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_SIGNCL-PROMETHEUS}", + "fill": 1, + "gridPos": { + "h": 6, + "w": 10, + "x": 14, + "y": 9 + }, + "id": 17, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "repeat": null, + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "probe_duration_seconds{instance=~\"$target\"}", + "format": "time_series", + "interval": "$interval", + "intervalFactor": 1, + "legendFormat": "seconds", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Probe Duration", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "s", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "${DS_SIGNCL-PROMETHEUS}", + "decimals": 0, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 0, + "y": 11 + }, + "id": 20, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "minSpan": 3, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "repeat": null, + "repeatDirection": "h", + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "probe_http_status_code{instance=~\"$target\"}", + "format": "time_series", + "interval": "$interval", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "201, 399", + "title": "HTTP Status Code", + "transparent": false, + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + }, + { + "op": "=", + "text": "YES", + "value": "1" + }, + { + "op": "=", + "text": "N/A", + "value": "0" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "${DS_SIGNCL-PROMETHEUS}", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 0, + "y": 13 + }, + "id": 27, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "probe_http_version{instance=~\"$target\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "HTTP Version", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#d44a3a", + "rgba(237, 129, 40, 0.89)", + "#299c46" + ], + "datasource": "${DS_SIGNCL-PROMETHEUS}", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 4, + "x": 0, + "y": 15 + }, + "id": 18, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "minSpan": 3, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "repeat": null, + "repeatDirection": "v", + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "probe_http_ssl{instance=~\"$target\"}", + "format": "time_series", + "interval": "$interval", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "0, 1", + "title": "SSL", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + }, + { + "op": "=", + "text": "YES", + "value": "1" + }, + { + "op": "=", + "text": "NO", + "value": "0" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#d44a3a", + "rgba(237, 129, 40, 0.89)", + "#299c46" + ], + "datasource": "${DS_SIGNCL-PROMETHEUS}", + "decimals": 2, + "format": "dtdurations", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 10, + "x": 4, + "y": 15 + }, + "id": 19, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "minSpan": 3, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "repeat": null, + "repeatDirection": "h", + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "probe_ssl_earliest_cert_expiry{instance=~\"$target\"} - time()", + "format": "time_series", + "interval": "$interval", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "0,1209600", + "timeFrom": null, + "title": "SSL Expiry", + "transparent": false, + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + }, + { + "op": "=", + "text": "YES", + "value": "1" + }, + { + "op": "=", + "text": "NO", + "value": "0" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "${DS_SIGNCL-PROMETHEUS}", + "format": "s", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 5, + "x": 14, + "y": 15 + }, + "id": 23, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "repeat": null, + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "avg(probe_duration_seconds{instance=~\"$target\"})", + "format": "time_series", + "interval": "$interval", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Average Probe Duration", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "${DS_SIGNCL-PROMETHEUS}", + "format": "s", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 2, + "w": 5, + "x": 19, + "y": 15 + }, + "id": 24, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "repeat": null, + "repeatDirection": "h", + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "avg(probe_dns_lookup_time_seconds{instance=~\"$target\"})", + "format": "time_series", + "interval": "$interval", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Average DNS Lookup", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + } + ], + "refresh": "10s", + "schemaVersion": 16, + "style": "dark", + "tags": [ + "blackbox", + "prometheus" + ], + "templating": { + "list": [ + { + "auto": true, + "auto_count": 10, + "auto_min": "10s", + "current": { + "text": "10s", + "value": "10s" + }, + "hide": 0, + "label": "Interval", + "name": "interval", + "options": [ + { + "selected": false, + "text": "auto", + "value": "$__auto_interval_interval" + }, + { + "selected": false, + "text": "5s", + "value": "5s" + }, + { + "selected": true, + "text": "10s", + "value": "10s" + }, + { + "selected": false, + "text": "30s", + "value": "30s" + }, + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": false, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "6h", + "value": "6h" + }, + { + "selected": false, + "text": "12h", + "value": "12h" + }, + { + "selected": false, + "text": "1d", + "value": "1d" + }, + { + "selected": false, + "text": "7d", + "value": "7d" + }, + { + "selected": false, + "text": "14d", + "value": "14d" + }, + { + "selected": false, + "text": "30d", + "value": "30d" + } + ], + "query": "5s,10s,30s,1m,10m,30m,1h,6h,12h,1d,7d,14d,30d", + "refresh": 2, + "type": "interval" + }, + { + "allValue": null, + "current": {}, + "datasource": "${DS_SIGNCL-PROMETHEUS}", + "hide": 0, + "includeAll": true, + "label": null, + "multi": true, + "name": "target", + "options": [], + "query": "label_values(probe_success, instance)", + "refresh": 1, + "regex": "", + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "", + "title": "Prometheus Blackbox Exporter", + "uid": "gnet-7587", + "version": 2 +} \ No newline at end of file diff --git a/nixos/hosts/asxpio-ops/monitoring/dashboards/Services/traefik.json b/nixos/hosts/asxpio-ops/monitoring/dashboards/Services/traefik.json new file mode 100644 index 0000000..bde2f2a --- /dev/null +++ b/nixos/hosts/asxpio-ops/monitoring/dashboards/Services/traefik.json @@ -0,0 +1,1527 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "description": "Official dashboard for Standalone Traefik", + "editable": false, + "fiscalYearStartMonth": 0, + "gnetId": 17346, + "graphTooltip": 0, + "id": null, + "links": [], + "liveNow": false, + "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 9, + "panels": [], + "title": "General", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 5, + "x": 0, + "y": 1 + }, + "id": 13, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.3.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "count(traefik_config_reloads_total)", + "legendFormat": "__auto", + "range": true, + "refId": "A" + } + ], + "title": "Traefik Instances", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "reqps" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 7, + "x": 5, + "y": 1 + }, + "id": 7, + "options": { + "legend": { + "calcs": [ + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "sum(rate(traefik_entrypoint_requests_total{entrypoint=~\"$entrypoint\"}[$interval])) by (entrypoint)", + "legendFormat": "{{entrypoint}}", + "range": true, + "refId": "A" + } + ], + "title": "Requests per Entrypoint", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "description": "https://medium.com/@tristan_96324/prometheus-apdex-alerting-d17a065e39d0", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 1 + }, + "id": 6, + "options": { + "legend": { + "calcs": [ + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "(sum(rate(traefik_entrypoint_request_duration_seconds_bucket{le=\"0.3\",code=\"200\",entrypoint=~\"$entrypoint\"}[$interval])) by (method) + \n sum(rate(traefik_entrypoint_request_duration_seconds_bucket{le=\"1.2\",code=\"200\",entrypoint=~\"$entrypoint\"}[$interval])) by (method)) / 2 / \n sum(rate(traefik_entrypoint_request_duration_seconds_count{code=\"200\",entrypoint=~\"$entrypoint\"}[$interval])) by (method)\n", + "legendFormat": "{{method}}", + "range": true, + "refId": "A" + } + ], + "title": "Apdex score", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "description": "Mean Distribution", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + } + }, + "mappings": [], + "unit": "reqps" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 5, + "x": 0, + "y": 3 + }, + "id": 14, + "options": { + "legend": { + "displayMode": "list", + "placement": "right", + "showLegend": true, + "values": [ + "percent" + ] + }, + "pieType": "pie", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "tooltip": { + "mode": "multi", + "sort": "asc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "sum(rate(traefik_service_requests_total{service=~\"$service.*\",protocol=\"http\"}[$interval])) by (method, code)", + "legendFormat": "{{method}}[{{code}}]", + "range": true, + "refId": "A" + } + ], + "title": "Http Code ", + "type": "piechart" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 9 + }, + "id": 23, + "options": { + "legend": { + "calcs": [ + "mean", + "max" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "topk(15,\n label_replace(\n traefik_service_request_duration_seconds_sum{service=~\"$service.*\",protocol=\"http\"} / \n traefik_service_request_duration_seconds_count{service=~\"$service.*\",protocol=\"http\"},\n \"service\", \"$1\", \"service\", \"([^-]+-[^-]+).*\")\n)\n\n", + "legendFormat": "{{method}}[{{code}}] on {{service}}", + "range": true, + "refId": "A" + } + ], + "title": "Top slow services", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "reqps" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 9 + }, + "id": 5, + "options": { + "legend": { + "calcs": [ + "mean", + "max" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "topk(15,\n label_replace(\n sum by (service,code) \n (rate(traefik_service_requests_total{service=~\"$service.*\",protocol=\"http\"}[$interval])) > 0,\n \"service\", \"$1\", \"service\", \"([^-]+-[^-]+).*\")\n)", + "legendFormat": "[{{code}}] on {{service}}", + "range": true, + "refId": "A" + } + ], + "title": "Most requested services", + "type": "timeseries" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 17 + }, + "id": 11, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 18 + }, + "id": 3, + "options": { + "legend": { + "calcs": [ + "mean", + "max" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "label_replace(\n 1 - (sum by (service)\n (rate(traefik_service_request_duration_seconds_bucket{le=\"1.2\",service=~\"$service.*\"}[$interval])) / sum by (service) \n (rate(traefik_service_request_duration_seconds_count{service=~\"$service.*\"}[$interval]))\n ) > 0,\n \"service\", \"$1\", \"service\", \"([^-]+-[^-]+).*\"\n)", + "legendFormat": "{{service}}", + "range": true, + "refId": "A" + } + ], + "title": "Services failing SLO of 1200ms", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 18 + }, + "id": 4, + "options": { + "legend": { + "calcs": [ + "mean", + "max" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "label_replace(\n 1 - (sum by (service)\n (rate(traefik_service_request_duration_seconds_bucket{le=\"0.3\",service=~\"$service.*\"}[$interval])) / sum by (service) \n (rate(traefik_service_request_duration_seconds_count{service=~\"$service.*\"}[$interval]))\n ) > 0,\n \"service\", \"$1\", \"service\", \"([^-]+-[^-]+).*\"\n)", + "legendFormat": "{{service}}", + "range": true, + "refId": "A" + } + ], + "title": "Services failing SLO of 300ms", + "type": "timeseries" + } + ], + "title": "SLO", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 18 + }, + "id": 16, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "reqps" + }, + "overrides": [] + }, + "gridPos": { + "h": 12, + "w": 8, + "x": 0, + "y": 19 + }, + "id": 17, + "options": { + "legend": { + "calcs": [ + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "topk(15,\n label_replace(\n sum by (service,method,code) \n (rate(traefik_service_requests_total{service=~\"$service.*\",code=~\"2..\",protocol=\"http\"}[$interval])) > 0,\n \"service\", \"$1\", \"service\", \"([^-]+-[^-]+).*\")\n)", + "legendFormat": "{{method}}[{{code}}] on {{service}}", + "range": true, + "refId": "A" + } + ], + "title": "2xx over $interval", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "reqps" + }, + "overrides": [] + }, + "gridPos": { + "h": 12, + "w": 8, + "x": 8, + "y": 19 + }, + "id": 18, + "options": { + "legend": { + "calcs": [ + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "topk(15,\n label_replace(\n sum by (service,method,code) \n (rate(traefik_service_requests_total{service=~\"$service.*\",code=~\"5..\",protocol=\"http\"}[$interval])) > 0,\n \"service\", \"$1\", \"service\", \"([^-]+-[^-]+).*\")\n)", + "legendFormat": "{{method}}[{{code}}] on {{service}}", + "range": true, + "refId": "A" + } + ], + "title": "5xx over $interval", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "reqps" + }, + "overrides": [] + }, + "gridPos": { + "h": 12, + "w": 8, + "x": 16, + "y": 19 + }, + "id": 19, + "options": { + "legend": { + "calcs": [ + "mean", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "topk(15,\n label_replace(\n sum by (service,method,code) \n (rate(traefik_service_requests_total{service=~\"$service.*\",code!~\"2..|5..\",protocol=\"http\"}[$interval])) > 0,\n \"service\", \"$1\", \"service\", \"([^-]+-[^-]+).*\")\n)", + "legendFormat": "{{method}}[{{code}}] on {{service}}", + "range": true, + "refId": "A" + } + ], + "title": "Other codes over $interval", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "binBps" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 31 + }, + "id": 20, + "options": { + "legend": { + "calcs": [ + "mean", + "max" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "topk(15,\n label_replace(\n sum by (service,method) \n (rate(traefik_service_requests_bytes_total{service=~\"$service.*\",protocol=\"http\"}[$interval])) > 0,\n \"service\", \"$1\", \"service\", \"([^-]+-[^-]+).*\")\n)", + "legendFormat": "{{method}} on {{service}}", + "range": true, + "refId": "A" + } + ], + "title": "Requests Size", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "binBps" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 31 + }, + "id": 24, + "options": { + "legend": { + "calcs": [ + "mean", + "max" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "topk(15,\n label_replace(\n sum by (service,method) \n (rate(traefik_service_responses_bytes_total{service=~\"$service.*\",protocol=\"http\"}[$interval])) > 0,\n \"service\", \"$1\", \"service\", \"([^-]+-[^-]+).*\")\n)", + "legendFormat": "{{method}} on {{service}}", + "range": true, + "refId": "A" + } + ], + "title": "Responses Size", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 39 + }, + "id": 21, + "options": { + "legend": { + "calcs": [ + "mean", + "max" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "editorMode": "code", + "expr": "sum(traefik_open_connections{entrypoint=~\"$entrypoint\"}) by (entrypoint)\n", + "legendFormat": "{{entrypoint}}", + "range": true, + "refId": "A" + } + ], + "title": "Connections per Entrypoint", + "type": "timeseries" + } + ], + "title": "HTTP Details", + "type": "row" + } + ], + "refresh": false, + "schemaVersion": 37, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "current": { + "selected": false, + "text": "Prometheus", + "value": "Prometheus" + }, + "hide": 0, + "includeAll": false, + "multi": false, + "name": "DS_PROMETHEUS", + "label": "datasource", + "options": [], + "query": "prometheus", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "type": "datasource" + }, + { + "auto": true, + "auto_count": 30, + "auto_min": "1m", + "current": { + "selected": false, + "text": "auto", + "value": "$__auto_interval_interval" + }, + "hide": 0, + "name": "interval", + "options": [ + { + "selected": true, + "text": "auto", + "value": "$__auto_interval_interval" + }, + { + "selected": false, + "text": "1m", + "value": "1m" + }, + { + "selected": false, + "text": "5m", + "value": "5m" + }, + { + "selected": false, + "text": "10m", + "value": "10m" + }, + { + "selected": false, + "text": "30m", + "value": "30m" + }, + { + "selected": false, + "text": "1h", + "value": "1h" + }, + { + "selected": false, + "text": "2h", + "value": "2h" + }, + { + "selected": false, + "text": "4h", + "value": "4h" + }, + { + "selected": false, + "text": "8h", + "value": "8h" + } + ], + "query": "1m,5m,10m,30m,1h,2h,4h,8h", + "refresh": 2, + "skipUrlSync": false, + "type": "interval" + }, + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "definition": "label_values(traefik_open_connections, entrypoint)", + "hide": 0, + "includeAll": true, + "multi": false, + "name": "entrypoint", + "options": [], + "query": { + "query": "label_values(traefik_open_connections, entrypoint)", + "refId": "StandardVariableQuery" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "definition": "label_values(traefik_service_requests_total, service)", + "hide": 0, + "includeAll": true, + "multi": false, + "name": "service", + "options": [], + "query": { + "query": "label_values(traefik_service_requests_total, service)", + "refId": "StandardVariableQuery" + }, + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 1, + "type": "query" + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Traefik Official Standalone Dashboard", + "uid": "gnet-17346", + "version": 7, + "weekStart": "" +} \ No newline at end of file diff --git a/nixos/hosts/asxpio-ops/monitoring/dashboards/overview.json b/nixos/hosts/asxpio-ops/monitoring/dashboards/overview.json new file mode 100644 index 0000000..29758ec --- /dev/null +++ b/nixos/hosts/asxpio-ops/monitoring/dashboards/overview.json @@ -0,0 +1,2077 @@ +{ + "uid": "asxpio-overview", + "title": "asxpio overview", + "tags": [ + "asxpio" + ], + "timezone": "browser", + "editable": false, + "refresh": "1m", + "time": { + "from": "now-6h", + "to": "now" + }, + "schemaVersion": 39, + "panels": [ + { + "type": "row", + "title": "Status", + "id": 1, + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "panels": [] + }, + { + "type": "stat", + "title": "Services (outside-in)", + "id": 2, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "probe_success", + "legendFormat": "{{probe}}", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 7, + "w": 16, + "x": 0, + "y": 1 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 1 + } + ] + }, + "mappings": [ + { + "type": "value", + "options": { + "0": { + "text": "DOWN", + "color": "red" + }, + "1": { + "text": "UP", + "color": "green" + } + } + } + ] + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "background", + "graphMode": "none", + "textMode": "value_and_name", + "justifyMode": "center", + "orientation": "auto", + "text": { + "titleSize": 12, + "valueSize": 16 + } + }, + "description": "blackbox_exporter probes from asxpio-ops: HTTPS sites, XMPP, TURN, Xray, Minecraft, SillyTavern" + }, + { + "type": "bargauge", + "title": "Certificates: days left", + "id": 3, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "(probe_ssl_earliest_cert_expiry - time()) / 86400", + "legendFormat": "{{probe}}", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 7, + "w": 8, + "x": 16, + "y": 1 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "unit": "d", + "decimals": 0, + "min": 0, + "max": 90, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "orange", + "value": 14 + }, + { + "color": "green", + "value": 30 + } + ] + } + }, + "overrides": [] + }, + "options": { + "displayMode": "basic", + "orientation": "horizontal", + "showUnfilled": true, + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "values": false + }, + "minVizHeight": 10 + } + }, + { + "type": "row", + "title": "Hosts", + "id": 4, + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 8 + }, + "panels": [] + }, + { + "type": "gauge", + "title": "CPU", + "id": 5, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "100 - avg by (host) (rate(node_cpu_seconds_total{mode=\"idle\"}[5m])) * 100", + "legendFormat": "{{host}}", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 6, + "w": 4, + "x": 0, + "y": 9 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "unit": "percent", + "decimals": 0, + "min": 0, + "max": 100, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 75 + }, + { + "color": "red", + "value": 90 + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "values": false + }, + "showThresholdMarkers": true + } + }, + { + "type": "gauge", + "title": "Memory", + "id": 6, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "100 * (1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)", + "legendFormat": "{{host}}", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 6, + "w": 4, + "x": 4, + "y": 9 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "unit": "percent", + "decimals": 0, + "min": 0, + "max": 100, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 75 + }, + { + "color": "red", + "value": 90 + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "values": false + }, + "showThresholdMarkers": true + } + }, + { + "type": "gauge", + "title": "Disk /", + "id": 7, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "100 * (1 - node_filesystem_avail_bytes{mountpoint=\"/\"} / node_filesystem_size_bytes{mountpoint=\"/\"})", + "legendFormat": "{{host}}", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 6, + "w": 4, + "x": 8, + "y": 9 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "unit": "percent", + "decimals": 0, + "min": 0, + "max": 100, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 75 + }, + { + "color": "red", + "value": 90 + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "values": false + }, + "showThresholdMarkers": true + } + }, + { + "type": "gauge", + "title": "Load (1m) per CPU", + "id": 8, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum by (host) (node_load1) / count by (host) (node_cpu_seconds_total{mode=\"idle\"})", + "legendFormat": "{{host}}", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 6, + "w": 4, + "x": 12, + "y": 9 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "unit": "percentunit", + "decimals": 0, + "min": 0, + "max": 2, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 0.8 + }, + { + "color": "red", + "value": 1.2 + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "values": false + }, + "showThresholdMarkers": true + } + }, + { + "type": "stat", + "title": "Uptime", + "id": 9, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "time() - node_boot_time_seconds", + "legendFormat": "{{host}}", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 6, + "w": 4, + "x": 16, + "y": 9 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "unit": "s", + "decimals": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "blue", + "value": null + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "value", + "graphMode": "none", + "textMode": "value_and_name", + "justifyMode": "center", + "orientation": "auto" + } + }, + { + "type": "stat", + "title": "Swap used", + "id": 10, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "node_memory_SwapTotal_bytes - node_memory_SwapFree_bytes", + "legendFormat": "{{host}}", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 6, + "w": 4, + "x": 20, + "y": 9 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "unit": "bytes", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 524288000 + }, + { + "color": "red", + "value": 1572864000 + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "value", + "graphMode": "none", + "textMode": "value_and_name", + "justifyMode": "center", + "orientation": "auto" + } + }, + { + "type": "timeseries", + "title": "CPU by host", + "id": 11, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "100 - avg by (host) (rate(node_cpu_seconds_total{mode=\"idle\"}[$__rate_interval])) * 100", + "legendFormat": "{{host}}", + "refId": "A", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 15 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "unit": "percent", + "min": 0, + "max": 100 + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + } + }, + { + "type": "timeseries", + "title": "Memory used by host", + "id": 12, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes", + "legendFormat": "{{host}}", + "refId": "A", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 8, + "w": 8, + "x": 8, + "y": 15 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "unit": "bytes" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + } + }, + { + "type": "timeseries", + "title": "Network by host (in +, out -)", + "id": 13, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum by (host) (rate(node_network_receive_bytes_total{device!~\"lo|veth.*|br-.*|docker.*\"}[$__rate_interval]))", + "legendFormat": "{{host}} in", + "refId": "A", + "instant": false, + "range": true + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "-sum by (host) (rate(node_network_transmit_bytes_total{device!~\"lo|veth.*|br-.*|docker.*\"}[$__rate_interval]))", + "legendFormat": "{{host}} out", + "refId": "B", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 8, + "w": 8, + "x": 16, + "y": 15 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "unit": "Bps" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + } + }, + { + "type": "row", + "title": "Containers", + "id": 14, + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 23 + }, + "panels": [] + }, + { + "type": "bargauge", + "title": "Memory (top 12)", + "id": 15, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "topk(12, container_memory_working_set_bytes{name!=\"\"})", + "legendFormat": "{{host}} · {{name}}", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 10, + "w": 8, + "x": 0, + "y": 24 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "unit": "bytes", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "blue", + "value": null + } + ] + } + }, + "overrides": [] + }, + "options": { + "displayMode": "gradient", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "values": false + }, + "minVizHeight": 10 + } + }, + { + "type": "timeseries", + "title": "CPU (top 8)", + "id": 16, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "topk(8, sum by (host, name) (rate(container_cpu_usage_seconds_total{name!=\"\"}[$__rate_interval])))", + "legendFormat": "{{host}} · {{name}}", + "refId": "A", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 10, + "w": 10, + "x": 8, + "y": 24 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "table", + "placement": "right", + "calcs": [ + "mean", + "max" + ], + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + } + }, + { + "type": "table", + "title": "Restarts (24 h)", + "id": 17, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sort_desc(sum by (host, name) (changes(container_start_time_seconds{name!=\"\"}[24h])) > 0)", + "legendFormat": "", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 10, + "w": 6, + "x": 18, + "y": 24 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 1 + }, + { + "color": "red", + "value": 3 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Value" + }, + "properties": [ + { + "id": "displayName", + "value": "restarts" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Time" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + } + ] + }, + "options": { + "showHeader": true, + "cellHeight": "sm" + } + }, + { + "type": "row", + "title": "Web traffic (Traefik)", + "id": 18, + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 34 + }, + "panels": [] + }, + { + "type": "timeseries", + "title": "Requests by router", + "id": 19, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum by (router) (rate(traefik_router_requests_total[$__rate_interval]))", + "legendFormat": "{{router}}", + "refId": "A", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 35 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "unit": "reqps" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + } + }, + { + "type": "timeseries", + "title": "5xx by router", + "id": 20, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum by (router) (rate(traefik_router_requests_total{code=~\"5..\"}[$__rate_interval]))", + "legendFormat": "{{router}}", + "refId": "A", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 8, + "w": 8, + "x": 8, + "y": 35 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "unit": "reqps" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + } + }, + { + "type": "timeseries", + "title": "Latency p95 by router", + "id": 21, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "histogram_quantile(0.95, sum by (le, router) (rate(traefik_router_request_duration_seconds_bucket[$__rate_interval])))", + "legendFormat": "{{router}}", + "refId": "A", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 8, + "w": 8, + "x": 16, + "y": 35 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "unit": "s" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + } + }, + { + "type": "row", + "title": "Data and backups", + "id": 22, + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 43 + }, + "panels": [] + }, + { + "type": "stat", + "title": "Postgres", + "id": 23, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "pg_up", + "legendFormat": "up", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 6, + "w": 4, + "x": 0, + "y": 44 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 1 + } + ] + }, + "mappings": [ + { + "type": "value", + "options": { + "0": { + "text": "DOWN", + "color": "red" + }, + "1": { + "text": "UP", + "color": "green" + } + } + } + ] + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "background", + "graphMode": "none", + "textMode": "value_and_name", + "justifyMode": "center", + "orientation": "auto" + } + }, + { + "type": "stat", + "title": "asxpio DB size", + "id": 24, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "pg_database_size_bytes{datname=\"asxpio\"}", + "legendFormat": "asxpio", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 6, + "w": 4, + "x": 4, + "y": 44 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "unit": "bytes", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "blue", + "value": null + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "colorMode": "value", + "graphMode": "none", + "textMode": "value_and_name", + "justifyMode": "center", + "orientation": "auto" + } + }, + { + "type": "timeseries", + "title": "Postgres connections", + "id": 25, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum by (datname) (pg_stat_activity_count)", + "legendFormat": "{{datname}}", + "refId": "A", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 6, + "w": 6, + "x": 8, + "y": 44 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + } + }, + { + "type": "bargauge", + "title": "Last good backup / replica (hours ago)", + "id": 26, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "(time() - restic_backup_last_success_timestamp_seconds) / 3600", + "legendFormat": "restic · {{host}} · {{repo}}", + "refId": "A", + "instant": true, + "range": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "(time() - s3_replicate_last_success_timestamp_seconds) / 3600", + "legendFormat": "replica hel1 → fsn1", + "refId": "B", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 6, + "w": 10, + "x": 14, + "y": 44 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "unit": "h", + "decimals": 1, + "min": 0, + "max": 48, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 26 + }, + { + "color": "red", + "value": 48 + } + ] + } + }, + "overrides": [] + }, + "options": { + "displayMode": "basic", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "values": false + }, + "showUnfilled": true + } + }, + { + "type": "row", + "title": "Logs", + "id": 27, + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 50 + }, + "panels": [] + }, + { + "type": "timeseries", + "title": "Log lines by host", + "id": 28, + "datasource": { + "type": "loki", + "uid": "loki" + }, + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "loki" + }, + "expr": "sum by (host) (count_over_time({job=~\"docker|journal\"}[$__interval]))", + "legendFormat": "{{host}}", + "refId": "A", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 51 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + }, + "drawStyle": "bars" + } + }, + { + "type": "logs", + "title": "Errors (all containers)", + "id": 29, + "datasource": { + "type": "loki", + "uid": "loki" + }, + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "loki" + }, + "expr": "{job=\"docker\"} |~ \"(?i)(error|fatal|panic|exception|traceback)\" != \"level=info\"", + "legendFormat": "", + "refId": "A", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 8, + "w": 16, + "x": 8, + "y": 51 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + } + }, + "overrides": [] + }, + "options": { + "showTime": true, + "wrapLogMessage": true, + "sortOrder": "Descending", + "enableLogDetails": true, + "dedupStrategy": "signature" + } + }, + { + "type": "row", + "title": "AI crawlers", + "id": 30, + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 59 + }, + "panels": [] + }, + { + "type": "piechart", + "title": "Who is asking (time range)", + "id": 31, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum(increase(crawler_ai_requests_total{verdict=\"verified\"}[$__range]))", + "legendFormat": "AI · verified", + "refId": "A", + "instant": true, + "range": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum(increase(crawler_ai_requests_total{verdict=\"spoofed\"}[$__range]))", + "legendFormat": "AI · spoofed", + "refId": "B", + "instant": true, + "range": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum(increase(crawler_ai_requests_total{verdict=~\"unknown|proxied|private\"}[$__range]))", + "legendFormat": "AI · unverifiable", + "refId": "C", + "instant": true, + "range": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum(increase(crawler_class_requests_total{class=\"other-bot\"}[$__range]))", + "legendFormat": "other bots", + "refId": "D", + "instant": true, + "range": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum(increase(crawler_class_requests_total{class=\"browser-like\"}[$__range]))", + "legendFormat": "browser-like", + "refId": "E", + "instant": true, + "range": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum(increase(crawler_class_requests_total{class=\"none\"}[$__range]))", + "legendFormat": "no user agent", + "refId": "F", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 8, + "w": 6, + "x": 0, + "y": 60 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "verified" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "green" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "spoofed" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "red" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "proxied" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "blue" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "unknown" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "yellow" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "private" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "purple" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "AI · verified" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "green" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "AI · spoofed" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "red" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "AI · unverifiable" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "yellow" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "other bots" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "orange" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "browser-like" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "purple" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "no user agent" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "text" + } + } + ] + } + ] + }, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "pieType": "donut", + "legend": { + "displayMode": "table", + "placement": "right", + "showLegend": true, + "values": [ + "value", + "percent" + ] + }, + "tooltip": { + "mode": "single" + } + }, + "description": "From the Traefik access log, every router (crawler-alert.py --metrics, 5-minute timer). A request naming an AI bot counts as verified only if its source IP is in the vendor's published ranges, or passes forward-confirmed reverse DNS, or (Meta) sits in the vendor's own ASN. spoofed = the claim failed that check; unverifiable = via Cloudflare, no PTR, or over the DNS budget.", + "links": [ + { + "title": "Crawler details", + "url": "/d/asxpio-crawlers?${__url_time_range}" + } + ] + }, + { + "type": "timeseries", + "title": "AI crawler requests by verdict (per minute)", + "id": 32, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum by (verdict) (rate(crawler_ai_requests_total[$__rate_interval])) * 60", + "legendFormat": "{{verdict}}", + "refId": "A", + "instant": false, + "range": true + } + ], + "gridPos": { + "h": 8, + "w": 9, + "x": 6, + "y": 60 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "unit": "short", + "custom": { + "stacking": { + "mode": "normal" + }, + "fillOpacity": 40, + "lineWidth": 1 + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "verified" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "green" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "spoofed" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "red" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "proxied" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "blue" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "unknown" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "yellow" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "private" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "purple" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "AI · verified" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "green" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "AI · spoofed" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "red" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "AI · unverifiable" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "yellow" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "other bots" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "orange" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "browser-like" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "purple" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "no user agent" + }, + "properties": [ + { + "id": "color", + "value": { + "mode": "fixed", + "fixedColor": "text" + } + } + ] + } + ] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "description": "From the Traefik access log, every router (crawler-alert.py --metrics, 5-minute timer). A request naming an AI bot counts as verified only if its source IP is in the vendor's published ranges, or passes forward-confirmed reverse DNS, or (Meta) sits in the vendor's own ASN. spoofed = the claim failed that check; unverifiable = via Cloudflare, no PTR, or over the DNS budget." + }, + { + "type": "bargauge", + "title": "Verified AI crawlers by vendor (time range)", + "id": 33, + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sort_desc(sum by (vendor) (increase(crawler_ai_requests_total{verdict=\"verified\"}[$__range])))", + "legendFormat": "{{vendor}}", + "refId": "A", + "instant": true, + "range": false + } + ], + "gridPos": { + "h": 8, + "w": 9, + "x": 15, + "y": 60 + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "unit": "short", + "decimals": 0, + "min": 0 + }, + "overrides": [] + }, + "options": { + "displayMode": "gradient", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "values": false + }, + "showUnfilled": true, + "valueMode": "color" + } + } + ], + "graphTooltip": 1, + "links": [ + { + "title": "Dashboards", + "type": "dashboards", + "asDropdown": true, + "includeVars": false, + "keepTime": true, + "tags": [] + } + ] +} diff --git a/nixos/hosts/asxpio-ops/monitoring/default.nix b/nixos/hosts/asxpio-ops/monitoring/default.nix new file mode 100644 index 0000000..d7a3184 --- /dev/null +++ b/nixos/hosts/asxpio-ops/monitoring/default.nix @@ -0,0 +1,465 @@ +# Prometheus, Loki, Grafana and the blackbox prober, for both hosts. +# +# gf.asxp.io Grafana, WireGuard only (through Traefik) +# 10.10.0.10:3100 Loki, where every host's Alloy pushes +# 127.0.0.1:9090 Prometheus +# +# Dashboards (./dashboards) and alert rules (./alert-rules.yaml) are +# provisioned read-only: change them here, not in the UI. +{ + config, + lib, + pkgs, + unstable, + ... +}: +let + hosts = { + asxpio-ops = "10.10.0.10"; + asxpio-services = "10.10.0.20"; + }; + perHost = + port: + lib.mapAttrsToList (name: address: { + targets = [ "${address}:${toString port}" ]; + labels.host = name; + }) hosts; + + probes = [ + { name = "asxp.io"; target = "https://asxp.io/"; module = "http_2xx"; } + { name = "blog"; target = "https://blog.asxp.io/"; module = "http_2xx"; } + { name = "czsk.it"; target = "https://czsk.it/"; module = "http_2xx"; } + { name = "datacenterbingo"; target = "https://datacenterbingo.xyz/"; module = "http_2xx"; } + { name = "datacenterbingo data.json"; target = "https://datacenterbingo.xyz/data.json"; module = "http_2xx"; } + { name = "forgejo"; target = "https://git.asxp.io/"; module = "http_2xx"; } + { name = "s3"; target = "https://s3.asxp.io/"; module = "http_up"; } + { name = "sillytavern"; target = "http://10.20.0.20:8000/"; module = "http_up"; } + { name = "xmpp c2s"; target = "xmpp.asxp.io:5222"; module = "tcp_connect"; } + { name = "xmpp c2s tls"; target = "xmpp.asxp.io:5223"; module = "tls_connect"; } + { name = "xmpp c2s tls asxp.io"; target = "xmpp.asxp.io:5223"; module = "tls_connect_asxpio"; } + { name = "xmpp s2s"; target = "xmpp.asxp.io:5269"; module = "tcp_connect"; } + { name = "turn"; target = "xmpp.asxp.io:3478"; module = "tcp_connect"; } + { name = "xray"; target = "46.62.228.216:443"; module = "tcp_connect"; } + { name = "minecraft"; target = "mc.asxp.io:25565"; module = "tcp_connect"; } + ]; + + blackbox = (pkgs.formats.yaml { }).generate "blackbox.yml" { + modules = + let + tcp = extra: { + prober = "tcp"; + timeout = "10s"; + tcp = { preferred_ip_protocol = "ip4"; } // extra; + }; + in + { + http_2xx = { + prober = "http"; + timeout = "10s"; + http = { + preferred_ip_protocol = "ip4"; + follow_redirects = true; + }; + }; + http_up = { + prober = "http"; + timeout = "10s"; + http = { + preferred_ip_protocol = "ip4"; + valid_status_codes = [ 200 301 302 401 403 404 ]; + }; + }; + tcp_connect = tcp { }; + tls_connect = tcp { tls = true; }; + tls_connect_asxpio = tcp { + tls = true; + tls_config.server_name = "asxp.io"; + }; + }; + }; +in +{ + sops.secrets = { + "monitoring/grafana_admin_password".owner = "grafana"; + "monitoring/hcloud_ro_token".owner = "prometheus"; + "forgejo/metrics_token".owner = lib.mkForce "prometheus"; # Forgejo reads it as root, at start + "alert/smtp_user".owner = lib.mkForce "grafana"; + "alert/smtp_password".owner = lib.mkForce "grafana"; + }; + sops.templates."loki.env".content = '' + S3_ACCESS_KEY=${config.sops.placeholder."s3/access_key"} + S3_SECRET_KEY=${config.sops.placeholder."s3/secret_key"} + ''; + + # --- Prometheus --------------------------------------------------------- + services.prometheus = { + enable = true; + package = unstable.prometheus; # 26.05 has 3.12, the data is from 3.16 + listenAddress = "127.0.0.1"; + port = 9090; + retentionTime = "90d"; + # The token files only exist at run time + checkConfig = "syntax-only"; + globalConfig = { + scrape_interval = "30s"; + evaluation_interval = "30s"; + }; + scrapeConfigs = [ + { + job_name = "node"; + static_configs = perHost 9100; + } + { + job_name = "cadvisor"; + scrape_interval = "60s"; + static_configs = perHost 9180; + metric_relabel_configs = [ + { + source_labels = [ "name" ]; + regex = "FORGEJO-ACTIONS-TASK-.*"; + action = "drop"; + } + ]; + } + { + job_name = "alloy"; + static_configs = perHost 12345; + } + { + job_name = "traefik"; + static_configs = [ + { + targets = [ "127.0.0.1:8082" ]; + labels.host = "asxpio-ops"; + } + ]; + } + { + job_name = "forgejo"; + metrics_path = "/metrics"; + authorization.credentials_file = config.sops.secrets."forgejo/metrics_token".path; + static_configs = [ + { + targets = [ "127.0.0.1:3000" ]; + labels.host = "asxpio-ops"; + } + ]; + } + { + job_name = "postgres"; + static_configs = [ + { + targets = [ "127.0.0.1:9187" ]; + labels.host = "asxpio-ops"; + } + ]; + } + { + job_name = "monitoring"; + static_configs = [ + { + targets = [ + "127.0.0.1:9090" + "10.10.0.10:3100" + "127.0.0.1:3001" + "127.0.0.1:9115" + ]; + labels.host = "asxpio-ops"; + } + ]; + } + # Every server in the Hetzner project; one that is not ours gets + # known="false" and an alert. Scrapes Prometheus itself: only the + # discovered labels matter, the samples are dropped. + { + job_name = "hcloud"; + scrape_interval = "60s"; + hetzner_sd_configs = [ + { + role = "hcloud"; + authorization.credentials_file = config.sops.secrets."monitoring/hcloud_ro_token".path; + } + ]; + relabel_configs = [ + { + source_labels = [ "__meta_hetzner_server_name" ]; + target_label = "server"; + } + { + source_labels = [ "__meta_hetzner_server_name" ]; + target_label = "instance"; + } + { + source_labels = [ "__meta_hetzner_public_ipv4" ]; + target_label = "public_ip"; + } + { + regex = "__meta_hetzner_hcloud_private_ipv4_.+"; + action = "labelmap"; + replacement = "private_ip"; + } + { + source_labels = [ "__meta_hetzner_hcloud_server_type" ]; + target_label = "type"; + } + { + source_labels = [ "__meta_hetzner_server_status" ]; + target_label = "status"; + } + { + target_label = "known"; + replacement = "false"; + } + { + source_labels = [ "__meta_hetzner_server_name" ]; + regex = lib.concatStringsSep "|" (lib.attrNames hosts); + target_label = "known"; + replacement = "true"; + } + { + target_label = "__address__"; + replacement = "127.0.0.1:9090"; + } + ]; + metric_relabel_configs = [ { action = "drop"; } ]; + } + ] + ++ map (module: { + job_name = "probe_${module}"; + metrics_path = "/probe"; + params.module = [ module ]; + static_configs = map (p: { + targets = [ p.target ]; + labels.probe = p.name; + }) (lib.filter (p: p.module == module) probes); + relabel_configs = [ + { + source_labels = [ "__address__" ]; + target_label = "__param_target"; + } + { + source_labels = [ "__param_target" ]; + target_label = "instance"; + } + { + target_label = "__address__"; + replacement = "127.0.0.1:9115"; + } + ]; + }) (lib.unique (map (p: p.module) probes)); + + exporters.blackbox = { + enable = true; + listenAddress = "127.0.0.1"; + port = 9115; + configFile = blackbox; + }; + exporters.postgres = { + enable = true; + listenAddress = "127.0.0.1"; + port = 9187; + runAsLocalSuperUser = true; + }; + }; + + # --- Loki --------------------------------------------------------------- + services.loki = { + enable = true; + package = pkgs.grafana-loki; + extraFlags = [ "-config.expand-env=true" ]; + configuration = { + auth_enabled = false; + server = { + http_listen_address = "10.10.0.10"; + http_listen_port = 3100; + grpc_listen_address = "127.0.0.1"; + log_level = "warn"; + }; + common = { + path_prefix = "/var/lib/loki"; + # Its own components talk gRPC over loopback only + instance_addr = "127.0.0.1"; + replication_factor = 1; + ring.kvstore.store = "inmemory"; + storage.filesystem = { + chunks_directory = "/var/lib/loki/chunks"; + rules_directory = "/var/lib/loki/rules"; + }; + }; + schema_config.configs = [ + { + from = "2026-11-01"; + store = "tsdb"; + object_store = "filesystem"; + schema = "v13"; + index = { + prefix = "index_"; + period = "24h"; + }; + } + # Chunks since then are in Object Storage (asxpio-loki-main) + { + from = "2026-11-14"; + store = "tsdb"; + object_store = "aws"; + schema = "v13"; + index = { + prefix = "index_"; + period = "24h"; + }; + } + ]; + storage_config.aws = { + endpoint = "hel1.your-objectstorage.com"; + region = "hel1"; + bucketnames = config.asxpio.lokiBucket; + access_key_id = "\${S3_ACCESS_KEY}"; + secret_access_key = "\${S3_SECRET_KEY}"; + }; + limits_config = { + retention_period = "17520h"; # 2 years + reject_old_samples = true; + reject_old_samples_max_age = "168h"; + ingestion_rate_mb = 8; + ingestion_burst_size_mb = 16; + volume_enabled = true; + }; + compactor = { + working_directory = "/var/lib/loki/compactor"; + retention_enabled = true; + delete_request_store = "aws"; + }; + analytics.reporting_enabled = false; + }; + }; + systemd.services.loki = { + after = [ "network-online.target" ]; + wants = [ "network-online.target" ]; + serviceConfig.EnvironmentFile = config.sops.templates."loki.env".path; + }; + + # --- Grafana ------------------------------------------------------------ + services.grafana = { + enable = true; + package = unstable.grafana; # 26.05 has 13.0, the database is from 13.3 + settings = { + server = { + http_addr = "127.0.0.1"; + http_port = 3001; + root_url = "https://gf.asxp.io/"; + }; + security = { + admin_user = "admin"; + admin_password = "$__file{${config.sops.secrets."monitoring/grafana_admin_password".path}}"; + cookie_secure = true; + secret_key = "$__file{${config.sops.secrets."monitoring/grafana_secret_key".path}}"; + }; + users.allow_sign_up = false; + "auth.anonymous".enabled = false; + analytics = { + reporting_enabled = false; + check_for_updates = false; + }; + news.news_feed_enabled = false; + dashboards.default_home_dashboard_path = "${./dashboards}/overview.json"; + smtp = { + enabled = true; + host = "smtp.fastmail.com:587"; + user = "$__file{${config.sops.secrets."alert/smtp_user".path}}"; + password = "$__file{${config.sops.secrets."alert/smtp_password".path}}"; + from_address = "$__file{${config.sops.secrets."alert/smtp_user".path}}"; + from_name = "asxpio monitoring"; + startTLS_policy = "MandatoryStartTLS"; + }; + }; + provision = { + enable = true; + datasources.settings = { + apiVersion = 1; + datasources = [ + { + name = "Prometheus"; + uid = "prometheus"; + type = "prometheus"; + access = "proxy"; + url = "http://127.0.0.1:9090"; + isDefault = true; + jsonData.timeInterval = "30s"; + } + { + name = "Loki"; + uid = "loki"; + type = "loki"; + access = "proxy"; + url = "http://10.10.0.10:3100"; + } + ]; + }; + dashboards.settings = { + apiVersion = 1; + providers = [ + { + name = "asxpio"; + type = "file"; + disableDeletion = true; + allowUiUpdates = false; + options = { + path = ./dashboards; + foldersFromFilesStructure = true; + }; + } + ]; + }; + alerting = { + rules.path = ./alert-rules.yaml; + contactPoints.settings = { + apiVersion = 1; + contactPoints = [ + { + orgId = 1; + name = "email"; + receivers = [ + { + uid = "email-me"; + type = "email"; + settings = { + addresses = config.asxpio.alertEmail; + singleEmail = true; + }; + } + ]; + } + ]; + }; + policies.settings = { + apiVersion = 1; + policies = [ + { + orgId = 1; + receiver = "email"; + group_by = [ "alertname" "host" ]; + group_wait = "1m"; + group_interval = "5m"; + repeat_interval = "4h"; + } + ]; + }; + }; + }; + }; + sops.secrets."monitoring/grafana_secret_key".owner = "grafana"; + + asxpio.routes.grafana = { + hosts = [ "gf.asxp.io" ]; + url = "http://127.0.0.1:3001"; + middlewares = [ "wireguard-only" ]; + }; + + asxpio.security.ports = [ "tcp/3100/loki" ]; + asxpio.waitForData = [ + "prometheus" + "loki" + "grafana" + ]; + asxpio.backup.paths = [ "/var/lib/grafana" ]; +} diff --git a/nixos/hosts/asxpio-ops/options.nix b/nixos/hosts/asxpio-ops/options.nix new file mode 100644 index 0000000..14c4630 --- /dev/null +++ b/nixos/hosts/asxpio-ops/options.nix @@ -0,0 +1,15 @@ +# Values the rehearsal host overrides. +{ lib, ... }: +{ + options.asxpio = { + alertEmail = lib.mkOption { + type = lib.types.str; + default = "me@asxp.io"; + description = "Where Grafana sends alerts."; + }; + lokiBucket = lib.mkOption { + type = lib.types.str; + default = "asxpio-loki-main"; + }; + }; +} diff --git a/nixos/hosts/asxpio-ops/postgres.nix b/nixos/hosts/asxpio-ops/postgres.nix new file mode 100644 index 0000000..85e90b5 --- /dev/null +++ b/nixos/hosts/asxpio-ops/postgres.nix @@ -0,0 +1,101 @@ +# Postgres for the apps. Roles and grants are set on every start from +# sops, so a password is changed by changing the secret. +# +# asxpio owns database asxpio (site, invoices, datacenter bingo admin) +# bingo read-only on the bingo tables, for datacenterbingo.xyz +{ + config, + lib, + pkgs, + ... +}: +let + pg = config.services.postgresql.package; +in +{ + sops.secrets."postgres/asxpio_password" = { }; + sops.secrets."postgres/bingo_password" = { }; + + services.postgresql = { + enable = true; + package = pkgs.postgresql_18; + # App containers connect from Podman's networks; the firewall decides + # who reaches the port + enableTCPIP = true; + authentication = '' + host all all 10.88.0.0/16 scram-sha-256 + host all all 10.89.0.0/16 scram-sha-256 + ''; + }; + networking.firewall.interfaces."podman*".allowedTCPPorts = [ 5432 ]; + asxpio.security.loginUsers = [ "postgres" ]; + asxpio.security.ports = [ "tcp/5432/.postgres-wrapp" ]; + + asxpio.waitForData = [ + "postgresql" + "postgresql-setup" + "postgres-roles" + ]; + + systemd.services.postgres-roles = { + description = "Postgres roles, databases and grants"; + after = [ "postgresql.target" ]; + requires = [ "postgresql.target" ]; + wantedBy = [ "multi-user.target" ]; + path = [ pg ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + User = "postgres"; + LoadCredential = [ + "asxpio:${config.sops.secrets."postgres/asxpio_password".path}" + "bingo:${config.sops.secrets."postgres/bingo_password".path}" + ]; + }; + script = '' + set -eu + role() { + psql -v ON_ERROR_STOP=1 -v role="$1" -v pw="$(cat "$CREDENTIALS_DIRECTORY/$1")" <<'SQL' + SELECT format('CREATE ROLE %I LOGIN', :'role') + WHERE NOT EXISTS (SELECT FROM pg_roles WHERE rolname = :'role') \gexec + SELECT format('ALTER ROLE %I WITH LOGIN PASSWORD %L', :'role', :'pw') \gexec + SQL + } + role asxpio + role bingo + + psql -tAc "SELECT 1 FROM pg_database WHERE datname = 'asxpio'" | grep -q 1 \ + || psql -c 'CREATE DATABASE asxpio OWNER asxpio' + psql -d asxpio -c 'CREATE EXTENSION IF NOT EXISTS citext' + + # Tables that do not exist yet (fresh install, asxpio not migrated) + # are granted on the next start + psql -c 'ALTER ROLE bingo SET default_transaction_read_only = on' + psql -d asxpio -v ON_ERROR_STOP=1 <<'SQL' + GRANT CONNECT ON DATABASE asxpio TO bingo; + GRANT USAGE ON SCHEMA public TO bingo; + DO $$ + DECLARE t text; + BEGIN + FOREACH t IN ARRAY ARRAY['bingo_datacenters', 'bingo_incidents', 'bingo_monitor_targets', + 'bingo_monitor_samples', 'bingo_monitor_buckets'] LOOP + IF to_regclass('public.' || t) IS NOT NULL THEN + EXECUTE format('GRANT SELECT ON public.%I TO bingo', t); + ELSE + RAISE NOTICE 'bingo: % missing, not granted yet', t; + END IF; + END LOOP; + END $$; + SQL + ''; + }; + + asxpio.backup.hookPackages = [ + pg + pkgs.util-linux + ]; + asxpio.backup.hooks = [ + ''runuser -u postgres -- pg_dumpall > "$STAGE/pg_dumpall.sql"'' + ''runuser -u postgres -- pg_dump -Fc asxpio > "$STAGE/asxpio.dump"'' + ]; +} diff --git a/nixos/hosts/asxpio-ops/traefik.nix b/nixos/hosts/asxpio-ops/traefik.nix new file mode 100644 index 0000000..a432c1d --- /dev/null +++ b/nixos/hosts/asxpio-ops/traefik.nix @@ -0,0 +1,251 @@ +# Traefik: the only thing listening on 80 and 443. Certificates from +# Let's Encrypt over the HTTP challenge, kept in /var/lib/traefik/acme.json. +# +# Routes come from two places: for the native services, from here +# (`asxpio.routes` below and in the services' own files); for the app +# containers, from their labels, read through Podman's socket exactly as +# they were read from Docker's. +{ + config, + lib, + pkgs, + ... +}: +let + internal = [ + "10.10.0.0/20" + "10.20.0.0/24" + ]; +in +{ + options.asxpio.letsencryptCA = lib.mkOption { + type = lib.types.str; + default = "https://acme-v02.api.letsencrypt.org/directory"; + }; + + # Shorthand for the common case: these hosts, over TLS, to that URL + options.asxpio.routes = lib.mkOption { + default = { }; + type = lib.types.attrsOf ( + lib.types.submodule { + options = { + hosts = lib.mkOption { type = lib.types.listOf lib.types.str; }; + url = lib.mkOption { type = lib.types.str; }; + middlewares = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + }; + }; + } + ); + }; + + config = { + sops.secrets."traefik/letsencrypt_email" = { }; + sops.templates."traefik.env".content = '' + TRAEFIK_CERTIFICATESRESOLVERS_LETSENCRYPT_ACME_EMAIL=${config.sops.placeholder."traefik/letsencrypt_email"} + ''; + + services.traefik = { + enable = true; + package = pkgs.traefik; + environmentFiles = [ config.sops.templates."traefik.env".path ]; + + staticConfigOptions = { + api = { + dashboard = true; + insecure = true; # on the "traefik" entry point below: WireGuard only + }; + entryPoints = { + web = { + address = ":80"; + http.redirections.entryPoint = { + to = "websecure"; + scheme = "https"; + }; + }; + websecure.address = ":443"; + traefik.address = "10.20.0.10:8080"; + metrics.address = "127.0.0.1:8082"; + }; + metrics.prometheus = { + entryPoint = "metrics"; + addRoutersLabels = true; + addServicesLabels = true; + }; + providers.docker = { + endpoint = "unix:///run/podman/podman.sock"; + exposedByDefault = false; + network = "traefik"; + }; + certificatesResolvers.letsencrypt.acme = { + caServer = config.asxpio.letsencryptCA; + storage = "${config.services.traefik.dataDir}/acme.json"; + httpChallenge.entryPoint = "web"; + }; + log = { + level = "INFO"; + filePath = "/var/log/traefik/traefik.log"; + }; + accessLog = { + filePath = "/var/log/traefik/access.log"; + bufferingSize = 100; + fields.headers = { + defaultMode = "drop"; + names = { + User-Agent = "keep"; + Referer = "keep"; + }; + }; + }; + }; + + dynamicConfigOptions.http = { + middlewares = { + secure-headers.headers = { + sslRedirect = true; + stsSeconds = 31536000; + stsIncludeSubdomains = true; + stsPreload = true; + forceSTSHeader = true; + frameDeny = true; + contentTypeNosniff = true; + browserXssFilter = true; + }; + rate-limit.rateLimit = { + average = 100; + burst = 50; + period = "1s"; + }; + internal-only.ipAllowList.sourceRange = internal; + wireguard-only.ipAllowList.sourceRange = [ "10.20.0.0/24" ]; + + # Anonymous reads of Garage's public bucket (see garage-public) + garage-public-strip.stripPrefix.prefixes = [ "/public" ]; + garage-public-host.headers.customRequestHeaders.Host = "public.web.garage"; + }; + + routers = { + traefik-dashboard = { + rule = "Host(`traefik.asxp.io`)"; + entryPoints = [ "websecure" ]; + service = "api@internal"; + middlewares = [ "internal-only" ]; + tls.certResolver = "letsencrypt"; + }; + + # Exists only to obtain the XMPP certificate (ejabberd on + # asxpio-services); xmpp-cert-sync pushes it there on every + # renewal. No traffic reaches it: these names point at + # services. asxp.io is pushed from the site's own certificate. + xmpp-cert = { + rule = "Host(`xmpp.asxp.io`)"; + entryPoints = [ "websecure" ]; + priority = 1; + service = "noop@internal"; + tls = { + certResolver = "letsencrypt"; + domains = [ + { + main = "xmpp.asxp.io"; + sans = [ "conference.asxp.io" ]; + } + ]; + }; + }; + + # Unsigned GET/HEAD of s3.asxp.io/public/ goes to Garage's + # web endpoint as Host public.web.garage, path /. Signed + # requests still reach the S3 API (route garage-s3). + garage-public = { + rule = "Host(`s3.asxp.io`) && PathPrefix(`/public/`) && (Method(`GET`) || Method(`HEAD`)) && !HeaderRegexp(`Authorization`, `.+`) && !QueryRegexp(`X-Amz-Signature`, `.+`)"; + priority = 1000; + entryPoints = [ "websecure" ]; + service = "garage-web"; + middlewares = [ + "garage-public-strip" + "garage-public-host" + ]; + tls.certResolver = "letsencrypt"; + }; + } + // lib.mapAttrs (name: r: { + rule = lib.concatMapStringsSep " || " (h: "Host(`${h}`)") r.hosts; + entryPoints = [ "websecure" ]; + service = name; + inherit (r) middlewares; + tls.certResolver = "letsencrypt"; + }) config.asxpio.routes; + + services = { + garage-web.loadBalancer.servers = [ { url = "http://127.0.0.1:3902"; } ]; + } + // lib.mapAttrs (_: r: { loadBalancer.servers = [ { inherit (r) url; } ]; }) config.asxpio.routes; + }; + }; + + asxpio.routes = { + forgejo = { + hosts = [ + "git.asxp.io" + "git.czsk.it" + ]; + url = "http://127.0.0.1:3000"; + }; + garage-s3 = { + hosts = [ "s3.asxp.io" ]; + url = "http://127.0.0.1:3900"; + }; + }; + + users.users.traefik.extraGroups = [ "podman" ]; + asxpio.security.podmanUsers = [ "traefik" ]; + asxpio.security.ports = [ + "tcp/80/traefik" + "tcp/443/traefik" + "tcp/8080/traefik" # dashboard, WireGuard address + ]; + systemd.services.traefik = { + after = [ + "podman.socket" + "wireguard-wg0.service" + ]; + wants = [ + "podman.socket" + "wireguard-wg0.service" + ]; + serviceConfig.LogsDirectory = "traefik"; + }; + services.logrotate.settings.traefik = { + files = "/var/log/traefik/*.log"; + frequency = "weekly"; + rotate = 8; + compress = true; + delaycompress = true; + # Traefik reopens its log files on USR1 + postrotate = "${config.systemd.package}/bin/systemctl kill -s USR1 traefik.service"; + }; + + # App containers that Traefik routes to join this network + systemd.services.podman-network-traefik = { + description = "Podman network traefik"; + wantedBy = [ "multi-user.target" ]; + before = [ "traefik.service" ]; + path = [ config.virtualisation.podman.package ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + script = "podman network exists traefik || podman network create traefik"; + }; + + networking.firewall.allowedTCPPorts = [ + 80 + 443 + ]; + + # acme.json holds the account key and every certificate + asxpio.waitForData = [ "traefik" ]; + asxpio.backup.paths = [ "/var/lib/traefik" ]; + }; +} diff --git a/nixos/hosts/asxpio-ops/xmpp-cert-sync.nix b/nixos/hosts/asxpio-ops/xmpp-cert-sync.nix new file mode 100644 index 0000000..c9c0c36 --- /dev/null +++ b/nixos/hosts/asxpio-ops/xmpp-cert-sync.nix @@ -0,0 +1,40 @@ +# XMPP certificates come from Traefik here (router xmpp-cert requests +# xmpp.asxp.io + conference.; asxp.io is the site's own certificate) and +# are pushed to ejabberd on asxpio-services on every renewal. +{ config, pkgs, ... }: +let + sync = pkgs.writers.writePython3 "xmpp-cert-sync" { + flakeIgnore = [ "E501" ]; + } (builtins.readFile ./xmpp-cert-sync.py); +in +{ + sops.secrets."xmpp_cert_sync/ssh_key" = { }; + + systemd.services.xmpp-cert-sync = { + description = "Push the XMPP certificate from Traefik to ejabberd"; + path = [ + pkgs.openssh + pkgs.openssl + pkgs.coreutils + ]; + environment.XMPP_CERT_KEY = config.sops.secrets."xmpp_cert_sync/ssh_key".path; + serviceConfig = { + Type = "oneshot"; + ExecStart = sync; + StateDirectory = "xmpp-cert-sync"; + }; + }; + systemd.paths.xmpp-cert-sync = { + description = "Watch Traefik's acme.json for a renewed XMPP certificate"; + wantedBy = [ "paths.target" ]; + pathConfig.PathChanged = "/var/lib/traefik/acme.json"; + }; + systemd.timers.xmpp-cert-sync = { + description = "Daily XMPP certificate check (fallback for the path unit)"; + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = "*-*-* 05:40:00"; + Persistent = true; + }; + }; +} diff --git a/nixos/hosts/asxpio-ops/xmpp-cert-sync.py b/nixos/hosts/asxpio-ops/xmpp-cert-sync.py new file mode 100644 index 0000000..27ef008 --- /dev/null +++ b/nixos/hosts/asxpio-ops/xmpp-cert-sync.py @@ -0,0 +1,80 @@ +# Push the XMPP certificates from Traefik's acme.json to ejabberd on +# asxpio-services whenever they change (xmpp-cert-sync.path), and daily +# as a fallback. The SSH key may only run xmpp-cert-install there. +import base64 +import hashlib +import json +import os +import subprocess +import sys +import tempfile +import time + +ACME = os.environ.get("XMPP_CERT_ACME", "/var/lib/traefik/acme.json") +CERTS = ["asxp.io", "xmpp.asxp.io"] +TARGET = "root@10.10.0.20" +KEY = os.environ["XMPP_CERT_KEY"] +STATE = "/var/lib/xmpp-cert-sync" +KNOWN = STATE + "/known_hosts" +PROM_DIR = "/var/lib/node_exporter/textfile" +PROM = PROM_DIR + "/xmpp_cert.prom" + + +def not_after(pem): + with tempfile.NamedTemporaryFile() as t: + t.write(pem) + t.flush() + end = subprocess.run(["openssl", "x509", "-in", t.name, "-noout", "-enddate"], + capture_output=True, text=True, check=True).stdout + end = end.split("=", 1)[1].strip() + return end, subprocess.run(["date", "-d", end, "+%s"], capture_output=True, + text=True, check=True).stdout.strip() + + +try: + acme = json.load(open(ACME))["letsencrypt"]["Certificates"] or [] +except (OSError, KeyError, ValueError): + acme = [] +os.makedirs(STATE, exist_ok=True) +expiry, missing = {}, [] +for name in CERTS: + entry = next((c for c in acme if c["domain"]["main"] == name), None) + if not entry: + print(f"no certificate for {name} in {ACME} yet") + missing.append(name) + continue + pem = base64.b64decode(entry["certificate"]) + base64.b64decode(entry["key"]) + end, expiry[name] = not_after(pem) + digest = hashlib.sha256(pem).hexdigest() + state = os.path.join(STATE, name + ".sha256") + try: + pushed = open(state).read().strip() + except OSError: + pushed = "" + if pushed == digest and "--force" not in sys.argv: + print(f"{name}: ejabberd already has it (valid until {end})") + continue + subprocess.run(["ssh", "-i", KEY, "-o", "BatchMode=yes", "-o", "IdentitiesOnly=yes", + "-o", f"UserKnownHostsFile={KNOWN}", "-o", "StrictHostKeyChecking=accept-new", + TARGET, name], input=pem, check=True, timeout=120) + with open(state, "w") as f: + f.write(digest + "\n") + print(f"{name}: pushed (valid until {end})") + +if os.path.isdir(PROM_DIR): + lines = ["# HELP xmpp_cert_source_not_after_timestamp_seconds Expiry of each XMPP certificate in Traefik's acme.json.", + "# TYPE xmpp_cert_source_not_after_timestamp_seconds gauge"] + lines += [f'xmpp_cert_source_not_after_timestamp_seconds{{cert="{n}"}} {t}' for n, t in expiry.items()] + if not missing: + lines += ["# HELP xmpp_cert_sync_last_success_timestamp_seconds Last run that left ejabberd with all of Traefik's current certificates.", + "# TYPE xmpp_cert_sync_last_success_timestamp_seconds gauge", + f"xmpp_cert_sync_last_success_timestamp_seconds {int(time.time())}"] + else: + try: # keep the last success, so the stale alert still counts from it + lines += [ln.rstrip("\n") for ln in open(PROM) + if ln.startswith(("# HELP xmpp_cert_sync", "# TYPE xmpp_cert_sync", "xmpp_cert_sync"))] + except OSError: + pass + with open(PROM + ".tmp", "w") as f: + f.write("\n".join(lines) + "\n") + os.replace(PROM + ".tmp", PROM) diff --git a/nixos/hosts/asxpio-services/acme-forward.nix b/nixos/hosts/asxpio-services/acme-forward.nix new file mode 100644 index 0000000..b8fa557 --- /dev/null +++ b/nixos/hosts/asxpio-services/acme-forward.nix @@ -0,0 +1,21 @@ +# Let's Encrypt validates xmpp.asxp.io on this host's port 80, but the +# certificates are requested by Traefik on asxpio-ops: pass the +# challenges on, answer nothing else. +{ ... }: +{ + services.nginx = { + enable = true; + serverTokens = false; + virtualHosts.acme-forward = { + default = true; + extraConfig = "access_log off;"; + locations."/.well-known/acme-challenge/" = { + proxyPass = "http://10.10.0.10"; + extraConfig = "proxy_set_header Host $host;"; + }; + locations."/".return = "404"; + }; + }; + networking.firewall.allowedTCPPorts = [ 80 ]; + asxpio.security.ports = [ "tcp/80/nginx" ]; +} diff --git a/nixos/hosts/asxpio-services/default.nix b/nixos/hosts/asxpio-services/default.nix new file mode 100644 index 0000000..095fec7 --- /dev/null +++ b/nixos/hosts/asxpio-services/default.nix @@ -0,0 +1,75 @@ +# asxpio-services: CI runners, Minecraft, XMPP, Xray, SillyTavern. +# Services are added here as they move over from ../../ansible (see +# MIGRATION.md at the repo root); until then this is the base system only. +{ lib, ... }: +{ + imports = [ + ./acme-forward.nix + ./minecraft.nix + ./replica.nix + ./runner.nix + ./sillytavern.nix + ./xmpp.nix + ./xmpp-cert-install.nix + ./xray.nix + ]; + + asxpio.publicIPv4 = lib.mkDefault "46.62.228.216"; + + networking.hostName = lib.mkDefault "asxpio-services"; + networking.domain = "asxp.io"; + asxpio.privateIPv4 = "10.10.0.20"; + system.stateVersion = "26.05"; + + systemd.network.networks."10-public".address = [ "2a01:4f9:c013:8269::1/64" ]; + # No swap, by choice + + sops.defaultSopsFile = lib.mkDefault ../../secrets/asxpio-services.yaml; + + # --- WireGuard spoke of asxpio-ops --------------------------------------- + asxpio.wireguard = { + interface = "asxpio-services"; + address = [ + "10.20.0.20/32" + "fd69:69:69::20/128" + ]; + listenPort = 52820; + peers = lib.mkDefault [ + { + name = "asxpio-ops"; + publicKey = "0gRrNiV4FjP6ipczZCRD3dsnK7k7rl6IyjG84fPaJB4="; + endpoint = "135.181.27.77:60101"; + allowedIPs = [ + "10.20.0.0/24" + "fd69:69:69::/64" + ]; + } + ]; + }; + + # --- Backup --------------------------------------------------------------- + # ejabberd's Mnesia through its own backup command, its SQLite through + # the online backup API. The Paper world is copied live (RCON is off, so + # there is no save-off); its autosave keeps that close enough. + asxpio.backup = { + hostName = "asxpio-services"; + schedule = "*-*-* 04:15:00"; + paths = [ + "/etc/ssh" # the host key decrypts this host's secrets + "/opt" + "/var/lib/minecraft" + "/var/lib/SillyTavern" + "/var/lib/containers/storage/volumes/xmpp_database" + "/var/lib/containers/storage/volumes/xmpp_tackygram" + ]; + excludes = [ + "/var/lib/minecraft/cache" + "/var/lib/minecraft/libraries" + "/var/lib/minecraft/versions" + ]; + hooks = [ + "podman exec xmpp-ejabberd ejabberdctl backup /opt/ejabberd/database/nightly.backup" + ''sqlite3 /var/lib/containers/storage/volumes/xmpp_database/_data/ejabberd.sqlite ".backup '$STAGE/ejabberd.sqlite'"'' + ]; + }; +} diff --git a/nixos/hosts/asxpio-services/minecraft.nix b/nixos/hosts/asxpio-services/minecraft.nix new file mode 100644 index 0000000..fb6b54f --- /dev/null +++ b/nixos/hosts/asxpio-services/minecraft.nix @@ -0,0 +1,38 @@ +# Paper. The world, plugins and server.properties are data in +# /var/lib/minecraft and not managed here; Geyser (a plugin) adds the +# Bedrock port. +{ lib, pkgs, ... }: +{ + services.minecraft-server = { + enable = true; + eula = true; + package = pkgs.papermc; + jvmOpts = "-Xmx4G -Xms2G"; + }; + asxpio.waitForData = [ "minecraft-server" ]; + systemd.services.minecraft-server = { + # Stopping saves the world first + serviceConfig.TimeoutStopSec = 120; + # Geyser lists the network interfaces (netlink) for Bedrock's + # signalling; the module allows IP sockets only + serviceConfig.RestrictAddressFamilies = lib.mkForce [ + "AF_INET" + "AF_INET6" + "AF_UNIX" + "AF_NETLINK" + ]; + # Geyser unpacks native libraries that expect a usual Linux around + # them (libcrypto, libstdc++) + environment.LD_LIBRARY_PATH = lib.makeLibraryPath [ + pkgs.openssl + pkgs.stdenv.cc.cc.lib + ]; + }; + networking.firewall.allowedTCPPorts = [ 25565 ]; + asxpio.security.ports = [ + "tcp/25565/java" + "tcp/19132/java" # Geyser's signalling + "udp/19132/java" # Bedrock + ]; + networking.firewall.allowedUDPPorts = [ 19132 ]; +} diff --git a/nixos/hosts/asxpio-services/replica.nix b/nixos/hosts/asxpio-services/replica.nix new file mode 100644 index 0000000..e23686d --- /dev/null +++ b/nixos/hosts/asxpio-services/replica.nix @@ -0,0 +1,86 @@ +# Daily one-way replica of the hel1 buckets into their fsn1 twins. +# restic/ is left out: restic writes its own, independent fsn1 repository. +{ + config, + lib, + pkgs, + ... +}: +let + pairs = [ + { + src = "asxpio-backups-main"; + dst = "asxpio-backups-repl"; + exclude = [ "restic/**" ]; + } + { + src = "asxpio-terraform-main"; + dst = "asxpio-terraform-repl"; + } + { + src = "k8s-asxpio-main"; + dst = "k8s-asxpio-repl"; + } + ]; + # A run that would delete more than this stops and fails (and mails): + # a mistake on the hel1 side must not empty the replica the next morning + maxDelete = 1000; + textfileDir = "/var/lib/node_exporter/textfile"; +in +{ + sops.templates."s3-replicate.env".content = + let + remote = name: region: '' + RCLONE_CONFIG_${name}_TYPE=s3 + RCLONE_CONFIG_${name}_PROVIDER=Other + RCLONE_CONFIG_${name}_ENDPOINT=https://${region}.your-objectstorage.com + RCLONE_CONFIG_${name}_REGION=${region} + RCLONE_CONFIG_${name}_ACCESS_KEY_ID=${config.sops.placeholder."s3/access_key"} + RCLONE_CONFIG_${name}_SECRET_ACCESS_KEY=${config.sops.placeholder."s3/secret_key"} + ''; + in + remote "HEL1" "hel1" + + remote "FSN1" "fsn1" + + '' + RCLONE_CONFIG_FSN1_NO_CHECK_BUCKET=true + ''; + + systemd.services.s3-replicate = { + description = "Replicate the hel1 buckets to fsn1"; + wants = [ "network-online.target" ]; + after = [ "network-online.target" ]; + onFailure = [ "alert-mail@%n.service" ]; + path = [ pkgs.rclone ]; + serviceConfig = { + Type = "oneshot"; + EnvironmentFile = config.sops.templates."s3-replicate.env".path; + TimeoutStartSec = "12h"; + }; + # One bucket at a time; a failing pair does not stop the others, but + # fails the run + script = '' + failed=0 + ${lib.concatMapStrings (p: '' + echo "s3-replicate: ${p.src} -> ${p.dst}" + rclone sync hel1:${p.src} fsn1:${p.dst} \ + --fast-list --checkers 16 --transfers 8 --max-delete ${toString maxDelete} \ + ${lib.concatMapStringsSep " " (e: "--exclude ${lib.escapeShellArg e}") (p.exclude or [ ])} \ + --stats-one-line -v || failed=1 + '') pairs} + if [ $failed = 0 ] && [ -d ${textfileDir} ]; then + f=${textfileDir}/s3_replicate.prom + printf '# HELP s3_replicate_last_success_timestamp_seconds Last fully successful hel1 to fsn1 replica.\n# TYPE s3_replicate_last_success_timestamp_seconds gauge\ns3_replicate_last_success_timestamp_seconds %s\n' "$(date +%s)" > "$f.tmp" && mv "$f.tmp" "$f" + fi + exit $failed + ''; + }; + systemd.timers.s3-replicate = { + description = "Daily hel1 -> fsn1 bucket replica"; + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = "*-*-* 06:00:00"; + RandomizedDelaySec = "15m"; + Persistent = true; + }; + }; +} diff --git a/nixos/hosts/asxpio-services/runner.nix b/nixos/hosts/asxpio-services/runner.nix new file mode 100644 index 0000000..1d86aa2 --- /dev/null +++ b/nixos/hosts/asxpio-services/runner.nix @@ -0,0 +1,162 @@ +# Forgejo Actions runners. Jobs are containers started through Podman's +# Docker-compatible socket. +# +# asxpio for git.asxp.io, reached over the private network +# interop for another-im/interop on dev.another.im +{ + config, + lib, + pkgs, + ... +}: +let + # Image behind the nix labels. Jobs mount a nix-store volume over /nix, + # seeded from this image on first use; the image's /bin/sh and + # /etc/nix/nix.conf link into that store, so a volume from another + # version breaks every job. Bumping this switches to a fresh volume; + # remove the old one afterwards (podman volume rm nix-store-). + # renovate: datasource=docker depName=nixos/nix + nixVersion = "2.35.6"; + + yaml = pkgs.formats.yaml { }; + interopConfig = yaml.generate "runner-interop.yaml" { + log = { + level = "info"; + job_level = "info"; + }; + runner = { + capacity = 3; + timeout = "5h"; + shutdown_timeout = "5h"; + fetch_interval = "5s"; + envs.NIX_CONFIG = '' + experimental-features = nix-command flakes + build-users-group = + sandbox = false + ''; + labels = [ + "nix:docker://nixos/nix:${nixVersion}" + "docker:docker://node:22.23.5-bookworm" + "nix-host:docker://nixos/nix:${nixVersion}" + ]; + }; + container = { + network = "bridge"; + privileged = false; + docker_host = "-"; # its jobs get no container socket + valid_volumes = [ ]; + force_pull = false; + }; + }; +in +{ + options.asxpio.runner.forgejoUrl = lib.mkOption { + type = lib.types.str; + default = "http://10.10.0.10:3000"; # over the private network, not through Traefik + }; + + config = { + sops.secrets."runner/token" = { }; + sops.secrets."runner/interop_token" = { }; + sops.templates."runner.env".content = '' + TOKEN=${config.sops.placeholder."runner/token"} + ''; + # The connection (URL, UUID, token) is merged into the config at + # start; the UUID is not secret (interop's infra/runner.json) + sops.templates."runner-interop-server.yaml".content = '' + server: + connections: + interop: + url: https://dev.another.im/ + uuid: dc326085-8420-4c33-8b88-a9ef46b3359b + token: ${config.sops.placeholder."runner/interop_token"} + ''; + + # The job cache server listens on a random port + asxpio.security.ports = [ "tcp/*/.forgejo-runner" ]; + asxpio.security.containers."FORGEJO-ACTIONS-TASK-.*" = [ "docker-sock" ]; # docker_host: automount + + services.gitea-actions-runner = { + package = pkgs.forgejo-runner; + instances.asxpio = { + enable = true; + name = config.networking.hostName; + url = config.asxpio.runner.forgejoUrl; + tokenFile = config.sops.templates."runner.env".path; + labels = [ + "ubuntu-latest:docker://node:20.20.2-bookworm" + "ubuntu-22.04:docker://node:20.20.2-bookworm" + "ubuntu-24.04:docker://node:22.23.5-bookworm" + "debian-latest:docker://debian:12.15" + "debian-12:docker://debian:12.15" + "debian-11:docker://debian:11.11" + "arch-latest:docker://archlinux:base-20261108.0.623074" + "nginx-latest:docker://nginx:1.31.8" + "nginx-alpine:docker://nginx:1.31.8-alpine" + "node-20:docker://node:20.20.2" + "node-22:docker://node:22.23.5" + "python-3.11:docker://python:3.11.18" + "python-3.12:docker://python:3.12.16" + "alpine-latest:docker://alpine:3.24.4" + "nix-latest:docker://nixos/nix:${nixVersion}" + ]; + settings = { + log = { + level = "info"; + job_level = "info"; + }; + runner = { + capacity = 4; + timeout = "3h"; + shutdown_timeout = "3h"; + fetch_timeout = "5s"; + fetch_interval = "2s"; + report_interval = "1s"; + }; + cache.enabled = true; + container = { + privileged = false; + options = "-v nix-store-${nixVersion}:/nix"; + valid_volumes = [ "**" ]; + docker_host = "automount"; # deploy jobs build and push images + force_pull = false; + }; + }; + }; + }; + + systemd.services.forgejo-runner-interop = { + description = "Forgejo Actions runner for another-im/interop"; + wantedBy = [ "multi-user.target" ]; + after = [ + "network-online.target" + "podman.socket" + ]; + wants = [ + "network-online.target" + "podman.socket" + ]; + environment.DOCKER_HOST = "unix:///run/podman/podman.sock"; + path = [ + pkgs.forgejo-runner + pkgs.yq-go + ]; + serviceConfig = { + DynamicUser = true; + SupplementaryGroups = [ "podman" ]; + StateDirectory = "forgejo-runner-interop"; + WorkingDirectory = "/var/lib/forgejo-runner-interop"; + RuntimeDirectory = "forgejo-runner-interop"; + LoadCredential = "server.yaml:${config.sops.templates."runner-interop-server.yaml".path}"; + Restart = "always"; + RestartSec = 5; + }; + script = '' + umask 077 + yq eval-all '. as $i ireduce ({}; . * $i)' ${interopConfig} "$CREDENTIALS_DIRECTORY/server.yaml" \ + > "$RUNTIME_DIRECTORY/config.yaml" + exec forgejo-runner daemon --config "$RUNTIME_DIRECTORY/config.yaml" + ''; + }; + }; +} diff --git a/nixos/hosts/asxpio-services/sillytavern.nix b/nixos/hosts/asxpio-services/sillytavern.nix new file mode 100644 index 0000000..0cbfcc6 --- /dev/null +++ b/nixos/hosts/asxpio-services/sillytavern.nix @@ -0,0 +1,19 @@ +# SillyTavern, on the WireGuard address only. State: /var/lib/SillyTavern +# (data/, extensions/). +{ config, unstable, ... }: +{ + services.sillytavern = { + enable = true; + package = unstable.sillytavern; # 26.05 has 1.18, the data is from 1.19 + configFile = "${./sillytavern.yaml}"; + # Port 8000, the WireGuard address and the whitelist (WireGuard only) + # are in the config file; the module's flags do not reach the server + }; + asxpio.waitForData = [ "sillytavern" ]; + asxpio.security.ports = [ "tcp/8000/MainThread" ]; + systemd.services.sillytavern = { + after = [ "wireguard-${config.asxpio.wireguard.interface}.service" ]; + wants = [ "wireguard-${config.asxpio.wireguard.interface}.service" ]; + serviceConfig.RestartSec = 5; + }; +} diff --git a/nixos/hosts/asxpio-services/sillytavern.yaml b/nixos/hosts/asxpio-services/sillytavern.yaml new file mode 100644 index 0000000..cbfa42b --- /dev/null +++ b/nixos/hosts/asxpio-services/sillytavern.yaml @@ -0,0 +1,171 @@ +dataRoot: ./data +# Bound to the WireGuard address (in Docker this was the published port) +listen: true +listenAddress: + ipv4: 10.20.0.20 + ipv6: "[::]" +protocol: + ipv4: true + ipv6: false +dnsPreferIPv6: false +browserLaunch: + enabled: false + browser: default + hostname: auto + port: -1 + avoidLocalhost: false +port: 8000 +ssl: + enabled: false + certPath: ./certs/cert.pem + keyPath: ./certs/privkey.pem + keyPassphrase: "" +whitelistMode: true +enableForwardedWhitelist: true +whitelist: + - ::1 + - 127.0.0.1 + - 10.20.0.0/24 +whitelistDockerHosts: true +basicAuthMode: false +basicAuthUser: + username: user + password: password +enableCorsProxy: false +requestProxy: + enabled: false + url: socks5://username:password@example.com:1080 + bypass: + - localhost + - 127.0.0.1 +enableUserAccounts: true +enableDiscreetLogin: false +perUserBasicAuth: false +sso: + autheliaAuth: false + authentikAuth: false + trustedProxies: + - ::1 + - 127.0.0.1 +hostWhitelist: + enabled: false + scan: true + hosts: [] +sessionTimeout: -1 +disableCsrfProtection: false +securityOverride: false +logging: + enableAccessLog: true + minLogLevel: 0 +rateLimiting: + preferRealIpHeader: false + basicAuthMaxAttempts: 5 + accountsLoginMaxAttempts: 5 + accountsRecoverMaxAttempts: 5 + accountsResetMaxAttempts: 5 +backups: + common: + numberOfBackups: 50 + chat: + enabled: true + checkIntegrity: true + maxTotalBackups: -1 + throttleInterval: 10000 + allowFullDataBackup: true +thumbnails: + enabled: true + format: jpg + quality: 95 + dimensions: + bg: + - 160 + - 90 + avatar: + - 96 + - 144 + persona: + - 96 + - 144 +performance: + lazyLoadCharacters: false + memoryCacheCapacity: 100mb + useDiskCache: true + requestCompression: + enabled: false + minPayloadSize: 256kb + maxPayloadSize: 8mb + timeout: 4000 +cacheBuster: + enabled: false + userAgentPattern: "" +allowKeysExposure: false +skipContentCheck: false +whitelistImportDomains: + - localhost + - cdn.discordapp.com + - files.catbox.moe + - raw.githubusercontent.com + - char-archive.evulid.cc +requestOverrides: [] +extensions: + enabled: true + autoUpdate: true + models: + autoDownload: true + classification: Cohee/distilbert-base-uncased-go-emotions-onnx + captioning: Xenova/vit-gpt2-image-captioning + embedding: Cohee/jina-embeddings-v2-base-en + speechToText: Xenova/whisper-small + textToSpeech: Xenova/speecht5_tts +enableDownloadableTokenizers: true +promptPlaceholder: "[Start a new chat]" +openai: + randomizeUserId: false + captionSystemPrompt: "" +deepl: + formality: default +mistral: + enablePrefix: false +ollama: + keepAlive: -1 + batchSize: -1 +claude: + enableSystemPromptCache: false + cachingAtDepth: -1 + extendedTTL: false + enableAdaptiveThinking: false +gemini: + apiVersion: v1beta + thoughtSignatures: true + enableSystemPromptCache: false + image: + personGeneration: allow_adult +enableServerPlugins: false +enableServerPluginsAutoUpdate: true +heartbeatInterval: 0 +enableKeepAlive: false +cors: + enabled: true + origin: + - "null" + methods: + - OPTIONS + allowedHeaders: [] + exposedHeaders: [] + credentials: false + maxAge: null +privateAddressWhitelist: + enabled: false + allowUnresolvedHosts: false + log: + blockedRequests: true + allowedRequests: false + allowedRanges: + - 127.0.0.0/8 + - ::1/128 +forwardedHeaders: + xRealIp: true + xForwardedFor: true + cfConnectingIp: false +git: + backend: auto diff --git a/nixos/hosts/asxpio-services/xmpp-cert-install.nix b/nixos/hosts/asxpio-services/xmpp-cert-install.nix new file mode 100644 index 0000000..908b45b --- /dev/null +++ b/nixos/hosts/asxpio-services/xmpp-cert-install.nix @@ -0,0 +1,41 @@ +# Receiving end of xmpp-cert-sync on asxpio-ops (see its file there): the +# key below may run exactly one command, from ops only. +{ + config, + lib, + pkgs, + ... +}: +let + install = pkgs.writeShellApplication { + name = "xmpp-cert-install"; + runtimeInputs = [ + pkgs.coreutils + pkgs.openssl + pkgs.gnugrep + pkgs.util-linux + config.virtualisation.podman.package + ]; + text = builtins.readFile ./xmpp-cert-install.sh; + }; +in +{ + options.asxpio.xmppCertSyncKey = lib.mkOption { + type = lib.types.str; + default = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAKd1FvOgmxeNCHUJzRQxNA3IBRz59A1VDdsnOwxhybl"; + description = "Public half of xmpp_cert_sync/ssh_key in the ops secrets."; + }; + + options.asxpio.xmppCertSyncKeysExtra = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ + # Debian asxpio-ops's key (Ansible role xmpp_cert_sync), until ops + # runs NixOS too. Remove after the ops conversion. + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGLSz8AvKF/cHmMBGxn7+BqNHa/g79xmRrnb7779lXLo" + ]; + }; + + config.users.users.root.openssh.authorizedKeys.keys = map ( + key: ''restrict,from="10.10.0.10",command="${lib.getExe install}" ${key} xmpp-cert-sync'' + ) ([ config.asxpio.xmppCertSyncKey ] ++ config.asxpio.xmppCertSyncKeysExtra); +} diff --git a/nixos/hosts/asxpio-services/xmpp-cert-install.sh b/nixos/hosts/asxpio-services/xmpp-cert-install.sh new file mode 100644 index 0000000..6dbd0d8 --- /dev/null +++ b/nixos/hosts/asxpio-services/xmpp-cert-install.sh @@ -0,0 +1,31 @@ +# Forced command of the xmpp-cert-sync key from asxpio-ops: read a +# certificate chain + key on stdin, check it, install it as +# certs/.pem for ejabberd (which picks the matching file per +# domain) and reload. +set -eu +umask 022 +name=${SSH_ORIGINAL_COMMAND:-} +case "$name" in + asxp.io|*.asxp.io) ;; + *) echo "refusing certificate name '$name'" >&2; exit 1 ;; +esac +case "$name" in *[!a-z0-9.-]*) echo "bad name" >&2; exit 1 ;; esac +dir=/opt/xmpp/state/certs +tmp=$(mktemp "$dir/.incoming.XXXXXX") +trap 'rm -f "$tmp"' EXIT +head -c 65536 > "$tmp" +# Valid for at least another day, for this name, with its matching key +openssl x509 -in "$tmp" -noout -checkend 86400 >/dev/null +openssl x509 -in "$tmp" -noout -checkhost "$name" | grep -q "does match" +cert_pub=$(openssl x509 -in "$tmp" -noout -pubkey | sha256sum) +key_pub=$(openssl pkey -in "$tmp" -pubout | sha256sum) +[ "$cert_pub" = "$key_pub" ] || { echo "key does not match certificate" >&2; exit 1; } +chmod 0644 "$tmp" +mv "$tmp" "$dir/$name.pem" +trap - EXIT +# Not running during a restore or on a rehearsal host: ejabberd reads the +# file at its next start +if podman container exists xmpp-ejabberd; then + podman exec xmpp-ejabberd ejabberdctl reload_config +fi +logger -t xmpp-cert-install "installed $name.pem, $(openssl x509 -in "$dir/$name.pem" -noout -enddate)" diff --git a/nixos/hosts/asxpio-services/xmpp.nix b/nixos/hosts/asxpio-services/xmpp.nix new file mode 100644 index 0000000..ec85c8d --- /dev/null +++ b/nixos/hosts/asxpio-services/xmpp.nix @@ -0,0 +1,136 @@ +# XMPP for asxp.io: another.im's ejabberd build, its push server and the +# Telegram gateway. A custom image, so containers; the two helpers share +# ejabberd's network namespace and reach its component port on 127.0.0.1. +# +# /opt/xmpp/state (secrets.env, certs/, apushd/, tackygram/) is host data: +# generated once, backed up, not in this repo. Certificates arrive there +# from asxpio-ops (xmpp-cert-sync). +{ config, lib, ... }: +let + # renovate: datasource=docker depName=dev.another.im/another-im/anotherim-server + ejabberd = "dev.another.im/another-im/anotherim-server:2026.11.07"; + # renovate: datasource=docker depName=dev.another.im/another-im/apushd + apushd = "dev.another.im/another-im/apushd:0.2"; + # renovate: datasource=docker depName=dev.another.im/another-im/tackygram + tackygram = "dev.another.im/another-im/tackygram:0.4.3"; + + callPorts = "50000-50099"; + state = "/opt/xmpp/state"; + helper = { + dependsOn = [ "xmpp-ejabberd" ]; + extraOptions = [ "--network=container:xmpp-ejabberd" ]; + }; +in +{ + options.asxpio.publicIPv4 = lib.mkOption { type = lib.types.str; }; + + config = { + # A network of its own with IPv6: xmpp.asxp.io has an AAAA record, + # and Podman's default network forwards published ports over IPv4 + # only (Docker on Debian did both). + systemd.services.podman-network-xmpp = { + description = "Podman network xmpp (IPv4 and IPv6)"; + wantedBy = [ "multi-user.target" ]; + before = [ "podman-xmpp-ejabberd.service" ]; + path = [ config.virtualisation.podman.package ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + script = '' + podman network exists xmpp \ + || podman network create --ipv6 --subnet 10.90.0.0/24 --subnet fd69:90::/64 xmpp + ''; + }; + systemd.services.podman-xmpp-ejabberd = { + requires = [ "podman-network-xmpp.service" ]; + after = [ "podman-network-xmpp.service" ]; + }; + + virtualisation.oci-containers.containers = { + xmpp-ejabberd = { + image = ejabberd; + environment = { + EJABBERD_MACRO_XMPP_DOMAIN = "asxp.io"; + EJABBERD_MACRO_TURN_IP = config.asxpio.publicIPv4; + EJABBERD_MACRO_POW_DIFFICULTY = "6"; + EJABBERD_MACRO_REGISTRATION_TIMEOUT = "600"; + EJABBERD_MACRO_UPLOAD_URL = "https://hel1.your-objectstorage.com/asxpio-xmpp-public/"; + EJABBERD_MACRO_ACME_URL = "https://acme-v02.api.letsencrypt.org/directory"; + }; + environmentFiles = [ "${state}/secrets.env" ]; + extraOptions = [ "--network=xmpp" ]; + ports = [ + "5222:5222" # clients, STARTTLS + "5223:5223" # clients, direct TLS + "5269:5269" # other servers + "5443:5443" # WebSocket, host-meta + "8448:8448" # Matrix federation + "3478:3478/udp" # STUN and TURN + "3478:3478/tcp" + "49160-49199:49160-49199/udp" # TURN relay + "7777:7777" # SOCKS5 bytestreams proxy + "${callPorts}:${callPorts}/udp" # gateway calls + ]; + volumes = [ + "xmpp_database:/opt/ejabberd/database" + "xmpp_logs:/opt/ejabberd/logs" + "${state}/certs:/opt/ejabberd/conf/certs:ro" + ]; + }; + + xmpp-apushd = helper // { + image = apushd; + volumes = [ "${state}/apushd:/etc/apushd:ro" ]; + }; + + xmpp-tackygram = helper // { + image = tackygram; + environment = { + CREDENTIALS_DIRECTORY = "/run/credentials"; + TACKYGRAM_CALL_IP = config.asxpio.publicIPv4; + TACKYGRAM_CALL_PORTS = callPorts; + }; + environmentFiles = [ "${state}/tackygram/env" ]; + volumes = [ + "xmpp_tackygram:/var/lib/tackygram" + "${state}/tackygram/key:/run/credentials/gateway-key:ro" + ]; + }; + }; + + asxpio.waitForData = [ + "podman-xmpp-ejabberd" + "podman-xmpp-apushd" + "podman-xmpp-tackygram" + ]; + + # Published ports belong to rootful Podman's port forwarder + asxpio.security.ports = map (p: "${p}/conmon") [ + "tcp/5222-5223" + "tcp/5269" + "tcp/5443" + "tcp/8448" + "tcp/3478" + "udp/3478" + "tcp/7777" + "udp/49160-49199" + "udp/50000-50099" + ]; + + networking.firewall.allowedTCPPorts = [ + 5222 + 5223 + 5269 + 5443 + 8448 + 3478 + 7777 + ]; + networking.firewall.allowedUDPPorts = [ 3478 ]; + networking.firewall.allowedUDPPortRanges = [ + { from = 49160; to = 49199; } + { from = 50000; to = 50099; } + ]; + }; +} diff --git a/nixos/hosts/asxpio-services/xray.nix b/nixos/hosts/asxpio-services/xray.nix new file mode 100644 index 0000000..ecc9976 --- /dev/null +++ b/nixos/hosts/asxpio-services/xray.nix @@ -0,0 +1,17 @@ +# Xray VLESS Reality on :443. The whole config is a secret (keys, UUIDs). +{ config, unstable, ... }: +{ + sops.secrets."xray/config" = { }; + + services.xray = { + enable = true; + package = unstable.xray; # 26.05 has 26.3, production runs 26.11 + settingsFile = config.sops.secrets."xray/config".path; + }; + systemd.services.xray.restartTriggers = [ config.sops.secrets."xray/config".sopsFile ]; + networking.firewall.allowedTCPPorts = [ 443 ]; + asxpio.security.ports = [ + "tcp/443/.xray-wrapped" + "udp/*/.xray-wrapped" # outbound relay sockets + ]; +} diff --git a/nixos/hosts/rehearsal/ops.nix b/nixos/hosts/rehearsal/ops.nix new file mode 100644 index 0000000..bfc1be4 --- /dev/null +++ b/nixos/hosts/rehearsal/ops.nix @@ -0,0 +1,71 @@ +# asxpio-ops on a throwaway server: the same system with its own keys, +# its own addresses and SSH open to the world. Pairs with ./services.nix +# on a private network with the production addresses (10.10.0.10/.20). +{ lib, ... }: +{ + networking.hostName = "rehearsal-ops"; + sops.defaultSopsFile = ../../secrets/rehearsal-ops.yaml; + asxpio.sshFrom = [ "*" ]; + + # Same script and schedule, into repositories on its own disk + asxpio.backup.repositories = lib.mkForce { + hel1 = "/var/backups/test-repo-hel1"; + fsn1 = "/var/backups/test-repo-fsn1"; + }; + systemd.network.networks."10-public".address = lib.mkForce [ "2a01:4f9:c015:f949::1/64" ]; + + # A restored copy of production must not mail anyone, sync mirrors or + # call webhooks + services.forgejo.settings = { + mailer.ENABLED = false; + service.ENABLE_NOTIFY_MAIL = lib.mkForce false; + mirror.ENABLED = false; + webhook.ALLOWED_HOST_LIST = "loopback"; + "cron.update_mirrors".ENABLED = false; + }; + + # The names point at production, so no challenge can succeed here: + # ask the staging CA, and expect Traefik's self-signed certificate + asxpio.letsencryptCA = "https://acme-staging-v02.api.letsencrypt.org/directory"; + + # No alert mail from a test pair + asxpio.alertEmail = "nobody@example.invalid"; + services.grafana.settings.smtp.enabled = lib.mkForce false; + systemd.timers.crawler-alert.enable = false; + systemd.timers.crawler-weekly.enable = false; + services.loki.configuration = { + # No Object Storage keys here: everything on local disk + schema_config.configs = lib.mkForce [ + { + from = "2026-11-01"; + store = "tsdb"; + object_store = "filesystem"; + schema = "v13"; + index = { + prefix = "index_"; + period = "24h"; + }; + } + ]; + compactor.delete_request_store = lib.mkForce "filesystem"; + }; + + asxpio.wireguard.peers = [ + { + name = "asxpio-services"; + publicKey = "DwCNEfzgV1fU2ZPwEwkxun/s8vMZYrzdp74ZDrrSTD4="; + allowedIPs = [ + "10.20.0.20/32" + "fd69:69:69::20/128" + ]; + } + { + name = "laptop"; + publicKey = "iTY+NChSd8pcm/vke8s8EqsxjwEJpBEc07PfEg1Q0zQ="; + allowedIPs = [ + "10.20.0.2/32" + "fd69:69:69::2/128" + ]; + } + ]; +} diff --git a/nixos/hosts/rehearsal/services.nix b/nixos/hosts/rehearsal/services.nix new file mode 100644 index 0000000..cd1617f --- /dev/null +++ b/nixos/hosts/rehearsal/services.nix @@ -0,0 +1,59 @@ +# asxpio-services on a throwaway server; see ./ops.nix. +{ lib, ... }: +{ + networking.hostName = "rehearsal-services"; + sops.defaultSopsFile = ../../secrets/rehearsal-services.yaml; + asxpio.sshFrom = [ "*" ]; + + # Same script and schedule, into repositories on its own disk + asxpio.backup.repositories = lib.mkForce { + hel1 = "/var/backups/test-repo-hel1"; + fsn1 = "/var/backups/test-repo-fsn1"; + }; + systemd.network.networks."10-public".address = lib.mkForce [ "2a01:4f9:c01d:6f9::1/64" ]; + + asxpio.publicIPv4 = "2.29.197.9"; + asxpio.xmppCertSyncKeysExtra = [ ]; + asxpio.xmppCertSyncKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHXhvaO3Dhkw3QuMUHycoPU12Vx8bKWk2PCFoULvnTAf"; + + # A 4 GB server + services.minecraft-server.jvmOpts = lib.mkForce "-Xmx2G -Xms1G"; + + # A restored world brings its plugins and their credentials along. + # Those that talk to the outside (the Discord bot logs in with the + # production token and edits the real server's slash commands) are + # put aside before every start. + systemd.services.minecraft-server.preStart = lib.mkBefore '' + mkdir -p plugins/disabled-on-rehearsal + for p in DiscordSRV ServerBackup AutoUpdateGeyser; do + for f in plugins/$p*.jar; do + [ ! -e "$f" ] || mv "$f" plugins/disabled-on-rehearsal/ + done + done + ''; + + # With production data restored these would act as production: a second + # asxp.io XMPP server and Telegram session. Start them by hand, and + # only with test data. + virtualisation.oci-containers.containers = lib.genAttrs [ "xmpp-ejabberd" "xmpp-apushd" "xmpp-tackygram" ] (_: { + autoStart = false; + }); + + # Dummy keys; and nothing here may write to the production buckets + systemd.timers.s3-replicate.enable = false; + + # This runner would take real jobs of another project + systemd.services.forgejo-runner-interop.wantedBy = lib.mkForce [ ]; + + asxpio.wireguard.peers = [ + { + name = "asxpio-ops"; + publicKey = "Zuufncq9a9UZGvgRBjattzuoomJtWREjFeoB0POt620="; + endpoint = "62.238.40.174:60101"; # rehearsal-ops + allowedIPs = [ + "10.20.0.0/24" + "fd69:69:69::/64" + ]; + } + ]; +} diff --git a/nixos/migration/ops-data.sh b/nixos/migration/ops-data.sh new file mode 100755 index 0000000..557f1cf --- /dev/null +++ b/nixos/migration/ops-data.sh @@ -0,0 +1,104 @@ +#!/usr/bin/env bash +# asxpio-ops: move the data of the Debian/Docker layout to where the +# NixOS services keep it, then let them start. +# +# ops-data.sh +# +# is /old-root after an in-place conversion (the dumps then +# come from the last thing done before it: `restic-backup run`, which +# leaves nothing behind, so take them by hand into +# /var/backups/restic-stage), or the target of a restic restore. +# Moves within one filesystem, so it is quick; run it once, as root, on a +# host whose services are still waiting for /var/lib/.data-in-place. +set -euo pipefail + +src=${1:?usage: ops-data.sh } +stage=$src/var/backups/restic-stage +[ ! -e /var/lib/.data-in-place ] || { echo "services already have data (/var/lib/.data-in-place exists)" >&2; exit 1; } +for f in "$stage/pg_dumpall.sql" "$stage/forgejo-gitea.db" "$src/opt/forgejo/data/git/repositories"; do + [ -e "$f" ] || { echo "missing: $f" >&2; exit 1; } +done + +echo "== Forgejo" +fj=/var/lib/forgejo +install -d -o git -g git -m 750 $fj $fj/data $fj/custom +mv "$src/opt/forgejo/data/git/repositories" $fj/repositories +mv "$src/opt/forgejo/data/git/lfs" $fj/data/lfs +for d in "$src"/opt/forgejo/data/gitea/data/*; do + case "$(basename "$d")" in + home | ssh | tmp | sessions | queues | indexers) ;; # rebuilt, or the container's own + *) mv "$d" $fj/data/ ;; + esac +done +[ ! -d "$src/opt/forgejo/data/gitea/public" ] || mv "$src/opt/forgejo/data/gitea/public" $fj/custom/public +# The online copy taken by the backup hook, not the live file +cp "$stage/forgejo-gitea.db" $fj/data/forgejo.db +chown -R git:git $fj + +echo "== Garage" +install -d -m 700 /var/lib/garage +mv "$src/var/lib/docker/volumes/storage_garage_meta/_data" /var/lib/garage/meta +mv "$src/var/lib/docker/volumes/storage_garage_data/_data" /var/lib/garage/data + +echo "== Traefik" +install -d -o traefik -g traefik -m 700 /var/lib/traefik +if [ -f "$src/opt/traefik/letsencrypt/acme.json" ]; then + install -o traefik -g traefik -m 600 "$src/opt/traefik/letsencrypt/acme.json" /var/lib/traefik/acme.json +fi + +echo "== Monitoring history (Docker volumes; not in the restic backup)" +mvvol() { # mvvol + if [ -d "$vols/$1/_data" ]; then + rm -rf "$2"; mkdir -p "$(dirname "$2")" + mv "$vols/$1/_data" "$2"; chown -R "$3" "$2" + else + echo " $1: not there (a restore, not a conversion); starting empty" + fi +} +vols=$src/var/lib/docker/volumes +mvvol monitoring_prometheus-data /var/lib/prometheus2/data prometheus:prometheus +mvvol monitoring_loki-data /var/lib/loki loki:loki +if [ -f "$vols/monitoring_grafana-data/_data/grafana.db" ]; then + install -d -o grafana -g grafana /var/lib/grafana/data + mv "$vols/monitoring_grafana-data/_data/grafana.db" /var/lib/grafana/data/grafana.db + chown grafana:grafana /var/lib/grafana/data/grafana.db +fi + +echo "== App stacks (compose file and .env each; CI deploys them later)" +for app in asxpio datacenterbingo blog czsk vhpbot-prod vhpbot-dev; do + [ -d "$src/opt/$app" ] || continue + rm -rf "/opt/$app"; mv "$src/opt/$app" "/opt/$app" + chown -R deploy:deploy "/opt/$app" +done +[ ! -d "$src/root/backups" ] || { rm -rf /root/backups; mv "$src/root/backups" /root/backups; } + +echo "== Starting" +touch /var/lib/.data-in-place +systemctl start postgresql.service + +echo "== Postgres" +# The dump recreates the roles with their old passwords; postgres-roles +# then sets the ones from sops +runuser -u postgres -- psql -q postgres < "$stage/pg_dumpall.sql" > /var/log/pg-restore.log 2>&1 || true +echo "errors in /var/log/pg-restore.log: $(grep -c ERROR /var/log/pg-restore.log || true)" +systemctl restart postgres-roles.service + +systemctl start garage.service garage-bootstrap.service forgejo.service traefik.service + +echo "== Forgejo: hooks and SSH keys for the new paths" +forgejo-admin regenerate hooks +forgejo-admin regenerate keys + +echo "== App stacks: images again (Docker's image store does not carry over)" +for app in asxpio datacenterbingo blog czsk vhpbot-prod vhpbot-dev; do + [ -f "/opt/$app/docker-compose.yml" ] || continue + echo " $app" + if grep -q "^ *build:" "/opt/$app/docker-compose.yml" && ! grep -q "image: *git" "/opt/$app/docker-compose.yml"; then + runuser -l deploy -c "cd /opt/$app && docker compose up -d --build" || echo " $app FAILED" + else + runuser -l deploy -c "cd /opt/$app && docker compose pull -q && docker compose up -d" || echo " $app FAILED" + fi +done + +echo "== Done. Check: systemctl --failed; garage status; a git clone over SSH and HTTPS;" +echo " docker ps (as deploy): every app healthy; Grafana on gf.asxp.io" diff --git a/nixos/migration/rehearsal-sanitize-forgejo.sh b/nixos/migration/rehearsal-sanitize-forgejo.sh new file mode 100755 index 0000000..6cf9dd8 --- /dev/null +++ b/nixos/migration/rehearsal-sanitize-forgejo.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# REHEARSAL HOSTS ONLY. Run after restoring production's Forgejo data and +# before any runner is started against it. +# +# A restored database still has production's queued jobs, its schedules +# and its Actions secrets (deploy keys, registry tokens). A runner would +# pick the jobs up and deploy to production from the test server. This +# cancels what is queued, removes the schedules and deletes every secret. +set -euo pipefail + +case "$(hostname)" in + rehearsal-*) ;; + *) echo "refusing: $(hostname) is not a rehearsal host" >&2; exit 1 ;; +esac + +db=/var/lib/forgejo/data/forgejo.db +systemctl stop forgejo.service +sqlite3 "$db" <<'SQL' +BEGIN; +DELETE FROM secret; +-- 3 = cancelled; 5 waiting, 6 running, 7 blocked +UPDATE action_run_job SET status = 3 WHERE status IN (5, 6, 7); +UPDATE action_run SET status = 3 WHERE status IN (5, 6, 7); +UPDATE action_task SET status = 3 WHERE status IN (5, 6, 7); +DELETE FROM action_schedule_spec; +DELETE FROM action_schedule; +DELETE FROM action_runner; +DELETE FROM webhook; +DELETE FROM push_mirror; +COMMIT; +SQL +systemctl start forgejo.service +echo "sanitized: no secrets, no queued jobs, no schedules, no runners, no webhooks" diff --git a/nixos/migration/services-data.sh b/nixos/migration/services-data.sh new file mode 100755 index 0000000..10fa6c7 --- /dev/null +++ b/nixos/migration/services-data.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +# asxpio-services: move the data of the Debian/Docker layout to where the +# NixOS services keep it, then let them start. +# +# services-data.sh +# +# is /old-root after an in-place conversion, or the target of +# a restic restore. Moves within one filesystem, so it is quick; run it +# once, as root, on a host whose services are still waiting for +# /var/lib/.data-in-place. +set -euo pipefail + +src=${1:?usage: services-data.sh } +vols=$src/var/lib/docker/volumes +[ ! -e /var/lib/.data-in-place ] || { echo "services already have data (/var/lib/.data-in-place exists)" >&2; exit 1; } +for f in "$src/opt/minecraft/world" "$src/opt/sillytavern/data" "$src/opt/xmpp/state" "$vols/xmpp_database/_data"; do + [ -e "$f" ] || { echo "missing: $f" >&2; exit 1; } +done + +echo "== Minecraft" +rm -rf /var/lib/minecraft +mv "$src/opt/minecraft" /var/lib/minecraft +rm -f /var/lib/minecraft/docker-compose.yml +chown -R minecraft:minecraft /var/lib/minecraft + +echo "== SillyTavern" +install -d -o sillytavern -g sillytavern -m 750 /var/lib/SillyTavern +rm -rf /var/lib/SillyTavern/data +mv "$src/opt/sillytavern/data" /var/lib/SillyTavern/data +chown -R sillytavern:sillytavern /var/lib/SillyTavern + +echo "== XMPP" +install -d -m 755 /opt/xmpp +rm -rf /opt/xmpp/state +mv "$src/opt/xmpp/state" /opt/xmpp/state +for v in xmpp_database xmpp_tackygram; do + podman volume exists $v || podman volume create $v >/dev/null + dst=$(podman volume inspect $v --format '{{.Mountpoint}}') + rm -rf "$dst" + mv "$vols/$v/_data" "$dst" +done +# The online copy taken by the backup hook, if this is a restore +stage=$src/var/backups/restic-stage/ejabberd.sqlite +db=$(podman volume inspect xmpp_database --format '{{.Mountpoint}}')/ejabberd.sqlite +if [ -f "$stage" ]; then + cp "$stage" "$db.new" + chown --reference="$db" "$db.new" + chmod --reference="$db" "$db.new" + mv "$db.new" "$db" +fi + +echo "== Starting" +touch /var/lib/.data-in-place +systemctl start minecraft-server.service sillytavern.service +for u in podman-xmpp-ejabberd podman-xmpp-apushd podman-xmpp-tackygram; do + # Not enabled on a rehearsal host: it would be a second asxp.io + if systemctl is-enabled -q $u.service 2>/dev/null; then systemctl start $u.service; else echo "left stopped: $u"; fi +done + +echo "== Done. Check: systemctl --failed; the Minecraft log reaches Done; SillyTavern on :8000; an XMPP login" diff --git a/nixos/modules/alert.nix b/nixos/modules/alert.nix new file mode 100644 index 0000000..f9af6d5 --- /dev/null +++ b/nixos/modules/alert.nix @@ -0,0 +1,52 @@ +# Mail the tail of a failed unit's journal: OnFailure=alert-mail@%n.service +# Sends through the SMTP account Forgejo uses (sops: alert/*). +{ config, pkgs, ... }: +let + send = pkgs.writers.writePython3 "alert-mail" { flakeIgnore = [ "E501" ]; } '' + import os + import smtplib + import socket + import subprocess + import sys + from email.message import EmailMessage + + unit = sys.argv[1] + log = subprocess.run( + ["journalctl", "-u", unit, "-n", "60", "--no-pager", "-o", "cat"], + capture_output=True, text=True, + ).stdout + + msg = EmailMessage() + msg["Subject"] = f"[{socket.gethostname()}] {unit} failed" + msg["From"] = os.environ["ALERT_SMTP_USER"] + msg["To"] = os.environ["ALERT_RECIPIENT"] + msg.set_content(log) + + with smtplib.SMTP(os.environ["ALERT_SMTP_HOST"], int(os.environ["ALERT_SMTP_PORT"]), timeout=30) as s: + s.starttls() + s.login(os.environ["ALERT_SMTP_USER"], os.environ["ALERT_SMTP_PASSWORD"]) + s.send_message(msg) + ''; +in +{ + sops.secrets."alert/smtp_user" = { }; + sops.secrets."alert/smtp_password" = { }; + sops.secrets."alert/recipient" = { }; + sops.templates."alert.env".content = '' + ALERT_SMTP_HOST=smtp.fastmail.com + ALERT_SMTP_PORT=587 + ALERT_SMTP_USER=${config.sops.placeholder."alert/smtp_user"} + ALERT_SMTP_PASSWORD=${config.sops.placeholder."alert/smtp_password"} + ALERT_RECIPIENT=${config.sops.placeholder."alert/recipient"} + ''; + + systemd.services."alert-mail@" = { + description = "Mail the failure of %i"; + path = [ config.systemd.package ]; + serviceConfig = { + Type = "oneshot"; + EnvironmentFile = config.sops.templates."alert.env".path; + ExecStart = "${send} %i"; + }; + }; +} diff --git a/nixos/modules/backup.nix b/nixos/modules/backup.nix new file mode 100644 index 0000000..8eb05e2 --- /dev/null +++ b/nixos/modules/backup.nix @@ -0,0 +1,174 @@ +# Nightly restic backup of the host into two independent repositories +# (Hetzner Object Storage, hel1 and fsn1): losing one region or one +# repository leaves the other complete. A failed run mails its journal. +# +# restic-backup run hooks, then backup + forget to every repository +# restic-backup init create the repositories that do not exist yet +# restic-backup plain restic against one repository, e.g. +# restic-backup hel1 snapshots +# restic-backup fsn1 restore latest --target /tmp/r +# +# Restoring: RESTORE.md at the repo root. +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.asxpio.backup; + host = cfg.hostName; + stage = "/var/backups/restic-stage"; + textfileDir = "/var/lib/node_exporter/textfile"; + + script = pkgs.writeShellScriptBin "restic-backup" '' + set -uo pipefail + export PATH=${ + lib.makeBinPath ( + [ + pkgs.restic + pkgs.sqlite + pkgs.coreutils + pkgs.gnused + config.virtualisation.podman.package + ] + ++ cfg.hookPackages + ) + }:$PATH + + set -a; . ${config.sops.templates."restic.env".path}; set +a + export RESTIC_CACHE_DIR=/var/cache/restic + STAGE=${stage} + + declare -A REPOS=( + ${lib.concatStrings (lib.mapAttrsToList (n: url: " [${n}]=${lib.escapeShellArg url}\n") cfg.repositories)}) + + log() { echo "restic-backup: $*"; } + + # Last good backup per repository, for Prometheus (node_exporter textfile) + metric() { + [ -d ${textfileDir} ] || return 0 + local f=${textfileDir}/restic_$1.prom + printf '# HELP restic_backup_last_success_timestamp_seconds Last successful restic backup.\n# TYPE restic_backup_last_success_timestamp_seconds gauge\nrestic_backup_last_success_timestamp_seconds{repo="%s"} %s\n' "$1" "$(date +%s)" > "$f.tmp" && mv "$f.tmp" "$f" + } + + case "''${1:-}" in + init) + for name in "''${!REPOS[@]}"; do + if RESTIC_REPOSITORY="''${REPOS[$name]}" restic cat config >/dev/null 2>&1; then + log "$name: exists" + else + RESTIC_REPOSITORY="''${REPOS[$name]}" restic init || exit 1 + log "$name: created" + fi + done + ;; + + run) + failed=0 + rm -rf "$STAGE"; install -d -m 700 "$STAGE" + export STAGE + ${lib.concatImapStrings (i: hook: '' + log "hook ${toString i}/${toString (lib.length cfg.hooks)}" + ( set -e; ${hook} ) || { log "hook failed"; failed=1; } + '') cfg.hooks} + for name in "''${!REPOS[@]}"; do + export RESTIC_REPOSITORY="''${REPOS[$name]}" + log "$name: backup" + restic backup --host ${host} --one-file-system --exclude-caches \ + ${lib.concatMapStringsSep " " (e: "--exclude ${lib.escapeShellArg e}") cfg.excludes} \ + ${lib.escapeShellArgs (cfg.paths ++ [ stage ])} || { failed=1; continue; } + + prune="" + [ "$(date +%a)" = "Sun" ] && prune="--prune" + log "$name: forget $prune" + restic forget --host ${host} --keep-daily 7 --keep-weekly 4 --keep-monthly 6 $prune || failed=1 + metric "$name" + done + + rm -rf "$STAGE" + exit $failed + ;; + + *) + [ -n "''${1:-}" ] && [ -n "''${REPOS[$1]:-}" ] || { echo "usage: restic-backup run | init | <${lib.concatStringsSep "|" (lib.attrNames cfg.repositories)}> "; exit 2; } + export RESTIC_REPOSITORY="''${REPOS[$1]}"; shift + exec restic "$@" + ;; + esac + ''; +in +{ + options.asxpio.backup = { + hostName = lib.mkOption { + type = lib.types.str; + description = "Name the snapshots are filed under; the path inside the buckets."; + }; + repositories = lib.mkOption { + type = lib.types.attrsOf lib.types.str; + default = { + hel1 = "s3:https://hel1.your-objectstorage.com/asxpio-backups-main/restic/${host}"; + fsn1 = "s3:https://fsn1.your-objectstorage.com/asxpio-backups-repl/restic/${host}"; + }; + }; + paths = lib.mkOption { type = lib.types.listOf lib.types.str; }; + excludes = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + }; + hooks = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + description = '' + Shell lines run in order before the backup, with $STAGE set; what + they write there is backed up too. A failing hook marks the run + as failed, but the backup still runs. + ''; + }; + hookPackages = lib.mkOption { + type = lib.types.listOf lib.types.package; + default = [ ]; + }; + schedule = lib.mkOption { type = lib.types.str; }; + }; + + config = { + sops.secrets."restic/password" = { }; + sops.secrets."s3/access_key" = { }; + sops.secrets."s3/secret_key" = { }; + sops.templates."restic.env".content = '' + RESTIC_PASSWORD=${config.sops.placeholder."restic/password"} + AWS_ACCESS_KEY_ID=${config.sops.placeholder."s3/access_key"} + AWS_SECRET_ACCESS_KEY=${config.sops.placeholder."s3/secret_key"} + ''; + + environment.systemPackages = [ script ]; + + # Nothing to back up, and nothing to overwrite in the repositories, + # before the host has its data + asxpio.waitForData = [ "restic-backup" ]; + + systemd.services.restic-backup = { + description = "restic backup (${lib.concatStringsSep ", " (lib.attrNames cfg.repositories)})"; + wants = [ "network-online.target" ]; + after = [ "network-online.target" ]; + onFailure = [ "alert-mail@%n.service" ]; + serviceConfig = { + Type = "oneshot"; + ExecStart = "${script}/bin/restic-backup run"; + Nice = 10; + IOSchedulingClass = "idle"; + TimeoutStartSec = "6h"; + }; + }; + systemd.timers.restic-backup = { + description = "Nightly restic backup"; + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = cfg.schedule; + RandomizedDelaySec = "10m"; + Persistent = true; + }; + }; + }; +} diff --git a/nixos/modules/base.nix b/nixos/modules/base.nix new file mode 100644 index 0000000..e4813c0 --- /dev/null +++ b/nixos/modules/base.nix @@ -0,0 +1,155 @@ +# What every host gets: users, SSH, fail2ban, journal cap, Nix settings. +{ + config, + lib, + pkgs, + ... +}: +let + keys = { + asxpi = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMZ+/5F7SxdTVW47iiStLpGK77oWfR5NgaK4tTSR/aVB me@asxp.io"; + zerrtika = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIELE7hTD4sC5raqjSxy2fXyM+q1CwwVuy9KLFgDR6SFl zerrtika@zerrtika-mac"; + deploy = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGTDPg3mV55lO8uBnvpcGRxJ2vMRP0qB3Pxhg+C8rwj9 asxpio-deploy"; + }; + admin = name: uid: key: { + inherit uid; + isNormalUser = true; + group = name; + extraGroups = [ + "wheel" + "podman" # the Docker-compatible socket + ]; + openssh.authorizedKeys.keys = [ key ]; + }; +in +{ + options.asxpio.sshFrom = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ + "10.20.0.0/24" # WireGuard + "10.10.0.0/20" # private network + ]; + description = "Networks shell users may log in from."; + }; + + # Units that own data start only once /var/lib/.data-in-place exists, + # so a fresh install never creates empty state where a restore is about + # to land. Create the file after the data is in place. + options.asxpio.waitForData = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + description = "systemd services that must not start before the host has its data."; + }; + + config = { + time.timeZone = "UTC"; + + systemd.services = lib.genAttrs config.asxpio.waitForData (_: { + unitConfig.ConditionPathExists = "/var/lib/.data-in-place"; + }); + + # UIDs as on the Debian hosts, so files in /opt and /home keep their owners + users.mutableUsers = false; + users.users = { + root.openssh.authorizedKeys.keys = [ keys.asxpi ]; + asxpi = admin "asxpi" 1000 keys.asxpi; + deploy = admin "deploy" 1001 keys.deploy; # CI + zerrtika = admin "zerrtika" 1002 keys.zerrtika; + }; + users.groups = { + asxpi.gid = 1000; + deploy.gid = 1001; + zerrtika.gid = 1002; + }; + security.sudo.wheelNeedsPassword = false; + + services.openssh = { + enable = true; + settings = { + PasswordAuthentication = false; + KbdInteractiveAuthentication = false; + PermitRootLogin = "prohibit-password"; + X11Forwarding = false; + MaxAuthTries = 3; + MaxSessions = 5; + ClientAliveInterval = 300; + ClientAliveCountMax = 2; + Ciphers = [ + "chacha20-poly1305@openssh.com" + "aes256-gcm@openssh.com" + "aes128-gcm@openssh.com" + "aes256-ctr" + "aes192-ctr" + "aes128-ctr" + ]; + Macs = [ + "hmac-sha2-512-etm@openssh.com" + "hmac-sha2-256-etm@openssh.com" + "hmac-sha2-512" + "hmac-sha2-256" + ]; + KexAlgorithms = [ + "sntrup761x25519-sha512@openssh.com" + "curve25519-sha256" + "curve25519-sha256@libssh.org" + "diffie-hellman-group-exchange-sha256" + "diffie-hellman-group16-sha512" + "diffie-hellman-group18-sha512" + ]; + # Shell users only from the trusted networks; the Hetzner + # firewall is the outer layer + AllowUsers = lib.concatMap ( + net: + map (u: "${u}@${net}") [ + "root" + "asxpi" + "deploy" + "zerrtika" + ] + ) config.asxpio.sshFrom; + }; + }; + services.fail2ban.enable = true; + + # The Hetzner firewall decides what the internet reaches; this one + # opens each service's ports next to its definition. The admin + # networks are trusted, as they were on Debian. + networking.nftables.enable = true; + networking.firewall.extraInputRules = '' + ip saddr { 10.20.0.0/24, 10.10.0.0/20 } accept + ip6 saddr fd69:69:69::/64 accept + ''; + + sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; + + services.journald.extraConfig = "SystemMaxUse=500M"; + + nix.settings = { + experimental-features = [ + "nix-command" + "flakes" + ]; + trusted-users = [ + "root" + "@wheel" # nixos-rebuild --target-host as deploy + ]; + }; + nix.gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 14d"; + }; + + environment.systemPackages = with pkgs; [ + curl + git + jq + htop + ncdu + tree + sqlite + rclone + restic + ]; + }; +} diff --git a/nixos/modules/hetzner.nix b/nixos/modules/hetzner.nix new file mode 100644 index 0000000..5fdc53b --- /dev/null +++ b/nixos/modules/hetzner.nix @@ -0,0 +1,56 @@ +# Hetzner Cloud VM as nixos-infect leaves it: the Debian image's disk +# (sda1 ext4 root, sda14 BIOS boot, sda15 unused ESP), GRUB in the MBR. +{ lib, modulesPath, ... }: +{ + imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; + + boot.loader.grub.device = "/dev/sda"; + boot.initrd.availableKernelModules = [ + "ata_piix" + "uhci_hcd" + "virtio_pci" + "virtio_scsi" + "sd_mod" + ]; + fileSystems."/" = { + device = "/dev/sda1"; + fsType = "ext4"; + }; + boot.tmp.cleanOnBoot = true; + services.qemuGuest.enable = true; + + # Public interface: IPv4 by DHCP, IPv6 static (asxpio.ipv6, Hetzner + # offers no router advertisements). Private network: DHCP, never the + # default route. Names differ between a switch from the bootstrap + # system (eth0) and a boot of this one (enp1s0). + networking.useDHCP = false; + networking.useNetworkd = true; + systemd.network.enable = true; + systemd.network.networks = { + "10-public" = { + matchConfig.Name = "enp1s0 eth0"; + networkConfig.DHCP = "ipv4"; + routes = [ { Gateway = "fe80::1"; } ]; + }; + "20-private" = { + matchConfig.Name = "enp7s0 ens10"; + networkConfig.DHCP = "ipv4"; + dhcpV4Config = { + RouteMetric = 2000; + UseDNS = false; + }; + linkConfig.RequiredForOnline = "no"; + }; + }; + # Name resolution on the local link is of no use on a server + services.resolved.settings.Resolve = { + LLMNR = false; + MulticastDNS = false; + }; + + networking.nameservers = lib.mkDefault [ + "185.12.64.1" + "185.12.64.2" + "2a01:4ff:ff00::add:1" + ]; +} diff --git a/nixos/modules/login-summary.sh b/nixos/modules/login-summary.sh new file mode 100644 index 0000000..902faab --- /dev/null +++ b/nixos/modules/login-summary.sh @@ -0,0 +1,62 @@ +# Printed on interactive SSH logins, under fastfetch: the host's security +# state as the Grafana alerts see it (from the node_exporter textfiles +# written by security-metrics, restic and s3-replicate), plus failed units. +# Reads local files only, so it is instant and works when ops is down. + +tf=/var/lib/node_exporter/textfile +now=$(date +%s) +red=$'\e[1;31m' green=$'\e[1;32m' yellow=$'\e[1;33m' dim=$'\e[2m' off=$'\e[0m' + +ago() { # seconds -> "3h 12m" / "2d 4h" + local s=$1 + if [ "$s" -ge 86400 ]; then echo "$((s / 86400))d $((s % 86400 / 3600))h" + elif [ "$s" -ge 3600 ]; then echo "$((s / 3600))h $((s % 3600 / 60))m" + else echo "$((s / 60))m"; fi +} + +echo "${dim}── security ──────────────────────────────────────────${off}" + +if [ -r "$tf/security.prom" ]; then + age=$((now - $(awk '/^security_audit_last_run_timestamp_seconds/ {print int($2)}' "$tf/security.prom"))) + unknown=$(grep 'known="false"' "$tf/security.prom" \ + | sed -E 's/^security_([a-z_]+)_info\{.*/\1/; s/^security_([a-z_]+)\{.*/\1/' \ + | sort | uniq -c | awk '{printf "%s%s %s", sep, $1, $2; sep=", "}') + failed_checks=$(awk -F'"' '/^security_audit_check_ok/ && $NF ~ / 0$/ {printf "%s%s", sep, $2; sep=", "}' "$tf/security.prom") + if [ -n "$unknown" ]; then + echo " unexpected : ${red}${unknown}${off} ${dim}(see Grafana → Security)${off}" + else + echo " unexpected : ${green}nothing${off} ${dim}(peers, devices, accounts, ports, containers)${off}" + fi + [ -z "$failed_checks" ] || echo " checks : ${yellow}not run: ${failed_checks}${off}" + [ "$age" -lt 300 ] || echo " baseline : ${yellow}last written $(ago "$age") ago${off}" + sessions=$(awk -F'"' '/^security_sessions/ {printf "%s%s from %s", sep, $2, $4; sep=", "}' "$tf/security.prom") + echo " logged in : ${sessions:-nobody}" +else + echo " baseline : ${yellow}no data yet${off}" +fi + +backups="" +for f in "$tf"/restic_*.prom; do + [ -r "$f" ] || continue + repo=$(basename "$f" .prom); repo=${repo#restic_} + t=$(awk '/^restic_backup_last_success/ {print int($2)}' "$f") + a=$((now - t)); c=$green; [ "$a" -lt 93600 ] || c=$red + backups="$backups${backups:+, }$repo ${c}$(ago "$a") ago${off}" +done +echo " backups : ${backups:-${yellow}none recorded yet${off}}" + +if [ -r "$tf/s3_replicate.prom" ]; then + a=$((now - $(awk '/^s3_replicate_last_success/ {print int($2)}' "$tf/s3_replicate.prom"))) + c=$green; [ "$a" -lt 93600 ] || c=$red + echo " replica : ${c}$(ago "$a") ago${off}" +fi + +failed=$(systemctl --failed --no-legend --plain 2>/dev/null | awk '{printf "%s%s", sep, $1; sep=", "}') +if [ -n "$failed" ]; then echo " failed : ${red}${failed}${off}" +else echo " failed : ${green}no units${off}"; fi + +if [ "$(id -u)" = 0 ] && command -v fail2ban-client >/dev/null; then + banned=$(fail2ban-client status sshd 2>/dev/null | awk -F: '/Currently banned/ {gsub(/[ \t]/, "", $2); print $2}') + echo " fail2ban : ${banned:-0} banned" +fi +echo diff --git a/nixos/modules/monitoring-agent.nix b/nixos/modules/monitoring-agent.nix new file mode 100644 index 0000000..eee9df9 --- /dev/null +++ b/nixos/modules/monitoring-agent.nix @@ -0,0 +1,267 @@ +# What every host reports: node metrics, container metrics, its logs to +# Loki on asxpio-ops, and its security state (peers, devices on the +# private network, accounts, listening ports, privileged containers). +# Everything listens on the private address only; Prometheus on ops +# scrapes it. +{ + config, + lib, + pkgs, + ... +}: +let + ip = config.asxpio.privateIPv4; + sec = config.asxpio.security; + textfile = "/var/lib/node_exporter/textfile"; + + securityConfig = pkgs.writeText "security-metrics.json" ( + builtins.toJSON { + textfile = "${textfile}/security.prom"; + vpc_network = "10.10.0.0/20"; + vpc_hosts = [ + "10.10.0.1" + "10.10.0.10" + "10.10.0.20" + ]; + wg_peer_keys = lib.listToAttrs ( + map (p: lib.nameValuePair p.publicKey p.name) config.asxpio.wireguard.peers + ); + login_users = sec.loginUsers; + groups = { + wheel = sec.adminUsers; + podman = sec.adminUsers ++ sec.podmanUsers; + }; + ports = sec.ports; + containers = sec.containers; + # Files a deploy does not rewrite; the rest of /etc is the Nix store + filesets = { + accounts = [ + "/etc/passwd" + "/etc/shadow" + "/etc/group" + ]; + authorized_keys = [ "/etc/ssh/authorized_keys.d/*" ]; + host_keys = [ "/etc/ssh/ssh_host_*" ]; + }; + forgejo_db = sec.forgejoDb; + } + ); + + alloyConfig = pkgs.writeText "config.alloy" '' + // Logs of this host to Loki. + + discovery.docker "containers" { + host = "unix:///run/podman/podman.sock" + } + + discovery.relabel "containers" { + targets = discovery.docker.containers.targets + rule { + source_labels = ["__meta_docker_container_name"] + regex = "/(.*)" + target_label = "container" + } + rule { + source_labels = ["__meta_docker_container_label_com_docker_compose_project"] + target_label = "compose_project" + } + rule { + source_labels = ["__meta_docker_container_label_com_docker_compose_service"] + target_label = "compose_service" + } + } + + loki.source.docker "containers" { + host = "unix:///run/podman/podman.sock" + targets = discovery.docker.containers.targets + relabel_rules = discovery.relabel.containers.rules + labels = { job = "docker" } + forward_to = [loki.process.containers.receiver] + } + + loki.process "containers" { + // CI job containers are many, short-lived and noisy: the runner logs suffice + stage.match { + selector = "{container=~\"FORGEJO-ACTIONS-TASK-.*\"}" + action = "drop" + } + forward_to = [loki.write.default.receiver] + } + + loki.relabel "journal" { + forward_to = [] + rule { + source_labels = ["__journal__systemd_unit"] + target_label = "unit" + } + // Every SSH login (CI deploys) gets its own session-N.scope: one + // stream each blew Loki's active stream limit. + rule { + source_labels = ["unit"] + regex = "session-\\d+\\.scope" + target_label = "unit" + replacement = "session.scope" + } + rule { + source_labels = ["__journal_priority_keyword"] + target_label = "level" + } + } + + loki.source.journal "journal" { + max_age = "12h" + relabel_rules = loki.relabel.journal.rules + labels = { job = "journal" } + forward_to = [loki.write.default.receiver] + } + ${lib.optionalString config.services.traefik.enable '' + + local.file_match "traefik" { + path_targets = [{ "__path__" = "/var/log/traefik/access.log", job = "traefik-access" }] + } + + loki.source.file "traefik" { + targets = local.file_match.traefik.targets + forward_to = [loki.write.default.receiver] + } + ''} + loki.write "default" { + endpoint { + url = "http://10.10.0.10:3100/loki/api/v1/push" + } + external_labels = { host = "${config.asxpio.backup.hostName}" } + } + ''; +in +{ + options.asxpio.privateIPv4 = lib.mkOption { + type = lib.types.str; + description = "This host's address on the private network."; + }; + + options.asxpio.security = { + loginUsers = lib.mkOption { + type = lib.types.listOf lib.types.str; + description = "Accounts that may have a login shell."; + }; + adminUsers = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ + "asxpi" + "deploy" + "zerrtika" + ]; + }; + podmanUsers = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + description = "Service users allowed on the container socket."; + }; + ports = lib.mkOption { + type = lib.types.listOf lib.types.str; + description = "Expected listening sockets outside loopback: proto/port/process."; + }; + containers = lib.mkOption { + type = lib.types.attrsOf (lib.types.listOf lib.types.str); + default = { }; + description = "Containers allowed host-level access: name pattern to flags."; + }; + forgejoDb = lib.mkOption { + type = lib.types.str; + default = ""; + }; + }; + + config = { + asxpio.security.loginUsers = [ + "root" + "asxpi" + "deploy" + "zerrtika" + ]; + asxpio.security.ports = [ + "tcp/22/sshd" + "udp/${toString config.asxpio.wireguard.listenPort}/" + "tcp/12345/alloy" + "tcp/9100/node_exporter" + "tcp/9180/cadvisor" + "udp/68/systemd-network" # DHCP + ]; + + systemd.tmpfiles.rules = [ "d ${textfile} 0755 root root -" ]; + + services.prometheus.exporters.node = { + enable = true; + listenAddress = ip; + port = 9100; + enabledCollectors = [ "textfile" ]; + extraFlags = [ + "--collector.textfile.directory=${textfile}" + "--collector.filesystem.mount-points-exclude=^/(dev|proc|run|sys|var/lib/containers/.+)($|/)" + ]; + }; + + services.cadvisor = { + enable = true; + listenAddress = ip; + port = 9180; + extraOptions = [ + "--podman=unix:///run/podman/podman.sock" + "--docker_only=true" + "--housekeeping_interval=30s" + "--store_container_labels=false" + "--whitelisted_container_labels=com.docker.compose.project,com.docker.compose.service" + "--disable_metrics=percpu,sched,tcp,udp,hugetlb,referenced_memory,cpu_topology,resctrl,advtcp,process" + ]; + }; + + services.alloy = { + enable = true; + configPath = alloyConfig; + extraFlags = [ "--server.http.listen-addr=${ip}:12345" ]; + }; + # They bind the private address: wait for it, and retry + systemd.services = lib.mkMerge [ + (lib.genAttrs [ "prometheus-node-exporter" "cadvisor" "alloy" ] (_: { + after = [ "network-online.target" ]; + wants = [ "network-online.target" ]; + serviceConfig = { + Restart = lib.mkForce "always"; + RestartSec = lib.mkForce 5; + }; + })) + { + alloy.serviceConfig.SupplementaryGroups = [ + "podman" + "systemd-journal" + ] + ++ lib.optional config.services.traefik.enable "traefik"; + } + { + security-metrics = { + description = "Security state for Prometheus (node_exporter textfile)"; + path = [ + pkgs.wireguard-tools + pkgs.iproute2 + pkgs.coreutils + pkgs.docker-client # `docker ps` / `docker inspect`, against Podman + ]; + environment.DOCKER_HOST = "unix:///run/podman/podman.sock"; + serviceConfig = { + Type = "oneshot"; + ExecStart = "${pkgs.python3}/bin/python3 ${./security-metrics.py} ${securityConfig}"; + # Runs every minute: keep "Starting/Finished" out of the journal + LogLevelMax = "notice"; + }; + }; + } + ]; + systemd.timers.security-metrics = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = "minutely"; + AccuracySec = "5s"; + }; + }; + }; +} diff --git a/nixos/modules/podman.nix b/nixos/modules/podman.nix new file mode 100644 index 0000000..90dfa93 --- /dev/null +++ b/nixos/modules/podman.nix @@ -0,0 +1,37 @@ +# Containers, for what has no native NixOS service: Podman, no Docker +# daemon. Declared containers (virtualisation.oci-containers) become +# systemd units named podman-.service. +# +# The `docker` command is the real Docker CLI (with compose and buildx) +# talking to rootful Podman's Docker-compatible socket, so the apps' CI +# deploys (`docker compose up -d`, `docker inspect`, `docker logs`) work +# unchanged, and root, deploy and the admins all see the same containers. +{ pkgs, ... }: +{ + virtualisation.podman = { + enable = true; + dockerSocket.enable = true; # /run/docker.sock -> /run/podman/podman.sock + defaultNetwork.settings.dns_enabled = true; + # Every image update and CI job leaves an image behind + autoPrune = { + enable = true; + dates = "Mon 03:00"; + flags = [ "--all" ]; + }; + }; + virtualisation.oci-containers.backend = "podman"; + + environment.systemPackages = [ pkgs.docker-client ]; + # Podman's DNS for container networks, on each bridge's gateway. The + # NixOS module opens it on podman0 only; CI jobs and compose stacks get + # networks of their own (podman1, podman2, ...). + networking.firewall.interfaces."podman*" = { + allowedUDPPorts = [ 53 ]; + allowedTCPPorts = [ 53 ]; + }; + asxpio.security.ports = [ + "tcp/53/aardvark-dns" + "udp/53/aardvark-dns" + ]; + environment.variables.DOCKER_HOST = "unix:///run/podman/podman.sock"; +} diff --git a/nixos/modules/security-metrics.py b/nixos/modules/security-metrics.py new file mode 100755 index 0000000..8e03f99 --- /dev/null +++ b/nixos/modules/security-metrics.py @@ -0,0 +1,395 @@ +#!/usr/bin/env python3 +"""Security state of this host as Prometheus metrics. + +Run every minute by security-metrics.timer; writes a node_exporter +textfile. What is expected (peers, hosts, users, ports, containers) comes +from /etc/security-metrics.json, written by Ansible: anything else is +exported with known="false" and Grafana alerts on that. + +Never reads `wg show dump`: it prints private and preshared keys. +""" +import glob +import grp +import hashlib +import ipaddress +import json +import os +import pwd +import re +import select +import socket +import sqlite3 +import struct +import subprocess +import sys +import time + +CONFIG = sys.argv[1] if len(sys.argv) > 1 else "/etc/security-metrics.json" +NO_LOGIN = {"nologin", "false", "sync", "shutdown", "halt"} + + +class Metrics: + def __init__(self): + self.families = {} + + def add(self, name, text, value, /, **labels): + self.families.setdefault(name, (text, []))[1].append((labels, value)) + + def render(self): + out = [] + for name, (text, samples) in self.families.items(): + out.append(f"# HELP {name} {text}\n# TYPE {name} gauge\n") + for labels, value in samples: + body = ",".join(f'{k}="{escape(v)}"' for k, v in labels.items()) + out.append(f"{name}{{{body}}} {value}\n" if body else f"{name} {value}\n") + return "".join(out) + + +def escape(value): + return str(value).replace("\\", "\\\\").replace('"', '\\"').replace("\n", " ") + + +def run(*cmd): + return subprocess.run(cmd, capture_output=True, text=True, timeout=20, check=True).stdout + + +def flag(known): + return "true" if known else "false" + + +# --- WireGuard ----------------------------------------------------------- + +def conf_peer_names(interface): + """Public key -> name, from the '### Client ' comments in the conf.""" + names, name = {}, None + try: + with open(f"/etc/wireguard/{interface}.conf") as f: + for line in f: + line = line.strip() + m = re.match(r"#+\s*Client\s+(\S+)", line) + if m: + name = m.group(1) + elif line.startswith("[Peer]") and name is None: + name = "" + elif line.replace(" ", "").startswith("PublicKey=") and name is not None: + key = line.split("=", 1)[1].strip() + if name: + names[key] = name + name = None + except OSError: + pass + return names + + +def wg_table(interface, what): + rows = {} + for line in run("wg", "show", interface, what).splitlines(): + key, _, value = line.partition("\t") + rows[key] = value.strip() + return rows + + +def endpoint_net(endpoint): + host = endpoint.rsplit(":", 1)[0].strip("[]").split("%")[0] + ip = ipaddress.ip_address(host) + prefix = 16 if ip.version == 4 else 32 + return str(ip), str(ipaddress.ip_network(f"{ip}/{prefix}", strict=False)) + + +def wireguard(m, cfg): + known_names = set(cfg.get("wg_peer_names", [])) + known_keys = cfg.get("wg_peer_keys", {}) + for interface in run("wg", "show", "interfaces").split(): + names = conf_peer_names(interface) + used = list(names.values()) + allowed = wg_table(interface, "allowed-ips") + endpoints = wg_table(interface, "endpoints") + handshakes = wg_table(interface, "latest-handshakes") + for key, ips in allowed.items(): + name = known_keys.get(key) or names.get(key) or f"key:{key[:8]}" + # A name used twice is a hand-added peer hiding behind a known one + known = key in known_keys or ( + names.get(key) in known_names and used.count(names[key]) == 1) + m.add("security_wg_peer_info", "WireGuard peer configured on this host.", 1, + interface=interface, peer=name, allowed_ips=ips.replace(" ", ","), + known=flag(known)) + m.add("security_wg_peer_last_handshake_seconds", + "Unix time of the peer's last handshake (0: never).", + int(handshakes.get(key) or 0), interface=interface, peer=name) + endpoint = endpoints.get(key, "(none)") + if endpoint != "(none)": + ip, net = endpoint_net(endpoint) + m.add("security_wg_peer_endpoint_info", + "Address the peer last connected from; net is its /16 (IPv6: /32).", + 1, interface=interface, peer=name, endpoint=ip, net=net) + + +# --- Private network ----------------------------------------------------- + +def checksum(data): + total = sum(struct.unpack(f"!{len(data) // 2}H", data)) + total = (total >> 16) + (total & 0xFFFF) + total += total >> 16 + return ~total & 0xFFFF + + +def ping_sweep(network, passes=2, wait=1.5): + """Addresses in the network that answer an ICMP echo.""" + ident = os.getpid() & 0xFFFF + header = struct.pack("!BBHHH", 8, 0, 0, ident, 1) + packet = struct.pack("!BBHHH", 8, 0, checksum(header), ident, 1) + alive = set() + sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP) + sock.setblocking(False) + + def drain(timeout): + deadline = time.monotonic() + timeout + while True: + left = deadline - time.monotonic() + if left < 0 or not select.select([sock], [], [], left)[0]: + return + try: + data, (src, _) = sock.recvfrom(1024) + except BlockingIOError: + continue + ihl = (data[0] & 0x0F) * 4 + if len(data) >= ihl + 8: + kind, _, _, reply_id, _ = struct.unpack("!BBHHH", data[ihl:ihl + 8]) + if kind == 0 and reply_id == ident and ipaddress.ip_address(src) in network: + alive.add(src) + + try: + for _ in range(passes): + for n, host in enumerate(network.hosts()): + try: + sock.sendto(packet, (str(host), 0)) + except OSError: + pass + if n % 64 == 63: + drain(0.005) + drain(wait) + finally: + sock.close() + return alive + + +def vpc(m, cfg): + network = ipaddress.ip_network(cfg["vpc_network"]) + known = set(cfg.get("vpc_hosts", [])) + for ip in sorted(ping_sweep(network), key=ipaddress.ip_address): + m.add("security_vpc_host_info", "Address answering ping on the private network.", + 1, ip=ip, known=flag(ip in known)) + + +# --- Users, groups, keys ------------------------------------------------- + +def users(m, cfg): + known = set(cfg.get("login_users", [])) + for u in pwd.getpwall(): + can_login = os.path.basename(u.pw_shell) not in NO_LOGIN + if not (can_login or u.pw_uid == 0): + continue + ok = u.pw_name in known and (u.pw_uid != 0 or u.pw_name == "root") + m.add("security_user_info", "Account with a login shell, or uid 0.", 1, + user=u.pw_name, uid=u.pw_uid, shell=u.pw_shell, known=flag(ok)) + + for group, members in cfg.get("groups", {}).items(): + try: + g = grp.getgrnam(group) + except KeyError: + continue + found = set(g.gr_mem) | {u.pw_name for u in pwd.getpwall() if u.pw_gid == g.gr_gid} + for user in sorted(found): + m.add("security_group_member_info", "Member of a group that grants root.", 1, + group=group, user=user, known=flag(user in members)) + + +def authorized_keys_files(): + files = {} + for u in pwd.getpwall(): + for path in glob.glob(os.path.join(u.pw_dir, ".ssh", "authorized_keys*")): + files[os.path.realpath(path)] = u.pw_name + return files + + +def filesets(m, cfg): + key_files = authorized_keys_files() + for path, user in sorted(key_files.items()): + try: + with open(path, errors="replace") as f: + count = sum(1 for line in f if line.strip() and not line.lstrip().startswith("#")) + except OSError: + continue + m.add("security_authorized_keys", "Keys in an authorized_keys file.", count, + user=user, file=path) + + sets = {name: [p for pattern in patterns for p in glob.glob(pattern, recursive=True)] + for name, patterns in cfg.get("filesets", {}).items()} + sets["ssh_keys"] = list(key_files) + for name, paths in sets.items(): + digest, newest, count = hashlib.sha256(), 0, 0 + for path in sorted(set(paths)): + try: + st = os.stat(path) + if not os.path.isfile(path): + continue + with open(path, "rb") as f: + content = hashlib.sha256(f.read()).hexdigest() + except OSError: + continue + digest.update(f"{path}\0{content}\0{st.st_mode:o}\0{st.st_uid}\n".encode()) + newest = max(newest, int(st.st_mtime)) + count += 1 + # 48 bits: exact as a float, and says nothing about the contents + m.add("security_fileset_hash", "Fingerprint of a set of files; changes when one does.", + int(digest.hexdigest()[:12], 16), set=name) + m.add("security_fileset_files", "Files in the set.", count, set=name) + m.add("security_fileset_mtime_seconds", "Newest modification time in the set.", + newest, set=name) + + +# --- Listening ports ----------------------------------------------------- + +def port_matches(spec, port): + if spec == "*": + return True + low, _, high = spec.partition("-") + return int(low) <= port <= int(high or low) + + +def ports(m, cfg): + allowed = [entry.split("/", 2) for entry in cfg.get("ports", [])] + seen = {} + for line in run("ss", "-Htlnup").splitlines(): + fields = line.split() + if len(fields) < 5: + continue + proto = fields[0] + addr, _, port = fields[4].rpartition(":") + addr = addr.strip("[]").split("%")[0] + process = re.search(r'users:\(\("([^"]+)"', line) + process = process.group(1) if process else "" + if addr in ("*", "0.0.0.0", "::"): + scope = "public" + else: + ip = ipaddress.ip_address(addr) + if ip.is_loopback: + continue + scope = "internal" if ip.is_private else "public" + port = int(port) + for a_proto, a_port, a_process in allowed: + if a_proto == proto and a_process in ("*", process) and port_matches(a_port, port): + key = (proto, a_port, process, scope, True) + break + else: + key = (proto, str(port), process, scope, False) + seen[key] = seen.get(key, 0) + 1 + for (proto, port, process, scope, known), count in sorted(seen.items()): + m.add("security_listening_port_info", + "Listening sockets outside loopback; port is the allowlist entry when known.", + count, proto=proto, port=port, process=process, scope=scope, known=flag(known)) + + +# --- Containers ---------------------------------------------------------- + +def containers(m, cfg): + allowed = cfg.get("containers", {}) + ids = run("docker", "ps", "-q").split() + if not ids: + return + for c in json.loads(run("docker", "inspect", *ids)): + host = c["HostConfig"] + flags = [] + if host.get("Privileged"): + flags.append("privileged") + if host.get("NetworkMode") == "host": + flags.append("host-net") + if host.get("PidMode") == "host": + flags.append("host-pid") + mounts = [mnt.get("Source", "") for mnt in c.get("Mounts", [])] + if any(src.endswith("docker.sock") for src in mounts): + flags.append("docker-sock") + if "/" in mounts: + flags.append("host-root") + for cap in host.get("CapAdd") or []: + cap = cap.upper().removeprefix("CAP_") + if cap != "NET_BIND_SERVICE": + flags.append(f"cap-{cap}") + if not flags: + continue + name = c["Name"].lstrip("/") + known = any(re.fullmatch(pattern, name) and set(flags) <= set(ok) + for pattern, ok in allowed.items()) + m.add("security_container_privileged_info", + "Running container with host-level access.", 1, + name=name, flags=",".join(flags), known=flag(known)) + + +# --- Sessions and Forgejo ------------------------------------------------ + +def sessions(m, cfg): + counts = {} + for line in run("who").splitlines(): + fields = line.split() + if not fields: + continue + origin = re.search(r"\(([^)]+)\)\s*$", line) + key = (fields[0], origin.group(1) if origin else "local") + counts[key] = counts.get(key, 0) + 1 + for (user, origin), count in sorted(counts.items()): + m.add("security_sessions", "Open login sessions.", count, user=user, origin=origin) + + +FORGEJO_COUNTS = { + "users": "SELECT count(*) FROM user WHERE type = 0", + "admins": "SELECT count(*) FROM user WHERE is_admin = 1", + "ssh_keys": "SELECT count(*) FROM public_key", + "deploy_keys": "SELECT count(*) FROM deploy_key", + "access_tokens": "SELECT count(*) FROM access_token", + "oauth_apps": "SELECT count(*) FROM oauth2_application", + "runners": "SELECT count(*) FROM action_runner WHERE coalesce(deleted, 0) = 0", +} + + +def forgejo(m, cfg): + path = cfg.get("forgejo_db") + if not path: + return + db = sqlite3.connect(f"file:{path}?mode=ro", uri=True, timeout=5) + try: + for kind, query in FORGEJO_COUNTS.items(): + m.add("security_forgejo_objects", "Rows in Forgejo's database, by kind.", + db.execute(query).fetchone()[0], kind=kind) + finally: + db.close() + + +CHECKS = [wireguard, vpc, users, filesets, ports, containers, sessions, forgejo] + + +def main(): + with open(CONFIG) as f: + cfg = json.load(f) + m = Metrics() + failed = 0 + for check in CHECKS: + try: + check(m, cfg) + ok = 1 + except Exception as e: # one broken check must not hide the others + print(f"security-metrics: {check.__name__}: {e!r}", file=sys.stderr) + ok, failed = 0, failed + 1 + m.add("security_audit_check_ok", "Whether the check ran (0: it failed, see the journal).", + ok, check=check.__name__) + m.add("security_audit_last_run_timestamp_seconds", "When this file was written.", + int(time.time())) + target = cfg["textfile"] + with open(f"{target}.tmp", "w") as f: + f.write(m.render()) + os.chmod(f"{target}.tmp", 0o644) + os.replace(f"{target}.tmp", target) + return 1 if failed else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/nixos/modules/shell.nix b/nixos/modules/shell.nix new file mode 100644 index 0000000..f133739 --- /dev/null +++ b/nixos/modules/shell.nix @@ -0,0 +1,101 @@ +# Interactive shell: zsh as on the admin's workstation (asxpi/nixOS, +# modules/shell.nix), minus what only makes sense there. +# +# Every account logs in with zsh, including ones added later, except +# those that run other programs' commands through their login shell: +# deploy (the app CI's SSH scripts are bash) and git (Forgejo). +# root gets the same zsh with a red prompt ending in #. +# +# Interactive SSH logins show fastfetch and a short security summary; +# scp, CI and `ssh host ` stay quiet. +{ + config, + lib, + pkgs, + ... +}: +let + summary = pkgs.writeShellApplication { + name = "login-summary"; + # Read-only reporting: an empty grep or a missing file must not end it + bashOptions = [ "nounset" ]; + runtimeInputs = with pkgs; [ + coreutils + gawk + gnugrep + gnused + config.systemd.package + ]; + text = builtins.readFile ./login-summary.sh; + }; +in +{ + programs.zsh = { + enable = true; + enableCompletion = true; + autosuggestions.enable = true; + syntaxHighlighting.enable = true; + + histSize = 10000; + histFile = "$HOME/.zsh_history"; + + shellAliases = { + ls = "ls --color=auto"; + grep = "grep --color=auto"; + }; + + # Blue for everyone: [HH:MM:SS] [user@host path] $ + # Red for root: [HH:MM:SS] [root@host path] # + promptInit = '' + if [[ $EUID -eq 0 ]]; then + PROMPT='%B%F{#ff2020}[%b%f%D{%H:%M:%S}%B%F{#ff2020}]%b%f %B%F{#ff2020}[%b%F{#ff2020}%n%f@%m %B%F{#ff2020}%~]%b%f %B%F{#ff2020}#%b%f ' + else + PROMPT='%B%F{#0055ff}[%b%f%D{%H:%M:%S}%B%F{#0055ff}]%b%f %B%F{#0055ff}[%b%f%n@%m %B%F{#0055ff}%~]%b%f %B%F{#0055ff}$%b%f ' + fi + ''; + + # Fresh homes have no ~/.zshrc: never offer the new-user wizard + shellInit = '' + zsh-newuser-install() { :; } + ''; + + interactiveShellInit = '' + setopt SHARE_HISTORY + setopt HIST_IGNORE_DUPS + setopt HIST_IGNORE_ALL_DUPS + bindkey -e + + zstyle ':completion:*' menu select + zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' + zstyle ':completion:*' list-colors "''${(s.:.)LS_COLORS}" + zstyle ':completion:*' rehash true + + bindkey "^[[H" beginning-of-line # Home + bindkey "^[[F" end-of-line # End + bindkey "^[[3~" delete-char # Delete + bindkey "^[[1;5C" forward-word # Ctrl+Right + bindkey "^[[1;5D" backward-word # Ctrl+Left + bindkey '^R' history-incremental-search-backward + + ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8' + ''; + }; + + users.defaultUserShell = pkgs.zsh; + users.users.root.shell = pkgs.zsh; + users.users.deploy.shell = pkgs.bashInteractive; + + environment.systemPackages = with pkgs; [ + fastfetch + bat + eza + summary + ]; + + environment.loginShellInit = '' + if [ -n "''${SSH_TTY:-}" ] && [ -t 1 ]; then + ${lib.getExe pkgs.fastfetch} 2>/dev/null + ${lib.getExe summary} 2>/dev/null + fi + ''; +} diff --git a/nixos/modules/wireguard.nix b/nixos/modules/wireguard.nix new file mode 100644 index 0000000..96c9058 --- /dev/null +++ b/nixos/modules/wireguard.nix @@ -0,0 +1,65 @@ +# WireGuard, the admin network (10.20.0.0/24). asxpio-ops is the hub +# every peer connects to; everything else is a spoke with ops as its +# only peer. Keys come from sops: wireguard/private_key and, per peer, +# wireguard/psk/. +{ config, lib, ... }: +let + cfg = config.asxpio.wireguard; +in +{ + options.asxpio.wireguard = { + interface = lib.mkOption { type = lib.types.str; }; + address = lib.mkOption { type = lib.types.listOf lib.types.str; }; + listenPort = lib.mkOption { type = lib.types.port; }; + hub = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Forward between peers, and masquerade what leaves by the public interface."; + }; + peers = lib.mkOption { + type = lib.types.listOf ( + lib.types.submodule { + options = { + name = lib.mkOption { type = lib.types.str; }; + publicKey = lib.mkOption { type = lib.types.str; }; + allowedIPs = lib.mkOption { type = lib.types.listOf lib.types.str; }; + endpoint = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = null; + }; + }; + } + ); + }; + }; + + config = { + sops.secrets = { + "wireguard/private_key" = { }; + } + // lib.listToAttrs (map (p: lib.nameValuePair "wireguard/psk/${p.name}" { }) cfg.peers); + + networking.wireguard.interfaces.${cfg.interface} = { + ips = cfg.address; + listenPort = cfg.listenPort; + privateKeyFile = config.sops.secrets."wireguard/private_key".path; + peers = map (p: { + inherit (p) name publicKey allowedIPs endpoint; + presharedKeyFile = config.sops.secrets."wireguard/psk/${p.name}".path; + persistentKeepalive = 25; + }) cfg.peers; + }; + networking.firewall.allowedUDPPorts = [ cfg.listenPort ]; + + boot.kernel.sysctl = lib.mkIf cfg.hub { + "net.ipv4.ip_forward" = 1; + "net.ipv6.conf.all.forwarding" = 1; + }; + networking.nat = lib.mkIf cfg.hub { + enable = true; + enableIPv6 = true; + internalInterfaces = [ cfg.interface ]; + externalInterface = "enp1s0"; + }; + }; +} diff --git a/nixos/secrets/asxpio-ops.yaml b/nixos/secrets/asxpio-ops.yaml new file mode 100644 index 0000000..16d673e --- /dev/null +++ b/nixos/secrets/asxpio-ops.yaml @@ -0,0 +1,68 @@ +wireguard: + private_key: ENC[AES256_GCM,data:LQCY+qmReruZq6MncXi4GVtOcepdKrRtVNasDypPcDanSJCP3WodkoIvUBw=,iv:7vIp5nXFdGJDhLM2EwlOURdNe5J7sdLiMco8arJ9NcM=,tag:DCpYVgye5lpajr38R8BaSA==,type:str] + psk: + asxpio-services: ENC[AES256_GCM,data:+9fbEpiN9/v/LOo5elE9vgf/LtHiXbtSk8mLA3jO6MNm7cL/15JfO3dVIcI=,iv:kaLHJGWSY/zU6la0Zn4yOy3227pfndJwuwQgzKY2PsE=,tag:zxuSC1kKHmQvOAuNu1RJ0w==,type:str] + laptop: ENC[AES256_GCM,data:SOxn70zQZYKvLPujEsAwDUUMZNktjCvpJWlHDMJwiDpV7LGCMauOMes6CJA=,iv:B7XSDYN6xutuPlw5E+wTKRVZsijn1SuIfJChhkLpKwg=,tag:q+buR6EteMb5xTUBPvbcnw==,type:str] + aleks: ENC[AES256_GCM,data:nwVZu2OPFmI/2XwWMNU7c86Q+7dc2BAXSS09tZ7nLI41Po7Bo8WqzLJi0Qg=,iv:2un7bBl6oIEdtEN4duoUwWxfyagzc7i2lfhuIsZDgHc=,tag:tUSC8Bcoc4Frc5iINHWsIA==,type:str] + zerrtika: ENC[AES256_GCM,data:dAMNd/6ZQcr9Mc38T1arAUx2/7AZ4cOjOF9eLFCcq/XFp//crUYLzckxMdA=,iv:LDGowS6mLxSpzL4HYQwNoCqYc3gxojM4NPIz2DM5sxA=,tag:W2L0fvTpJPZLk92qpJ6StA==,type:str] + sanya: ENC[AES256_GCM,data:ADseOffYnm1Qe8KUEpz5IdI0d02Etp4A4tryLWbtsSIHnibsRjcOkRuItmw=,iv:AN0EFoyP4jv3zvBsNcy5lLLMtl010Z8q8XhW0fHz5Wo=,tag:hBk0gnAlY/CpgUMxwkcl1Q==,type:str] +restic: + password: ENC[AES256_GCM,data:kbJPWViSUnCpAhZSS4eth49p3O39NfD+F7LbSCC2zeSovVvhQm0ZRR729MQTG5ZIWWtsudsNa0IOItuVnELYJA==,iv:AofzidHezaQgh7CbgfEm412FMNYM9+dAbfy9QK51CsU=,tag:NtYYAQ9MY3kI7D68KURkZA==,type:str] +s3: + access_key: ENC[AES256_GCM,data:FP2fd/z9nPCaiygGjml8NGFZ56E=,iv:BjmnSe76TT/48W9Sg5zr3RPKZsZh0CyrI16bb+6Q9qs=,tag:79cUqfuDPbekVEWABFlXZA==,type:str] + secret_key: ENC[AES256_GCM,data:nVD29xv5KG9tBQ23StYJabhrIZ5qD7N2izVzFzMhJTUgadn2w2VcuA==,iv:9i7hqhp94OAICBmr2XUN/HRGh9uT+ADM+meyhKoqaTg=,tag:PR16m2a8i5eToxOz6HT7Mw==,type:str] +alert: + smtp_user: ENC[AES256_GCM,data:6oII4loTinr9vw==,iv:yLAzF8531Gr26mf/96TLZGqRc1lhHdQUUDCW/dyVQnQ=,tag:xv5CsVaM7V5BuutcNYSqhg==,type:str] + smtp_password: ENC[AES256_GCM,data:HINfBIr0O+wsKNXBoi8J0g==,iv:prdeqDok8pKoM6Y1fA6l5TiA6oAWCO3I6J9wfWHh2qc=,tag:OEmC7YK7rCeyfCiZ02Tn/w==,type:str] + recipient: ENC[AES256_GCM,data:A9/PHo22F0yorA==,iv:ijDj2jCIMgg11G9OJcAWMdc2SqYIlwYtXy2scxwM6bU=,tag:LIoFCmV6zHSLJMrDTXI1/A==,type:str] +postgres: + asxpio_password: ENC[AES256_GCM,data:h8pGH1J5CvaHVyj+dgSgiVLluPU0NrjI/5Ec,iv:IM3Fy5Ws6gVv3kI2zWNgL7EHUvG2F6+5Zyzq4nEWmNU=,tag:uRq1uwDRShoxc24B+lKecA==,type:str] + bingo_password: ENC[AES256_GCM,data:q36cANya1mBLFJMJVklWwvF9rBgqZAQXei15uwYDxnWmV6j8iL0kontjfNVeLiC4Xw2FYl4CKaoAxZrWWn4Q0Q==,iv:c+hwHpaEG7sbepRxLc65CQTbo7G9t+E6AvFsRBK6xiU=,tag:qTuvNuaPCHv7jpF7uDNNOw==,type:str] +garage: + asxpio_access_key: ENC[AES256_GCM,data:8jHxbOE+tJXOo7A2mxnXti/Aerw=,iv:cMX099BXZAYHvdkHhdB6sIO4Qknffmez+2rm/Y/iLcQ=,tag:xFYMWRyd1smqTa6iVb7RBw==,type:str] + asxpio_secret_key: ENC[AES256_GCM,data:qvxDJQc+QaH41sQ48vn1sdhyeuLvLR1Q0mIFOevMw8JzW57mdEqaZw==,iv:jn7QUzVdhBSXF+VM6YY6ZUPBXQSc2sKiaoWzFxbFzuk=,tag:NRoMrpdTZ0FyA/mns5kLQg==,type:str] + bingo_access_key: ENC[AES256_GCM,data:z1Lg+VC6zrPllh16kjOkFmVFZCo=,iv:YnnLMn4gHPjjz1YW1Qwk2OV9qRjB3kNRbs8YcrJj4Ds=,tag:s1QARkLaN0WVe1hzv0azqw==,type:str] + bingo_secret_key: ENC[AES256_GCM,data:cRvbSAbTpSDjWAf3m0bO/OshH7R+UHALs56AIH1S0MjwALbKEpu45A==,iv:sf5jd3vhzkRdIXn0uZbmbBsw/OVzt2vTaoL7KTWg+0s=,tag:6uJSU7keAunxbUyQnWa8aw==,type:str] + public_access_key: ENC[AES256_GCM,data:axLNYE8qmPu///yKbe7Cm34CRJo=,iv:8mTgX8O4esiRGAVRgYXB1VUZYYTPCBXCnEOYrd8dlRo=,tag:2oXheUarM3QLI9CCFT81VA==,type:str] + public_secret_key: ENC[AES256_GCM,data:ILSF2qjM+mgISR1WLsNuCX+3XM5qbKL7G+eNwzacqCh8jMGP/d/+Og==,iv:Fmy6UATg6VhWoD9hWJGdfJUWVCkuvMJbZEGuUmBodvQ=,tag:ao4qTeyZuryTKqh6he+Eww==,type:str] + rpc_secret: ENC[AES256_GCM,data:gkrIbnvdphm8jtJNLuUFdf54pnzP7nGCikSmekyleXnTKRoMLBOVsOu3s9CszuxAuUcAq1uIDQ0iBNqndoSxGg==,iv:QwCF4lu7Ow6XQvD/uCnH8Q+cj83y+c3scj5gdWPmOKY=,tag:3Mr+Ftype46pj5Ao/La3ig==,type:str] +forgejo: + secret_key: ENC[AES256_GCM,data:NhpAWN91Xx/on053Fu8umJlMtv+spTviQPnzvJ90Vf8CyAf2VJHH+511rFYN8cvKEQFzm3ZveYt3uWaHvXQ2BA==,iv:/oSq9prYvmf+svpBp5MajHOeMRsTGirdVI0o/IuvVZg=,tag:xbWoymew9DwvaFPOJ4GEtw==,type:str] + internal_token: ENC[AES256_GCM,data:qow2LO6Y8qLqV+3VxFS0n8EpCZThD3m9hE3TQetwumV5pmXfXUZHHvI/d0BFZ3QrDOYzaTR/AEtwR9h5mMbCIHsdpb5EhDuEyhQuhvTQRodZMYk98JDzJeUHmHRmJcoXKIReLKj3YAJH,iv:ff7obgtcK0lDlvIeIaLnYRFmN2UWzacO+dMXutLEElc=,tag:KZWHQ7w3MuE/VaPt0QETcg==,type:str] + jwt_secret: ENC[AES256_GCM,data:FrUsNHdtCjbmhshDmu2wn32vuvuY0KqD3mBHNE916utPPlI3yrNlta1MYQ==,iv:EljVZ1Fbj4tvDz0woZQSi0k6+S42lmZeI1NVNySfhmI=,tag:ndngQibprv3PV0uz34nyeg==,type:str] + lfs_jwt_secret: ENC[AES256_GCM,data:YQoBJaSDGtjqLI5eSFfzuTHebgn+xdhHmcy7K618rie09+4swl8YHWqGtA==,iv:CADpHPHXr0v4wfHJuiR4zd8G/0n6TF5P3FjT7Q0+wk8=,tag:96VH3Nz1Kr8s+THRb4k/cg==,type:str] + smtp_user: ENC[AES256_GCM,data:Frp6Gvni2ecnyg==,iv:VoIgipZO3U/QZb/GBvFMBBMYfeSTdjr1znNSyvMlIXY=,tag:rVAhZECBavqvZ0GXbdFygg==,type:str] + smtp_password: ENC[AES256_GCM,data:H4rSCFToHO+SPAYbUqSHWw==,iv:+nf8yx7QpFcN5UgAqbh4M66qKgUaz884yzap5WIlgIs=,tag:qp7Zj8J4lEYQWC2MkBTYbw==,type:str] + metrics_token: ENC[AES256_GCM,data:uSxdasf2F6wkmMPUt3LV5zuvKX+318sVzGSn8OGEZzCb5aiqu41ZsDB42IJVCaV0uc/4e9RVMbbwGNW9eW7QbQ==,iv:3Qym+ze3VcqKt7qeQ1UUWMJcZH9OEgQ27q9DBcsJZbc=,tag:Z3AXANIgTZvxJd1geQuO2w==,type:str] +traefik: + letsencrypt_email: ENC[AES256_GCM,data:0mUeZJPIgc8RqQ==,iv:PJp5HlV+G9d6WCz2SAX5+r3k15S7p6emexC1WV9t0XE=,tag:H7ingKTQysJ9XjOj0k+5ow==,type:str] +xmpp_cert_sync: + ssh_key: ENC[AES256_GCM,data:a9bq3BV3bZGJTE5HxXsfrmikRD6taRtU5XzvBP8wp5B45la6BF5+FDEzfePiM5yOt3ADzyQ6BWnQcPta1an7GT6m5JDB2uaamwXOUp8WVGhjYHMnT3JA20MaYGcxvJrDGf343lLYDB9W2BgRmq5vqb+TfTkQBErVLuX993V2N+lIofiFpd4ECfj0DILDr/fmPZjqXJDUkYd4ThzrTxRaI1q7BlpS6g8A1e8mAqCE0MP8Rw1LKS9jshq3nZfVHTeHyc5H1pbwHLKpvZiFK2QRzciwi7wojdf+k8wndv0WobIkWVCZBb0Xj8OU4oEkWIqW6iLrjblZqR/+y95pZIXvYsqur7x2jPHec4+MQWHB+e48SWQkrliO0+IIVYux24qX2sUP5nlKz1Jel5H5W663fL3KjwS8edYRdP+/GLAuNOoBQHnrhcm51UTblQ+EeHHD1IHkStqrNGhuZF0cJOb943ZJgKzF5UjPehpReWCjof5oOH7MUaw6wXBjOn21//5Qkt3vZbDsv2vT5r7Yg+/hL5C9QBXD6aI3yqqx,iv:r5mUE1DF0ExgBsvR5/jelib0LjLXlLybKW/HglomW3A=,tag:yVIWEGCSKmkcMnlvnmNyYw==,type:str] +monitoring: + grafana_admin_password: ENC[AES256_GCM,data:nhSYTSzq6tCfEdU4eTHku8ZWVCx7UyMJUSJZ2RG4d3AAs3fOxqvpi1YT8w==,iv:v5wp3az7oLjSyrF5RTocdGtgzCXPlYR0khRFRFw8678=,tag:ck7h+cSq+nvvPCVYaRTEwA==,type:str] + hcloud_ro_token: ENC[AES256_GCM,data:GL3ru0ssGOR530ffoGlLYbpLmeajZGLNj1PpqeeC0Y6bUH5Rv+Q6nppwRP3j5ScLeHCLlfqmU0VfmM4Y4CUETw==,iv:tf0efbuEZZ9gJu4Hy2M2IyeyGGih7ahOdMLmgoEN1rI=,tag:G9/3EKb7xDnzAXaI03T2hg==,type:str] + grafana_secret_key: ENC[AES256_GCM,data:xPdxBlKT/7wHulnye5JU6qU+/yE=,iv:HH1cjij7u9Z9Zl1WNAlv/Yfy6mvhnGvJIF6vqkjucRs=,tag:mhwjw/mg3MNSgEv61nfVdA==,type:str] +sops: + age: + - enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBpU21HQUEwR1p1SEV2ZTd3 + UUYyTUZiWkI3QTB4aUVyc01pMkhXTHNiY0U4Ck55eU1UYU9YVEZGNkZMYWtoMXNI + a3ptbnpXa1dBQWxTd1VIL0M4WDE4YWcKLS0tIHpFeUsxOVZYQ3kwMjh5cVNWM05Z + ZGZlV25wQkZXa0NkdFRxTkhqVlZhRVkKYNZ8ogVmFT+siK95PqtPVBT3k8GhMDs8 + JqOFjeameRWCjhKbh0A9yUwowj28aOnY3KmtSxOF1qz9nCh6kwUFIQ== + -----END AGE ENCRYPTED FILE----- + recipient: age19xvmm6j3h2u6mc3w6k65ufry4p5aa5lwu96p55h3e42p9wfzwc0qp2w7pk + - enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBHTXQxWkNiQjVRSi8wUlNR + S1VOWVNwcjRNcUtya2JaMzZLSDNSMUFFZzE4CmpCRjJZSnV0bEtoeXQraWgwT3p2 + dk5OVG13OWpoYzJnVVZxUndYanBZR0UKLS0tIFM4bisvVUkzalloOXhMUVJONHZV + aG5JenFCQzRGYmxSQWVrTithQWFqQlEK6GvBeneRrInRyYha39B91UwM8osz2et4 + 3Sxn5Hwx3FjksTfS4rHwefQQA7CS+2vr7KUrqGZill6ZZSfBNDE50g== + -----END AGE ENCRYPTED FILE----- + recipient: age1jxcl9cwk64wak2gyzf22vm3dpj80wtl76c7krywlrj7jjxftscrskrg3tf + lastmodified: "2026-11-17T00:23:59Z" + mac: ENC[AES256_GCM,data:ciM+RKwSbU/Y31HoCaRm3ZZdaxaVOm7m5N5zTnS/N0PnFhQPvMa4dF/pZPNJn4cGwd6kCyGlx7RKuSU/xVxJ8T+7b80GUyMPeVZAV2TXjP7ns4fHdEl97yuo0QY4Xot8Hmkm523IAqKRj+5VD4U+9HH1I29BPYw0gPdvQwYlYrc=,iv:pYXBo6ShAjHS7/imYrjlmJo1vHk0YzgOmwAvJS0pe+Q=,tag:VJ6ts8vBZdb60yQ03LxW9g==,type:str] + unencrypted_suffix: _unencrypted + version: 3.13.3 diff --git a/nixos/secrets/asxpio-services.yaml b/nixos/secrets/asxpio-services.yaml new file mode 100644 index 0000000..3d5f69a --- /dev/null +++ b/nixos/secrets/asxpio-services.yaml @@ -0,0 +1,42 @@ +wireguard: + private_key: ENC[AES256_GCM,data:yuKROw9E/ZGxvD8SpHNJTF3+4ucioI7H7AmQOAs9yAcmzpmsTrcl/Fde+Mg=,iv:U2OyQNjgbm1MJaJ0XVp8j7GCB/ud33VGaAUfqYaUleQ=,tag:yYNQ2AgMk1y3E3Djv0PCzw==,type:str] + psk: + asxpio-ops: ENC[AES256_GCM,data:APQ0XxFgKHXBHB8SC5g3RJ82qgGOF1UAJBVv3wD1U2ocEd/SrrXXb8tLm2E=,iv:soHT9kwZWLnA4DMv9gWBGL8BxNyGjNVotODjtX6lV+w=,tag:zq1ty7uGagQANP9Nioi2bw==,type:str] +xray: + config: ENC[AES256_GCM,data:T+LtvbyNfSJBOeqpEma1rbekOev08iPZ1OMYSZUVaziCgaO8CpFe/9D7HAAUq5NQLPYwPAU70+1hWsGp3HafewBILlKqjvqLxeOE8V4Wo9KkUEDyO3cfnqAxVzB27cKPXiJuXy9jbgUhjNe/WJmfjg7D5+5PS9SoWg5fOGAsIH8NvmyC+kUXIWgWIm74Ur8gmij3lBsYTN4019cJ2TR2LqUfB/+o4bXyx9eVblpz0AD2gEiY3/p9BkSBj7LNaY8dRI4Prb4VQfe1sjs+91zSxWCEX5aiCOQP6+C8H8UViYPIFYUtPR+8REl6OyWi4MdKPcauwxU75QQ6bSEfyThx1v57w7zaBL7woA1GUMsD0enwfZaz8Do8Qt65gvUInftkNpRDE1c4dbp70vjjlXfr96QNj4H/kQe9542FHQUpQnl3/L/lNxM3jLfvEOx3qBdsEWVxTLhgfRYgHPZEZHB45O0hqCSMFBJMjhMpOsSW8t9wXfJDgkv+vqLNnvs2KeU4RWnNux2Q9Nl81JMUdhgGo4f6CbT+4QnPeIdcnoHmp5BoAj59KQrf5xaMV+obodDXhgxXisziAG0jqXmOXYut7d3F/ZK2usMTAkIwpwSBSyEmTLrFH18KdevcmDdAd1NktyoMMytEAgRGE+Yl5nq9wM06bk5fh8tBa+Lv/JkJpCbD2kfQFqzqGe6LopkX79bXnPo81cy0g2+gOf0zEhmUcii8oVqUyyi36z6OdImFAvnzdtdXs6BJWFWOtmMWoRDadN4T8qQtxpFHlz2SkwcwkZ3fcosUICCdZHbKQfhHnVY+RtG3ABmjh05ROJdbCcdYqAPBARoA1REDOs6/2l/+FVlrcq3wnypr3FYfz51Bn+tOHQggeNrEXbXZ4ZsDLPkQnMVT/pmd3+HevzeNAqVuuBQvPM0fguMmqQYZE178VlkFsBkCe6HwzBIjAGaiVAdAdgaXwoO6hnopEmc/VBzORDFcSH1E4Ku5EoXA5QoPApP+BL41vRVA1dKDT1aKKCRnr11bOxAT+K5Bg2NJicJCt/OUdvBsISgTHbYmD9h6r1YsK0qTIEr/EtqyU9MlKy7SOry8vZd7c6IMgJiGJiI5kkD7OJANI/qBexO9SxUlov/ilZwUBd4fCPTVi4UbmQHDSV2Hw3As7mr3Wnbf2j1TFxttGlQYWRO7qKWMp/NvlRDJFBIjCM2fiYIHfzEfPDVPT+zfwA==,iv:q4jVWu3NfZxyQUJ7Zum4V3m8MpSUVsykc86EGZnP/LA=,tag:0VKGQUYTpTprRZ2Tbb2H1Q==,type:str] +restic: + password: ENC[AES256_GCM,data:b+ViaiPXsCIHMfzsZJqNwgmAmApXJUSCDeMeDdUUGl0dsQ4QcqVqb+Cc3VVe+GlOclaIgDOrY7taIwJ9XVeB5Q==,iv:6QO1X40RNIr6LtkK0SqkADXVQlgQ6IVKfEhcZ9Fe7KU=,tag:Wil0V3hohq+Wi2pFvjjFWA==,type:str] +s3: + access_key: ENC[AES256_GCM,data:tyyumc9S3A/Ub1k84Zc3tcCaEpI=,iv:NbUSp4bhrAyGZg7Y9jNiO2EFubbBZoBgyUjaQWeR4+g=,tag:WY+97S6fRdoJ2z71O6MH2A==,type:str] + secret_key: ENC[AES256_GCM,data:Jwpfn2SiDDCn70SuZ0HeaOLB1RtOFcAEEwp6tZjSPJJ3X3i79IfNug==,iv:vUupx7ENUi6EgyysfZxfCE+DvL/YJqN5W4qJTkgxYaA=,tag:qBdPrzpojaK5/Ucl4f2f/g==,type:str] +alert: + smtp_user: ENC[AES256_GCM,data:2OYs4VNPzaBOxQ==,iv:NZ3BUyiSdkYlxYVcQgGo2Rl4CUGoxJ/org4QvC9fVYc=,tag:uTNW0Rhaq6KBtPJWsqCjNw==,type:str] + smtp_password: ENC[AES256_GCM,data:MUeLpmXun4fS1FY8VBhrrQ==,iv:FtbuiZV6RN+3e+ZvI6ppgb40QZUUndibiR5RGvc0ltY=,tag:1RRahZSiqDPmdV0VgvpD/w==,type:str] + recipient: ENC[AES256_GCM,data:eFXuk/bzDdwMsg==,iv:Hyfv0w7MgLyIzEIV0hRffsvdrTZd5T6gEXl7lYGLVJY=,tag:S8QMDEQJtERbxlBQrfMhNw==,type:str] +runner: + token: ENC[AES256_GCM,data:0sUd8lSJUh2v2WQSsTvch0gkPTKJrkp59PFWMh1LRDbtx7MH67Gt3A==,iv:8xkt+41O5w/HDtX3nMWl5+z/Edwk5fbaUigSFQC+qf4=,tag:ntELGgQQT4HvQeGQnBHqAg==,type:str] + interop_token: ENC[AES256_GCM,data:ezityqViAdLEwFmJvqHms0OUjCTjMTdbeq35IATEDd5311mtN6IZEA==,iv:94u24cW4Rh0TBdXmof6TkJu1s32fTwAN6tgToRpNnBg=,tag:GbX5sNReoafxPJsUpfIWug==,type:str] +sops: + age: + - enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBmU2I2NDhWclZ1TnpuSFpN + dmF0R3VRNU5ROXhXUzMzc24zKzkxQnViWTEwClVNTFltNzZ1RWQzRmpjRys0azlV + RGN2L2VrOCt3SVVQZ0FyMFlWL1hJNFkKLS0tIGlOMjBURmdQOUZyQnRJLy9uS2FC + aHNGaXdWUTFYOTlZRWJ6cmpnMVFOc1kKOeK30pZiIW8Kj8CSV5HPMJXgvXsa/1hl + rkAasN9kK8I+A+/f939FdBgG1tFzU5m9ee+pMsL4fqAiNLDvnBCyYA== + -----END AGE ENCRYPTED FILE----- + recipient: age19xvmm6j3h2u6mc3w6k65ufry4p5aa5lwu96p55h3e42p9wfzwc0qp2w7pk + - enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBuZDVLb1laajJXYTF5b0o3 + NnVHM1BTcVhXTi92dWNxazFKSm5WYkl1WFhJCm5uMFdOejBQZEJMN1h2SXVNOWww + THhsM1h0Y3IyaFNoNEh1dmh1Y2pONHcKLS0tIFlhRTFoUGVnZ0dTRVpwa0hQbjFO + NWpFSWRvRjFzd2xkSnp3U1lvODI5R1EKUXLBHjR8Mxo63Vgr1XurAli7rirmhKTa + 2hjT1+bvAAgGpacmjFqqsoACQpMdjl86wco+mFZBL7D9Tc3e4TvMzg== + -----END AGE ENCRYPTED FILE----- + recipient: age15ws8alg3ftsgmzvqxft09556g87s4n8c8v39nmvhaz6k50gp4e7se8acmg + lastmodified: "2026-11-16T19:03:07Z" + mac: ENC[AES256_GCM,data:dgvS/jxSClrDOjHV1GukH2lxuISSbfls+qMab1QnpBUqt+0CycCQVXNUiNye2gm3tUeVwgmPgsDpS0ie4eHODXO9zgU60jufUZuNGdkqnAiFfPnQXAGGDJLlQb+QSFoJgz+gboYlGDjyWpe2ucXm8zd9KreXHwQnNQZrBxH0FbU=,iv:i0aHyG9svB5Lfs8HFi1kBXeRV4mRdVoEbPQAmgqCgdc=,tag:6GX0JdQCF+fcoBfhPjsOMQ==,type:str] + unencrypted_suffix: _unencrypted + version: 3.13.3 diff --git a/nixos/secrets/rehearsal-ops.yaml b/nixos/secrets/rehearsal-ops.yaml new file mode 100644 index 0000000..34a2278 --- /dev/null +++ b/nixos/secrets/rehearsal-ops.yaml @@ -0,0 +1,65 @@ +wireguard: + private_key: ENC[AES256_GCM,data:+3PtBGDBPf+n7NDPOipmHHKDe/doHVGIPd7bnp8fhqifVdjxbYDQoDRYYxw=,iv:8bsXcGVOTechmWNVl8P9ZigAqhP1b+IKAFAuHxJ+dN4=,tag:B2ysVrViv0eGVzom0zIncg==,type:str] + psk: + asxpio-services: ENC[AES256_GCM,data:kEkyRP87uH9rxCvm+ny+TZ5H3k6522egipIKtC7QuiS+qiLTexQ21O81FN4=,iv:fGo9wsRuy3LfKOhZDuShZaoCATMR6GAn18UPtwGjXUQ=,tag:i0dWMtt+LL/iN8qFUCKUIQ==,type:str] + laptop: ENC[AES256_GCM,data:4UoNNtwYBGQ30mrKnWZDnxVc5IIwd8IJnxTUdT1WSobq5+S8zuvG0hLGM6w=,iv:GcTfX7HSipNmWc1osWmuPF1A/4X/6zgvzsgd28INxFY=,tag:Is+4ylonzAuYSHUYkd4zlA==,type:str] +restic: + password: ENC[AES256_GCM,data:KbutI62YpvVH2/D1Sru6,iv:JSQXHnFuJBZQQJqQg0OV9JdxZqEeU37wg2oylrmJn7I=,tag:wRJQ6lZtmZbRdcDlOnHHvA==,type:str] +s3: + access_key: ENC[AES256_GCM,data:jS5lAcnkXEWY2NEcrgz/,iv:Aj3JB0Vl9Fl48fILIsatQqMmUg4gJlVBjaHclNzxnsA=,tag:MJ7EkWodP4r65cgJL5PkKw==,type:str] + secret_key: ENC[AES256_GCM,data:SBcQ+wDpts+ZoXaWFV/v,iv:yzdX7ZBrwHxjlIGlmBf5L5xGaA6z2JTfAiA+/cl9vN0=,tag:ggQ1Q2KhsViGLddn3f+QSQ==,type:str] +alert: + smtp_user: ENC[AES256_GCM,data:zC/uLUsNtcjcgeRqxX7dKuHZ20sYXC5qDg==,iv:BORb+IZ0liuuSkJ/SEKH1ODAdPP0Krk1dgzs3s1+Qg8=,tag:mlkcvX3/N3qfi60T7CTIzA==,type:str] + smtp_password: ENC[AES256_GCM,data:tm0lKVPNReWzHM6CSRWQ,iv:cQRbeAPcIRfdefsGhqz9kRTs49T0aPEPlJbCspw7s7E=,tag:DSR/D7t2lLb6DRCYH2GeKg==,type:str] + recipient: ENC[AES256_GCM,data:MwSUWfKT7v5oNQKTGm6ZboZJ5uwt/A==,iv:ZAos4tQzsuj6slfXkLnVCERKctnC+wtxEvw9l3jCcds=,tag:oUtprN6MdGJTNO8W/fqUVQ==,type:str] +postgres: + asxpio_password: ENC[AES256_GCM,data:2xhZDqQWrJhV4o4+VYpiRVpiiiznDtYrTMIRoNrmEVs=,iv:jGi3vyOg/WBMvIIfIQVoJxXJxc7eXP5Yz7zSwValO/M=,tag:XkpVl0QcbCLSgXAZ76I2cw==,type:str] + bingo_password: ENC[AES256_GCM,data:MO+8VUINZMyQz30UCXIlx84Vniyv6dvBEslliFAYYoE=,iv:wFV0rx7bw5hvEQuyhXv80mSReCSXC77uMPhbxc82Qa8=,tag:yNbXFNj+9SJeZcaSO6rZlg==,type:str] +garage: + asxpio_access_key: ENC[AES256_GCM,data:3mtBNKwG+utyLSimWhxc7BAxvC9ogI7VfDSoJrcVLB0=,iv:/zgX/pc0BPCApVJD/09SF32qCTm+IB2Mk5ydOMv6Z/s=,tag:0PjNNj1Ae+4a1GOZTDIOqg==,type:str] + asxpio_secret_key: ENC[AES256_GCM,data:z6rLprWXshsH3XnK28uEqfPDaGJamW9gQbb5rMuCtVY=,iv:0nBmvsFgGZr45lySAgjoAgf+KhYSCxAgS467ei53108=,tag:i9WY9rj35/iil/Q6W30YdQ==,type:str] + bingo_access_key: ENC[AES256_GCM,data:Y0ZQsK/KumX+ir7FC3DlbdV7UN1t4vzHtzfAnosgVfo=,iv:i0s8YVTOhhRixaSmJVIF5P24rF1gU/8fjoR7RHn5/f8=,tag:hMB6DN3HkpvSZhwZQr28CA==,type:str] + bingo_secret_key: ENC[AES256_GCM,data:yKKXyOxi/sr5Nqqg8pGA8x0XXrdjDaePFxqb3WP3Ss4=,iv:KiNIGHsE/hYs28j7tZMLRWt24QkbrbvSKn2KnD3i+J8=,tag:hMAzSR87RqT65yikriRsAA==,type:str] + public_access_key: ENC[AES256_GCM,data:sT73xqcg2ZLiYMqd1fasyapxqBQ6HGq/jdIk2JbRkq4=,iv:ypQyuz+O4FGZbvDobml+vr2z0MDvEcrDooTjKD6uqk0=,tag:nAZm76/JLTHMbDlU0BXnqA==,type:str] + public_secret_key: ENC[AES256_GCM,data:4B6J7wpJLBYSM+H4z3WatO24la8UYbxRYutzrcUmB9Y=,iv:Y9KHJsf3N/+yGeELw2I4ejNR0oeS8e/TLWJbUa0qbRE=,tag:sL6ODhQHSsQQv/uRNqk3Lg==,type:str] + rpc_secret: ENC[AES256_GCM,data:Uelv13vsPHYFhr/f60MKY7zR9HODi8EJZ6zsEyNLG3nEXzVOlWRqyCxZIsFeoM/S0o0EfyMH2dC+/6hLKzJifw==,iv:mGM2OK3De27FT4xX9lvXPK601NLZADcbot8MqbultoY=,tag:YxztR/ZpQUU5b/H1alWClA==,type:str] +forgejo: + secret_key: ENC[AES256_GCM,data:w/GkpP/8X6YG11Sfy5f3BoeN1CJycEuQfI8LWgjk1WA=,iv:RQMkjF2m+SIcAuumzJWd+Oi7d3v0I0ZhV6Vsdk2wVlU=,tag:7fjbTi7tftry0pNU6swpjA==,type:str] + jwt_secret: ENC[AES256_GCM,data:MdztCbG0J76qPgkDzUxwnYccmC3cHTSi07x4+Mo436r/eLO88UFuUpbwFQ==,iv:bKPLDSnKh9g1sIwn7sJS+ULSzwOCSpnyGRgWqQADrIg=,tag:aWndLj+pWTmcPIIkZkQiUw==,type:str] + lfs_jwt_secret: ENC[AES256_GCM,data:dTFtLBp2IwQT47ttq1c/BCMdOfFmucOma3h8EDjg0JINWa29p6MOiVqaPw==,iv:z4Z4dgpEtGttxEO/J3bINTtwNaQTBTgdm7yUs/DyDJk=,tag:AWhAEUrPiJp+eA10qPmGVw==,type:str] + smtp_user: ENC[AES256_GCM,data:nDb2aHuzpGrI1oLXUfN28BzpZxa6RDhcXfVWrKkZajw=,iv:UPbztzd4DskSGxsgaewiOOtKL3Fl2ixVBuVkesPdRwM=,tag:gLvl0Gauf1zTSoiIfKHveQ==,type:str] + smtp_password: ENC[AES256_GCM,data:Z+grwJY+laJ7gXofpqO8evyVlSXCRgEkgGHGpoo5/W4=,iv:FIlHHxofd7ZautCtHAe+xiCyWUy5eT9w4/PtljWwpw8=,tag:Lo7M38k/rzLpZe6r4K+aRg==,type:str] + metrics_token: ENC[AES256_GCM,data:6pp3/k6wi+UraWlWft6ns16OjvX0cWUo0EegsNY1LmQ=,iv:qKtM9Gz4ozjXLi8HnJf3w5i3FE9r1889VBYBUFLpz7A=,tag:BKGmncQcQaiUJIetsfYlWQ==,type:str] + internal_token: ENC[AES256_GCM,data:yFi0mqzutad4X0yVKA1u7oE3SB2na3+eN7DF9AI4LpBpIKD0nDf8c4CCbBvEbLRP56zuRW+NteGSvFgAALdlOB+HIvb+1zAn8DRRjZu+M/U=,iv:falRgW4WLk6PB9ICTAjffbmxRsUKRZiBjxnq20cNTcU=,tag:SuuSxYe+eOqxBAexh2oMNA==,type:str] +traefik: + letsencrypt_email: ENC[AES256_GCM,data:3tZhdsKwE0m5LMAqh453Oz/+lzhN/MErWg==,iv:yP29+EnYDadPZbYcXVL5XTYW4Uqf4zODzWpLI1r+ub4=,tag:d33uL83/bA9eHUD056XPhA==,type:str] +xmpp_cert_sync: + ssh_key: ENC[AES256_GCM,data:mV4yXFb9cvsOEoti2Rpl8QZiT8IMLMlGpGoeUfEOwquygLEEc/Ctc22x+Zjl8U3iEZik9ZDYtew6UkIjd2bkqyGjvz+uY7iFBrEIJTK0GxJl7t8xXQ6B2lc1fFZPWJDi9uHxbjDsqPwwVVFpt2tDQpJ43VHy7p6OOehQgIHiFDjyAGbpFD+IMN+3Z5TZWEfjlu5cFvJPQufJYanKhSclRR23NOyn1EUYZd6aXckz9x169o+1x8e3b0niZjkVdjgjdIfAENjiC0+GDFzEDvWib3P1j8gAdUW5YSA3ekPmmXraamIUDcv+ofRb1zu40Rcpk7Rc7DX0zHH2cNeB3SUEFKEBOJnM1h7p9yMzvYly2FxOAmMPGP76H5/xYEf3gxBD+mHMTygjmZnhFyqX52V0ML46wlrq9n4epa+xigh/IIbNLmz6Hk3z2X/b/tiEmSf0aIiIajvtCn8uYvuDYi8CIMAD+1gODjB3WJdKpKR3xLBF5Vi5XgDPrN8LbtpwYTxlqDCccW3VWB0ZdUZHjieDyOckOcvgvafUymtRQgopszfVUd4=,iv:paNOYweMsWHCV/Rg61K4/VxQCkcSU1/TBQjYCnzTe3M=,tag:LHagTSw5Jq7nQVIHEVfviQ==,type:str] +monitoring: + grafana_admin_password: ENC[AES256_GCM,data:RKCJOitUrbMT9+rPvF1iTHfDA8tjYTvid4k5SNpKNobmjXD9Qd13JQ==,iv:iXSZ1SAbDRkWMd0eorCkY79B2atzKjGwK9QnCWQ+TXQ=,tag:5QSbonnUCqthqc9EBXOJmA==,type:str] + hcloud_ro_token: ENC[AES256_GCM,data:nxiFpPD/QUn0jgFdCjrLtXlT/KG4zkBRMwpgxFCwjcEwz8b1tk93Sw==,iv:ioKZ7eX9G5AxVrdQyNySKfQ/e9dr640MhPoXbz0JaCc=,tag:t6HYdXkS0lExvIz+YhnL/Q==,type:str] + grafana_secret_key: ENC[AES256_GCM,data:tK99AS/MgNhZoweGXpVMwSLjjM8+zQPTj05gOXiJYBqwlsxJK6feGQ==,iv:yxLmezKIVt4vqwVwsBd1ztvLCgkriISFN4Db8QPs++c=,tag:0xPwFYMlQkZNTlCZRya+YA==,type:str] +sops: + age: + - enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBpZEZIUzZVWU5TNUlWVXdX + aGIyRVhCb25BdGxlK3AvcTBjMWRqeWFXWFhRClVjZHgwZ1dLVnEySi9FdlV5Myts + anA1aysyYjh3S0Q2ZksyK0luYktqVFUKLS0tIDA3WEVLMFVkajhzQVJwNi9kSGc1 + VjZsaWRuUGJnN2JZdncyY01hb04xNE0Ko0GKw0FHJETlil7W8xbmqoJnnimpQHw3 + E7C4HeRPaDvG+OcYpMH/ukIRHsQkiDc5KL80COM7AS/ZDK0IeNNPhA== + -----END AGE ENCRYPTED FILE----- + recipient: age19xvmm6j3h2u6mc3w6k65ufry4p5aa5lwu96p55h3e42p9wfzwc0qp2w7pk + - enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBXRHFyWmRPdEI0VktmdWQx + ZkFMUDh2RFgvWkhpKy9iWEhqdVpzSVBZU3lJCmExYktHemxNUGFUMUZtQ3NNc3E1 + QUE4UEZDU3J5VTdyRnA2MFFDUnY1a2cKLS0tIEYyTnpWdC9tQ3Fmb013REc3Y0Ez + UjkrQnZaUFpUQlB2ZEhYUUxQckdKM28KXsP1eTtI/512vxqfhB3zitJFzFrA78kY + Bez9GS+nbC/VEfTrAjd+uCKcj5hzYRvjF6HIvX97qMCPVFIwmhlXIg== + -----END AGE ENCRYPTED FILE----- + recipient: age1hfaf7h2h43ahhql8zc6u3yr67yx4utnrlw57h6r32wnm4axvzves8pcl0r + lastmodified: "2026-11-17T00:40:51Z" + mac: ENC[AES256_GCM,data:GfJBC73iJcXVroSEXbRhYPE0CrHANiPccWe5fCGx9ZzgeaBStCLDfSk2mkLmWsn/M87UzSTxus95Y09JojGmSwhgnoMfrVc26T/WuiyfJj4r4J7K83E/HR6XsIckc1xBcc6I9dbbvHRIhPj23hjz9jTbt5oa0/f5Rhj5I5u6NYE=,iv:gWwtV2tMWdmssSQ9iH54FTntNb4jDuzZNOrlge9qi5k=,tag:VIDg7swKFuB5KAGNyjaiWA==,type:str] + unencrypted_suffix: _unencrypted + version: 3.13.3 diff --git a/nixos/secrets/rehearsal-services.yaml b/nixos/secrets/rehearsal-services.yaml new file mode 100644 index 0000000..e473378 --- /dev/null +++ b/nixos/secrets/rehearsal-services.yaml @@ -0,0 +1,42 @@ +wireguard: + private_key: ENC[AES256_GCM,data:cnprcM/YYHqjFXi10VevcRWr/X6IJ/n+W/s219nKLKWioFrJrKxiyy+Avy4=,iv:cfb2wftlCrNEXheeSbBzBQFTrBRW90W7cJ7NA+Y48j4=,tag:rUzhF7dR3JX2hVrNG6Cuzg==,type:str] + psk: + asxpio-ops: ENC[AES256_GCM,data:aQxf1iS3dwy3gK/WGJQCMKGhICbTi6NKSM+pxYqg6OkzQrSIR2YPMmoWYnQ=,iv:3IUW0DVOrnfW/SZhYM3BVq4fUm2KNwoBVx0n/DlMyPM=,tag:TCglE8molI8WA1DEFEt3Zg==,type:str] +xray: + config: ENC[AES256_GCM,data:eYP+HL3aPTZAsvHNNAk19YeQfyzFDWwSeTLNkvBfFseyHLIUJpvgQ5MxB3eCBvDA3jbOQ9zZnDuDqeSpsfdm/QDlssCbkQQyU+A6+iS82+xOIkvDcns9g0paUFugfLOJa1p1agLMiqgi3Kz+0VMap2Nw2kwaGAreXrKngMZ1DAa5zE/WdyD+eD4zRmUG9Z9cvTkAga9KndEadpDRJLMr6VmauwpqDKgjqttJmvEnqg+4x6/A,iv:/1jU8vkraPgAALRrQkSTJy73E9qsKPLDLaMIMnSpq5Q=,tag:htJ3UZd7MySUEzRyfMDbZQ==,type:str] +restic: + password: ENC[AES256_GCM,data:jgeMSNlqyJWYoCYtqHfg,iv:puPQYTYk/fs+WoQs8VYZeIb9bX/3s2wyl8yn/815Aa0=,tag:Mu6xBfQzM4W5IY4I8uz+fw==,type:str] +s3: + access_key: ENC[AES256_GCM,data:AJYd7gM6Vg6Ewe1EhBWS,iv:F0y9p7FppQG3cfgZufcfcAEWwMEcXDyS5n+OQWw4Sho=,tag:f/fRchi7tOEg3HZeE8v++Q==,type:str] + secret_key: ENC[AES256_GCM,data:1o4xUAk9lCTKyjgA6yp6,iv:bZjPL3lZ0bGqQ4oft/urwIFjYTfgDf/2Qs5PeD53hxA=,tag:BRUOpHBAaZC5u5KRfHGYIA==,type:str] +alert: + smtp_user: ENC[AES256_GCM,data:GjrmbNdhQW4OxGZopwxImouX3+OlI9ITVA==,iv:L6M50N2ueJ6TvErr8OCRSwsIiMR4tvROfWqeqpRjGSA=,tag:V69vqNgUQ9Ht6P0Q/p+BIA==,type:str] + smtp_password: ENC[AES256_GCM,data:9vaW7csqXSzf4dG1mjQa,iv:tr5tftd+7bor27BRD3DL7iOhQeb8gMrGgUsC4DZ271M=,tag:tchVoYgKwXuuWI1yDGi/Rw==,type:str] + recipient: ENC[AES256_GCM,data:JarmuqFMM3C2K2ctzYtTyEk2V9m+RA==,iv:MGZDIvkoISphn4FEmYynoQXkN4oTOoBztNJB77jLrtU=,tag:CNH8FxBKRKIhGONjFI/wsQ==,type:str] +runner: + token: ENC[AES256_GCM,data:tzn3NaRCT+Dm3JaRPiht9zRyzU1OssLKDTaUk3JcDK7CbR8G6aB3VA==,iv:7czzYJOTQNMpRgt61fKTEsclU1HsbbpQA24kDDPjttY=,tag:ZHdAmTXidprSdfJxFEnrdw==,type:str] + interop_token: ENC[AES256_GCM,data:ul8ureU=,iv:ZxSJTSQWzaxmYkfRGgYbvtxCe3HSCbmh383e1XfAi5c=,tag:vG2AhibHpHWkMl6kNVmk4A==,type:str] +sops: + age: + - enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBFbXU5c280OHU3ckFsQVNF + dFRVZ2RRcFhtdzF0MmVoVUR5NDdJRmZ6L1FvClQ2SWpHMlZPVzZlK3o2MTRNcFRT + OGxoT3RMV2FyVkNFczBIZ1lxd2dFMDQKLS0tIDlad1FqK3ZaTSt2VU1qV1BjQWFi + b2thTVpXTjlQVENhaU13alM2M3orM0EKKOJKCj+7E179iinCfMmnmlevsq+MBYzi + S69orRnYRk2EIeiLs7Pu6zfPOT3ni4NTuAxlYohuyJdUz5GefT0p/Q== + -----END AGE ENCRYPTED FILE----- + recipient: age19xvmm6j3h2u6mc3w6k65ufry4p5aa5lwu96p55h3e42p9wfzwc0qp2w7pk + - enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBycXBqb0dNZlJxS2x0ME9I + dnJ0dWpickdQcHdreDIzL1RmdDZTekxRVWtvCjlrWkFaYUZpWHlpcjhYd2dPR09r + SUJoTEI2YVdyV0p6RnhtaGZFRDg2N0EKLS0tICtwckRQaWtnNFBlQzZUM0ROM0hz + WU5KOVpkR1JVLzNzWXdkdTJPN1hLLzAK0OZbTcXa2fLqJcKMKFQVOoCUT9SLeEzS + TAGv1m7E3iWqIfMypX6bGD1TIFEBbVbwN9EzOXMqYRdo6e70vf3CUQ== + -----END AGE ENCRYPTED FILE----- + recipient: age1au6f8m6l245ddrunqf2a62xprnlevn9yrducynlay2tgknfxeeusj94j5l + lastmodified: "2026-11-17T00:40:51Z" + mac: ENC[AES256_GCM,data:zIvQ90qP1C+IkMaTnw9EKWHxNZYAi3IeRcNlB8wNk4D3ITWnLzd44CSkNlT6D/S399wBbdxodiUBt2Hd/8Tyk9l3Cuz+Qbz6YQ1k1Tk9AIDMrq8ktQJbi+/InHSjC6DkHBWFlRmw6ir/QWMsCZqXP4QW7R7JFU6NHO4T5Y67KCg=,iv:fuPmBtukuhw7c09jIJ1Gv1amHKTEAyYcWE0/7n7FtqY=,tag:EDtcov4LOIfRtSM6ihV8ZA==,type:str] + unencrypted_suffix: _unencrypted + version: 3.13.3 diff --git a/renovate.json b/renovate.json index 8edb1a8..0ab4a13 100644 --- a/renovate.json +++ b/renovate.json @@ -14,11 +14,22 @@ "# renovate: datasource=(?\\S+) depName=(?\\S+)\\s+[a-z_0-9]+:\\s*\"?(?[^\"\\s]+)\"?" ] }, + { + "description": "Versions in the NixOS config, marked the same way: # renovate: ... above `name = \":\";` or `name = \"\";`", + "customType": "regex", + "managerFilePatterns": [ + "/^nixos/.+\\.nix$/" + ], + "matchStrings": [ + "# renovate: datasource=(?\\S+) depName=(?\\S+)\\s+[A-Za-z_0-9]+ = \"(?:[^\"]*:)?(?[^\":]+)\";" + ] + }, { "description": "Runner job images, pinned in the labels: docker://:", "customType": "regex", "managerFilePatterns": [ - "/^ansible/roles/forgejo_runner/(templates/config\\.yaml\\.j2|tasks/main\\.yaml)$/" + "/^ansible/roles/forgejo_runner/(templates/config\\.yaml\\.j2|tasks/main\\.yaml)$/", + "/^nixos/hosts/asxpio-services/runner\\.nix$/" ], "matchStrings": [ "docker://(?[a-z0-9./_-]+):(?[A-Za-z0-9._-]+)" @@ -37,7 +48,8 @@ { "description": "Runner labels name their line (node-20, debian-12, python-3.11): never leave it", "matchFileNames": [ - "ansible/roles/forgejo_runner/**" + "ansible/roles/forgejo_runner/**", + "nixos/hosts/asxpio-services/runner.nix" ], "matchUpdateTypes": [ "major" @@ -47,7 +59,8 @@ { "description": "python-3.11 / python-3.12 labels stay on their minor line", "matchFileNames": [ - "ansible/roles/forgejo_runner/**" + "ansible/roles/forgejo_runner/**", + "nixos/hosts/asxpio-services/runner.nix" ], "matchPackageNames": [ "python" @@ -57,7 +70,8 @@ }, { "matchFileNames": [ - "ansible/roles/forgejo_runner/**" + "ansible/roles/forgejo_runner/**", + "nixos/hosts/asxpio-services/runner.nix" ], "matchPackageNames": [ "python" @@ -75,7 +89,8 @@ { "description": "Both label files carry the same pins: one PR per image", "matchFileNames": [ - "ansible/roles/forgejo_runner/**" + "ansible/roles/forgejo_runner/**", + "nixos/hosts/asxpio-services/runner.nix" ], "groupName": "runner job images", "matchUpdateTypes": [ @@ -101,5 +116,14 @@ "The deploy job that applies this shows as cancelled; the next run confirms the result." ] } - ] + ], + "nix": { + "enabled": true + }, + "lockFileMaintenance": { + "enabled": true, + "schedule": [ + "before 6am on monday" + ] + } } diff --git a/terraform/.gitignore b/terraform/.gitignore index eef07c5..4ed7134 100644 --- a/terraform/.gitignore +++ b/terraform/.gitignore @@ -16,9 +16,8 @@ terraform.tfvars .terraformrc terraform.rc -# Terraform directories +# Terraform directories (the lock file is committed: it pins the providers) .terraform/ -.terraform.lock.hcl # Crash log files crash.log diff --git a/terraform/.terraform.lock.hcl b/terraform/.terraform.lock.hcl new file mode 100644 index 0000000..0bc2893 --- /dev/null +++ b/terraform/.terraform.lock.hcl @@ -0,0 +1,68 @@ +# This file is maintained automatically by "tofu init". +# Manual edits may be lost in future updates. + +provider "registry.opentofu.org/aminueza/minio" { + version = "3.46.3" + constraints = "~> 3.11" + hashes = [ + "h1:BucOu+t3X1LSQzolHrWUE4+tPoMEi/C+fjeOLxilysA=", + "h1:CHKkCVQ4mARCFbTl3CHOKZg6tLDIXhE4xBTY9/H8998=", + "h1:DOOZypFT5G5fknb5U4Kp59WeYZU1OgiBOaZq2xljW1Q=", + "h1:JufolSPtuQatY/9D0+V3iplgvlVPqd2hoU5P4QIyziM=", + "h1:bmRxF3I9fP1xokjhQB0K2ujFtidd3UNp88k/DBjR1lE=", + "h1:c8Kzjx+0EnpV37xtpfoxI/7GckVrLx0dmIfDuAx2CF8=", + "h1:cJr90p040Vk8J8DVEKvTtxdDr+uLkcA4Na6gfJdLfeQ=", + "h1:cRpLvfM+mNNsvLIgeogpn2MKkko3v7HtcYEBYxP9elI=", + "h1:jQfBea+ntcQk0eIXfJodo8Yrvs+8R7+1ejidKaNZXR0=", + "h1:luMw2XWKS2a8yi/yIqn2qAw2rLAdAkNnbIHapkzpT9c=", + "h1:o+nzoc77gQN6pqPUGa1q17r35usD1k9LbIMiAibg4q4=", + "h1:syn1oZHCH6mydfTks8+aWfs2oWQNF3ii3HvSXuA5oJM=", + "h1:tUraLqzJBd5KAyxz2wVSSqMWc8oh3RmBbZaoFHvg+w0=", + "zh:01733c14f9d0724c404a258b668732f99f86ce16e65747902f7e51fb276fffe0", + "zh:127371a47bd643ca3a84523f1426c00e81195e3f10e30c7bdb8ca7987cc3c7ef", + "zh:1b27dad321fbdd550d328a63bc85093c72281a6af91ad6d249bbf15774dd91dd", + "zh:6c28ac386489ed904d1cf88382d21dba4ca749b1da6fcb1a3ecb11c0d6234f9f", + "zh:7cced05a3b2f26a03ad76cc13f655aab842f26db38a47a72020ff2ac7fcede47", + "zh:87cd6395207e20f532891902e44f2fdb92028669176cef7a8a30f1dc33d2e50f", + "zh:94c299b67007310e0e57892465ae54c9591749376916782e242dad3ecf9c7332", + "zh:95537fd6ccf778917c25e25fcc2c75a0599210db993e23dcf1b4c5c8eae7d234", + "zh:be52ecb44f323cce598e85084987948e2d3c6f07bf31250c372f28503831d4b8", + "zh:c3e0f2bdde045b27ea3ad14d65d5f595e2e48fa4b840c4fd1d107d3330fe49a0", + "zh:d63c68cc4cf30d3173a3207f95460d8882b79c3679ee51e45b008dc734df1d89", + "zh:ef6a3f439cc877133597251953cffd6ed3574039e1a4efd241f6ecb232baac5e", + "zh:f426a35a940ae70aa2c2931b691700c8285c8af49a2d8060df8031ed2a567ee9", + ] +} + +provider "registry.opentofu.org/hetznercloud/hcloud" { + version = "1.70.2" + constraints = "~> 1.70" + hashes = [ + "h1:2eVvib40d9ki4E/wvPnT2wXxM704YjBRVxkozKHGTCs=", + "h1:BZWdJOileBlR+WMz0D0wrJXFhNLJpHcQJIgDqmPNlpw=", + "h1:EV7uBBPrEpNz8gJJ//iyBUu9/Tt+JJKjL3D3f9xVzX0=", + "h1:J5jjFM74jJrhwWKRdyQNFC3Ef7pbFBkLXGxbLSXheks=", + "h1:RYD1e858eOJstFN/bf9KonHtltMycZKIcYu7ngyiIRE=", + "h1:UB3bnUROLsLu1hreopppKw+Wm22//b3YZtM1k/SLloM=", + "h1:VB4xF79qoFHtcdxvEcajWgJZLJ59/uvbCReraaEHwqM=", + "h1:byNVX40XzpAO0MRuyxipatu4RWPfWKZ4Mf6PKyz0Tjk=", + "h1:cRkaW7N60DfWVvMhD8QtH2MdDDQzNOAJs0Gr5cmzwlE=", + "h1:eYR/chP/jFcSQlmPcfFBktyxZsoJuYRlJ57pOLVq1/k=", + "h1:hxmW37pH+dIDMH+9JQ9GSwjZg72SfvKIWUeJctmcy1M=", + "h1:qwPVmCN5bLh/2MjvsoatZhBvsvD8Nhs2J8OySiYN17M=", + "h1:wechRCpT64RPYT0BGWlkj/Y59BQa/qhO4elGaAlRpBo=", + "zh:05a474ecd2b019be03f857877c9bf1eca8f96c0897f6e76b91780adf3a8dd388", + "zh:1d4e4c0525c02618c015c079dc3e8d8b693ca796d698f95b59c4412114cbf166", + "zh:1f3bc703423f08a295e3e8f6d39c3f155e672da5e20b9a143ef7e7a465be37e3", + "zh:20ced3eec332b587a998ad3d87da322736aef49cb7e561a545a57f9a08000050", + "zh:619152b472b9ac266046db9d0c3f85946559ce0791bcb6fc78d278bb555d4572", + "zh:658a84427cc6b5385d68e1506678498dd7d3d04c0cf3410e3f2278c05b247ade", + "zh:6d9be3d79479345d21cef66e83002086153189535c82ab299d6ca5021aec7d0e", + "zh:72b0d26aadcc422ccb17e7a89abf92dfbe52dca6fc80025a934d7c4e058888cd", + "zh:865c0dc4912a5009f7b8c7ff374d47e496f9cfe96cbcebadc48f3434b7c12b46", + "zh:99f3f0778398d7348e5ab7dab42de0c918339a5250d140b6959272e50be4e372", + "zh:b3df6415bbe0f7021f94bff9e640c42e6d45b4a459ded3d267f10e2104a77760", + "zh:e7645b34e1aa45cb17dc473b33d7fa4d60e81d7e14332c7b04bc97535c867074", + "zh:f60b3e67be5cafe10001bb556ae7693e4a7696fb6946294643182946b36117f9", + ] +} diff --git a/terraform/README.md b/terraform/README.md index abc1138..3cb9f6a 100644 --- a/terraform/README.md +++ b/terraform/README.md @@ -1,6 +1,9 @@ # ASXP.IO Infrastructure -Hetzner Cloud infrastructure managed via Terraform. +Hetzner Cloud infrastructure, managed with [OpenTofu](https://opentofu.org) +(`tofu`; the dev shell of `../nixos` has it). The files are plain HCL and +the state is the one Terraform wrote; `.terraform.lock.hcl` pins the +providers and is committed. ## Servers @@ -11,10 +14,15 @@ Both have delete and rebuild protection. Hetzner's server backups are off; restic backs up the data instead (see ../README.md). Both servers carry `prevent_destroy` and ignore changes to `user_data`, -`image` and `ssh_keys`: cloud-init only runs at first boot, and hcloud -would otherwise replace a running server when those change. Edits to -`cloud-init/*.yaml` therefore describe a rebuild, not the live machine; -day-to-day configuration is in `../ansible`. +`image` and `ssh_keys`, because hcloud would replace a running server +when those change. + +A new server boots Debian and converts itself to NixOS: its cloud-init +(`cloud-init/nixos.yaml.tftpl`, one template for both) runs a pinned +nixos-infect and reboots into a bare NixOS, about three minutes after +creation. The system's configuration then comes from `../nixos`. Edits +to the template reach a server only when it is created or rebuilt in +place; both procedures are in `../nixos/README.md`. ## Storage (S3-compatible) @@ -68,94 +76,27 @@ delete protection guard against it. ## Setup -### 1. Initialize ```bash -terraform init +cp terraform.tfvars.example terraform.tfvars # token and Object Storage keys +export AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... # state bucket +tofu init +tofu plan +tofu apply ``` -### 2. Configure secrets -Edit `terraform.tfvars`: -```hcl -hcloud_token = "your-token" -s3_access_key = "your-key" -s3_secret_key = "your-secret" -s3_endpoint_hel1 = "hel1.your-objectstorage.com" -s3_endpoint_fsn1 = "fsn1.your-objectstorage.com" -``` +In a new project the state bucket does not exist yet: comment out the +`backend "s3"` block in `providers.tf` for the first apply, restore it, +then `tofu init -migrate-state`. -### 3. Deploy -```bash -terraform plan -terraform apply -``` - -### 4. Enable S3 backend (optional) -After buckets are created: - -```bash -# Set credentials -export AWS_ACCESS_KEY_ID="your-key" -export AWS_SECRET_ACCESS_KEY="your-secret" - -# Or use ~/.aws/credentials file -mkdir -p ~/.aws -cat > ~/.aws/credentials < +# +# Log: /var/log/nixos-infect.log (after the reboot under /old-root). + +hostname: ${hostname} +fqdn: ${hostname}.${domain} +manage_etc_hosts: true +ssh_deletekeys: false + +write_files: + # Corrections to what nixos-infect generates, for this bootstrap + # generation only: the takeover of the old root (NIXOS_LUSTRATE) exists + # only in the scripted initrd; without an interface the IPv4 default + # route is never added (the gateway is not on the /32's link); and the + # private network gets an address but no route. + - path: /etc/nixos/bootstrap.nix + content: | + { lib, ... }: { + boot.initrd.systemd.enable = false; + networking.defaultGateway = lib.mkForce { + address = "172.31.1.1"; + interface = "eth0"; + }; + networking.interfaces.enp7s0.ipv4.routes = [ + { address = "${private_gateway}"; prefixLength = 32; } + { address = "${private_net}"; prefixLength = ${private_prefix}; via = "${private_gateway}"; } + ]; + } + +runcmd: + # Debian keeps /tmp in RAM; nixos-infect puts its swap file there + - >- + umount -l /tmp; + curl -fsSL -o /root/nixos-infect + https://raw.githubusercontent.com/elitak/nixos-infect/${infect_rev}/nixos-infect + && echo "${infect_sha256} /root/nixos-infect" | sha256sum -c + && PROVIDER=hetznercloud NIX_CHANNEL=${nix_channel} NIXOS_IMPORT=./bootstrap.nix + bash -x /root/nixos-infect > /var/log/nixos-infect.log 2>&1 diff --git a/terraform/cloud-init/ops.yaml b/terraform/cloud-init/ops.yaml deleted file mode 100644 index ddffdee..0000000 --- a/terraform/cloud-init/ops.yaml +++ /dev/null @@ -1,136 +0,0 @@ -#cloud-config -# Cloud-init configuration for asxpio-ops server -# Debian 13 (trixie) - Ops Server - -hostname: asxpio-ops -fqdn: asxpio-ops.asxp.io -manage_etc_hosts: true - -# Package management -package_update: true -package_upgrade: true - -packages: - - fail2ban - - curl - - gpg - - htop - - ncdu - - tree - - apt-transport-https - - ca-certificates - - gnupg - - lsb-release - -# Create users (docker group will be added later in runcmd) -users: - - name: asxpi - groups: sudo - shell: /bin/bash - sudo: ['ALL=(ALL) NOPASSWD:ALL'] - lock_passwd: true - ssh_authorized_keys: - - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMZ+/5F7SxdTVW47iiStLpGK77oWfR5NgaK4tTSR/aVB me@asxp.io - - - name: zerrtika - groups: sudo - shell: /bin/bash - sudo: ['ALL=(ALL) NOPASSWD:ALL'] - lock_passwd: true - ssh_authorized_keys: - - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIELE7hTD4sC5raqjSxy2fXyM+q1CwwVuy9KLFgDR6SFl zerrtika@zerrtika-mac - - - name: deploy - groups: sudo - shell: /bin/bash - sudo: ['ALL=(ALL) NOPASSWD:ALL'] - lock_passwd: true - ssh_authorized_keys: - - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGTDPg3mV55lO8uBnvpcGRxJ2vMRP0qB3Pxhg+C8rwj9 asxpio-deploy - -# SSH hardening -ssh_pwauth: false -disable_root: false -ssh_deletekeys: false - -# Write files -write_files: - # Docker daemon configuration - - path: /etc/docker/daemon.json - content: | - { - "live-restore": true, - "storage-driver": "overlay2", - "log-opts": { - "max-size": "20m" - } - } - owner: root:root - permissions: '0644' - - # Custom bash prompt for asxpi user - - path: /home/asxpi/.bashrc_custom - content: | - # Custom bash prompt styling for asxpio servers - export PS1="\[$(tput bold)\]\[\033[38;5;4m\][\[$(tput sgr0)\]\t\[$(tput sgr0)\]\[$(tput bold)\]\[\033[38;5;4m\]]\[$(tput sgr0)\] \[$(tput sgr0)\]\[$(tput bold)\]\[\033[38;5;4m\][\[$(tput sgr0)\]\u@\h \[$(tput sgr0)\]\[$(tput bold)\]\[\033[38;5;4m\]\w]\[$(tput sgr0)\] \[$(tput sgr0)\]\[$(tput bold)\]\[\033[38;5;4m\]\\$\[$(tput sgr0)\] \[$(tput sgr0)\]" - owner: root:root - permissions: '0644' - - # SSH hardening config - - path: /etc/ssh/sshd_config.d/99-hardening.conf - content: | - PasswordAuthentication no - PermitRootLogin prohibit-password - PubkeyAuthentication yes - owner: root:root - permissions: '0644' - -runcmd: - # Install Docker - - curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg - - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null - - apt-get update - - apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin - - # Enable and start Docker - - systemctl enable docker - - systemctl start docker - - # Add users to docker group (after docker is installed) - - usermod -aG docker asxpi - - usermod -aG docker zerrtika - - usermod -aG docker deploy - - # Enable and start fail2ban - - systemctl enable fail2ban - - systemctl start fail2ban - - # Fix home directory ownership and setup bashrc for asxpi - - chown asxpi:asxpi /home/asxpi - - chown asxpi:asxpi /home/asxpi/.bashrc_custom - - cp /etc/skel/.bashrc /home/asxpi/.bashrc - - cp /etc/skel/.profile /home/asxpi/.profile - - chown asxpi:asxpi /home/asxpi/.bashrc /home/asxpi/.profile - - echo '[ -f ~/.bashrc_custom ] && source ~/.bashrc_custom' >> /home/asxpi/.bashrc - - # Fix home directory ownership for deploy user - - chown deploy:deploy /home/deploy - - # Set up weekly Docker image pruning - - echo '0 3 * * 1 docker image prune -af > /var/log/docker-prune.log 2>&1' | crontab - - - # Restart SSH to apply hardening - - systemctl restart sshd - -final_message: | - ========================================== - asxpio-ops server is ready! - ========================================== - Hostname: asxpio-ops - OS: Debian 13 (trixie) - User: asxpi (sudo + docker access) - SSH: Key-only authentication enabled - Docker: Installed with compose plugin - - You can now SSH: ssh asxpi@$(hostname -I | awk '{print $1}') - ========================================== diff --git a/terraform/cloud-init/services.yaml b/terraform/cloud-init/services.yaml deleted file mode 100644 index 2880e0b..0000000 --- a/terraform/cloud-init/services.yaml +++ /dev/null @@ -1,134 +0,0 @@ -#cloud-config -# Cloud-init configuration for asxpio-services server -# Debian 13 (trixie) - Services Server - -hostname: asxpio-services -fqdn: asxpio-services.asxp.io -manage_etc_hosts: true - -# Package management -package_update: true -package_upgrade: true - -packages: - - fail2ban - - curl - - gpg - - htop - - ncdu - - tree - - apt-transport-https - - ca-certificates - - gnupg - - lsb-release - -# Create users (docker group will be added later in runcmd) -users: - - name: asxpi - groups: sudo - shell: /bin/bash - sudo: ['ALL=(ALL) NOPASSWD:ALL'] - lock_passwd: true - ssh_authorized_keys: - - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMZ+/5F7SxdTVW47iiStLpGK77oWfR5NgaK4tTSR/aVB me@asxp.io - - name: zerrtika - groups: sudo - shell: /bin/bash - sudo: ['ALL=(ALL) NOPASSWD:ALL'] - lock_passwd: true - ssh_authorized_keys: - - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIELE7hTD4sC5raqjSxy2fXyM+q1CwwVuy9KLFgDR6SFl zerrtika@zerrtika-mac - - name: deploy - groups: sudo - shell: /bin/bash - sudo: ['ALL=(ALL) NOPASSWD:ALL'] - lock_passwd: true - ssh_authorized_keys: - - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGTDPg3mV55lO8uBnvpcGRxJ2vMRP0qB3Pxhg+C8rwj9 asxpio-deploy - -# SSH hardening -ssh_pwauth: false -disable_root: false -ssh_deletekeys: false - -# Write files -write_files: - # Docker daemon configuration - - path: /etc/docker/daemon.json - content: | - { - "live-restore": true, - "storage-driver": "overlay2", - "log-opts": { - "max-size": "20m" - } - } - owner: root:root - permissions: '0644' - - # Custom bash prompt for asxpi user - - path: /home/asxpi/.bashrc_custom - content: | - # Custom bash prompt styling for asxpio servers - export PS1="\[$(tput bold)\]\[\033[38;5;4m\][\[$(tput sgr0)\]\t\[$(tput sgr0)\]\[$(tput bold)\]\[\033[38;5;4m\]]\[$(tput sgr0)\] \[$(tput sgr0)\]\[$(tput bold)\]\[\033[38;5;4m\][\[$(tput sgr0)\]\u@\h \[$(tput sgr0)\]\[$(tput bold)\]\[\033[38;5;4m\]\w]\[$(tput sgr0)\] \[$(tput sgr0)\]\[$(tput bold)\]\[\033[38;5;4m\]\\$\[$(tput sgr0)\] \[$(tput sgr0)\]" - owner: root:root - permissions: '0644' - - # SSH hardening config - - path: /etc/ssh/sshd_config.d/99-hardening.conf - content: | - PasswordAuthentication no - PermitRootLogin prohibit-password - PubkeyAuthentication yes - owner: root:root - permissions: '0644' - -runcmd: - # Install Docker - - curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg - - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null - - apt-get update - - apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin - - # Enable and start Docker - - systemctl enable docker - - systemctl start docker - - # Add users to docker group (after docker is installed) - - usermod -aG docker asxpi - - usermod -aG docker zerrtika - - usermod -aG docker deploy - - # Enable and start fail2ban - - systemctl enable fail2ban - - systemctl start fail2ban - - # Fix home directory ownership and setup bashrc for asxpi - - chown asxpi:asxpi /home/asxpi - - chown asxpi:asxpi /home/asxpi/.bashrc_custom - - cp /etc/skel/.bashrc /home/asxpi/.bashrc - - cp /etc/skel/.profile /home/asxpi/.profile - - chown asxpi:asxpi /home/asxpi/.bashrc /home/asxpi/.profile - - echo '[ -f ~/.bashrc_custom ] && source ~/.bashrc_custom' >> /home/asxpi/.bashrc - - # Fix home directory ownership for deploy user - - chown deploy:deploy /home/deploy - - # Set up weekly Docker image pruning - - echo '0 3 * * 1 docker image prune -af > /var/log/docker-prune.log 2>&1' | crontab - - - # Restart SSH to apply hardening - - systemctl restart sshd - -final_message: | - ========================================== - asxpio-services server is ready! - ========================================== - Hostname: asxpio-services - OS: Debian 13 (trixie) - User: asxpi (sudo + docker access) - SSH: Key-only authentication enabled - Docker: Installed with compose plugin - - You can now SSH: ssh asxpi@$(hostname -I | awk '{print $1}') - ========================================== diff --git a/terraform/outputs.tf b/terraform/outputs.tf index 5224cb9..87b04fd 100644 --- a/terraform/outputs.tf +++ b/terraform/outputs.tf @@ -27,3 +27,11 @@ output "vpc_network" { } description = "VPC network info" } + +# For a rebuild in place: +# tofu output -json user_data | jq -r '."asxpio-ops"' | +# hcloud server rebuild --image debian-13 --user-data-from-file - asxpio-ops +output "user_data" { + value = local.user_data + description = "cloud-init per server, as a new or rebuilt server gets it" +} diff --git a/terraform/providers.tf b/terraform/providers.tf index 5d1bbae..7c61e65 100644 --- a/terraform/providers.tf +++ b/terraform/providers.tf @@ -1,5 +1,6 @@ +# Run with OpenTofu (`tofu`, in the dev shell of ../nixos). terraform { - required_version = ">= 1.0.0" + required_version = ">= 1.8.0" # S3 backend - comment this section if bucket not yet created backend "s3" { @@ -11,7 +12,7 @@ terraform { skip_metadata_api_check = true skip_region_validation = true skip_requesting_account_id = true - force_path_style = true + use_path_style = true } required_providers { diff --git a/terraform/servers.tf b/terraform/servers.tf index f908ac7..c0a5087 100644 --- a/terraform/servers.tf +++ b/terraform/servers.tf @@ -1,3 +1,24 @@ +# Debian on first boot installs NixOS over itself (cloud-init runs +# nixos-infect); the system itself is described in ../nixos. +locals { + user_data = { + for host in ["asxpio-ops", "asxpio-services"] : host => templatefile( + "${path.module}/cloud-init/nixos.yaml.tftpl", { + hostname = host + domain = "asxp.io" + # Pinned: this script replaces the operating system + infect_rev = "40f62a680bb0e8f2f607d79abfaaecd99d59401c" + infect_sha256 = "4354bd68773b41da65c0e815202c43c8549713b3ed3ff6381c71fbc0b0a840ab" + nix_channel = "nixos-26.05" + + private_net = split("/", hcloud_network.main.ip_range)[0] + private_prefix = split("/", hcloud_network.main.ip_range)[1] + private_gateway = cidrhost(hcloud_network.main.ip_range, 1) + } + ) + } +} + # Ops Server (2 vCPU, 4GB RAM) resource "hcloud_server" "ops" { name = "asxpio-ops" @@ -29,17 +50,17 @@ resource "hcloud_server" "ops" { firewall_ids = [hcloud_firewall.ops_fw.id] labels = { - role = "ops" - env = "production" - managed_by = "terraform" - project = "asxpio" + role = "ops" + env = "production" + managed_by = "terraform" + project = "asxpio" } - # Cloud-init for automated server setup - user_data = file("${path.module}/cloud-init/ops.yaml") - # cloud-init only runs at first boot, and hcloud replaces the server - # when user_data, image or ssh_keys change. Never let an edit to those - # destroy a running machine: changes there apply to a rebuild only. + # First boot converts the Debian image to NixOS (see local.user_data). + # hcloud replaces the server when user_data, image or ssh_keys change. + # Never let an edit to those destroy a running machine: they apply to + # a new server or to a rebuild in place (../nixos/README.md) only. + user_data = local.user_data["asxpio-ops"] lifecycle { ignore_changes = [user_data, image, ssh_keys] prevent_destroy = true @@ -77,17 +98,17 @@ resource "hcloud_server" "services" { firewall_ids = [hcloud_firewall.services_fw.id] labels = { - role = "services" - env = "production" - managed_by = "terraform" - project = "asxpio" + role = "services" + env = "production" + managed_by = "terraform" + project = "asxpio" } - # Cloud-init for automated server setup - user_data = file("${path.module}/cloud-init/services.yaml") - # cloud-init only runs at first boot, and hcloud replaces the server - # when user_data, image or ssh_keys change. Never let an edit to those - # destroy a running machine: changes there apply to a rebuild only. + # First boot converts the Debian image to NixOS (see local.user_data). + # hcloud replaces the server when user_data, image or ssh_keys change. + # Never let an edit to those destroy a running machine: they apply to + # a new server or to a rebuild in place (../nixos/README.md) only. + user_data = local.user_data["asxpio-services"] lifecycle { ignore_changes = [user_data, image, ssh_keys] prevent_destroy = true