{"id":33321461,"url":"https://github.com/toot-community/mastodon-observability","last_synced_at":"2025-11-23T05:01:53.261Z","repository":{"id":325065711,"uuid":"1098018922","full_name":"toot-community/mastodon-observability","owner":"toot-community","description":"Jsonnet/Grafonnet package that powers observability for the toot.community Mastodon instance.","archived":false,"fork":false,"pushed_at":"2025-11-19T10:22:04.000Z","size":3692,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-19T12:14:33.510Z","etag":null,"topics":["alertmanager","grafana","jsonnet","kubernetes","mastodon","observability","promql","victorialogs","victoriametrics"],"latest_commit_sha":null,"homepage":"https://toot.community","language":"Jsonnet","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/toot-community.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-17T06:36:29.000Z","updated_at":"2025-11-19T11:59:48.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/toot-community/mastodon-observability","commit_stats":null,"previous_names":["toot-community/mastodon-observability"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/toot-community/mastodon-observability","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toot-community%2Fmastodon-observability","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toot-community%2Fmastodon-observability/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toot-community%2Fmastodon-observability/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toot-community%2Fmastodon-observability/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toot-community","download_url":"https://codeload.github.com/toot-community/mastodon-observability/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toot-community%2Fmastodon-observability/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285731803,"owners_count":27222214,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-22T02:00:05.934Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alertmanager","grafana","jsonnet","kubernetes","mastodon","observability","promql","victorialogs","victoriametrics"],"created_at":"2025-11-20T02:00:33.907Z","updated_at":"2025-11-22T04:00:58.530Z","avatar_url":"https://github.com/toot-community.png","language":"Jsonnet","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mastodon Observability (toot.community)\n\nThis repository contains the Jsonnet/Grafonnet code that powers observability for the toot.community Mastodon instance. It is published as a reference for how we run monitoring in production.\n\n- Instance: https://toot.community\n- Questions: [@jorijn](https://toot.community/@jorijn) or [@support](https://toot.community/@support)\n\n## What's inside\n- **Jsonnet libraries** for recording/alerting rules and Grafana dashboards under `lib/mastodon/`.\n- **Dashboards** for web, sidekiq, streaming, edge/ingress, and an overview (`lib/mastodon/dashboards/*.libsonnet`).\n- **Recording rules \u0026 alerts** (`lib/mastodon/records.libsonnet`, `lib/mastodon/alerts.libsonnet`) keyed by `namespace` so a single set covers both toot.community and microblog.network (our testing instance).\n- **Config** in `lib/mastodon/config.libsonnet` (SLO targets, ingress APDEX thresholds, Sidekiq queues/latency windows, request classification).\n- **Runbooks** in `docs/runbooks/` linked directly from alert annotations.\n- Inspiration: Google SRE handbook/playbook patterns (multi-window burn rates, symptom-based alerts).\n\n## Stack requirements\n- VictoriaMetrics (Prometheus-compatible) for metrics.\n- Grafana with provisioning of dashboards via ConfigMaps (see `deploy/kustomization.yaml`).\n- PrometheusRule-compatible operator (vmalert/VM operator in our case).\n- Tooling to render: `jsonnet`, `jsonnetfmt`, `jsonnet-lint`, `promtool`, `kustomize`, `kubectl`.\n\n### Mastodon deployment assumptions\n\n- **Ingress**: We front Mastodon with ingress-nginx (standard controller). Edge metrics/APDEX rely on nginx-ingress histogram buckets.\n- **Prometheus exporter settings**: (see [Mastodon docs](https://docs.joinmastodon.org/admin/config/#prometheus))\n  - Generic env (web/sidekiq/streaming):\n    - `MASTODON_PROMETHEUS_EXPORTER_ENABLED=\"true\"`\n    - `MASTODON_PROMETHEUS_EXPORTER_WEB_DETAILED_METRICS=\"true\"`\n    - `MASTODON_PROMETHEUS_EXPORTER_SIDEKIQ_DETAILED_METRICS=\"true\"`\n    - `PROMETHEUS_EXPORTER_HOST=\"127.0.0.1\"`\n    - `PROMETHEUS_EXPORTER_PORT=\"9394\"`\n  - Sidekiq env overrides (runs exporter inside the worker Pod):\n    - `MASTODON_PROMETHEUS_EXPORTER_ENABLED=\"true\"`\n    - `MASTODON_PROMETHEUS_EXPORTER_LOCAL=\"true\"`\n    - `MASTODON_PROMETHEUS_EXPORTER_HOST=\"0.0.0.0\"`\n    - `MASTODON_PROMETHEUS_EXPORTER_PORT=\"9394\"`\n- **Web exporter sidecar**: Mastodon web Pods run a sidecar container using the same Mastodon image executing `./bin/prometheus_exporter` (our Helm chart handles this; see [toot-community/platform](https://github.com/toot-community/platform/tree/main/charts/mastodon)).\n- **Logging**: Vector ships Pod logs to VictoriaLogs; dashboards assume fields like `_msg`, `kubernetes.pod_namespace`, and `kubernetes.pod_name`.\n- **Scraping**: VictoriaMetrics scrapes the exporters on all Mastodon Pods, as well as ingress-nginx metrics.\n\nIf you deploy Mastodon differently (other ingress, disabled exporters, etc.) you'll need equivalent metrics/logs to drive these dashboards.\n\n## Generate / lint / apply\n```sh\nmake generate          # render to generated/\nmake lint              # format + jsonnet-lint + promtool check rules\nmake apply             # kustomize build deploy | kubectl apply -f - (namespaced to mastodon-observability)\n```\n\n## Data sources \u0026 SLOs (high level)\n- **Web**: `ruby_http_requests_total` + duration summaries for diagnostics; availability/SLI excludes federation controllers; edge-based APDEX from ingress histograms (100/500ms, 5xx frustrated).\n- **Sidekiq**: queue latency, processed/failed rates, dead/retry growth, DB pool utilization.\n- **Streaming**: connected clients, Redis/PG pools, eventloop lag, messages in/out.\n- **Edge/Ingress**: nginx-ingress RPS/errors/latency, estimated cache hit ratio (no alerts).\n\n### SLOs we hold ourselves to\n- **Web availability**: We aim for 99.5% success on user-facing requests, with alerts that escalate when the error budget is burning fast or steadily.\n- **Web latency / APDEX**: We expect most requests to feel fast (target APDEX around 0.90+ using 100/500ms thresholds); if p99 latency climbs above 1s during real traffic, we treat it as critical.\n- **Sidekiq**: Background queues should stay responsive; if queue latency rises or the dead queue grows unusually versus processed jobs, we investigate.\n- **Streaming**: Connected clients and delivered messages should stay near recent norms; large drops trigger alerts, as does sustained event loop lag.\n\n## Usage and support\nThis code is tailored for toot.community and published as a reference. You're welcome to borrow ideas and adapt it; use `lib/mastodon/config.libsonnet` to tune namespaces, SLOs, and thresholds for your environment. Feel free to say hi ([@jorijn](https://toot.community/@jorijn) or [@support](https://toot.community/@support)), but we don't promise support beyond sharing how we run it.\n\n## Screenshots\n![Overview dashboard showing availability, APDEX, burn rates, and traffic mix](./screenshots/overview.png)\n![Web dashboard highlighting latency percentiles, APDEX over time, and 5xx rates](./screenshots/web.png)\n![Sidekiq dashboard with queue latency and dead/retry growth panels](./screenshots/sidekiq.png)\n![Streaming dashboard showing client baselines, drop ratios, and message flow](./screenshots/streaming.png)\n![Edge/ingress dashboard with RPS, errors, latency, and cache hit ratio](./screenshots/edge.png)\n\n## License\nMIT License — see `LICENSE`. Use at your own risk; attribution appreciated.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoot-community%2Fmastodon-observability","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoot-community%2Fmastodon-observability","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoot-community%2Fmastodon-observability/lists"}