Files

5.4 KiB

Dashboards and Queries

Grafana: https://dashboard.fetcherpay.com
Login: admin / admin_secure_2024


Dashboard inventory

Custom / session-built dashboards

Dashboard URL Purpose
FetcherPay / SquareMCP — Health Overview /d/fetcherpay-health-overview/fetcherpay-squaremcp-e28094-health-overview All websites, K8s pods, DB/cache, infra health in one place
Loki Operational /d/MQHVDmtWk/loki-operational Loki ingest/query performance
Tempo Operational /d/5BcHdkRgz/tempo-operational Tempo trace ingest/query performance

Imported dashboards (kube-prometheus-stack + grafana.com)

Dashboard Source Purpose
Blackbox Exporter grafana.com HTTPS endpoint probes
MySQL Overview grafana.com MySQL performance
Node Exporter Full grafana.com Linux node metrics
Kubernetes cluster kube-prometheus-stack K8s cluster overview
Kubernetes cluster monitoring kube-prometheus-stack K8s workload monitoring

How to create or edit a dashboard

Human workflow

  1. Log in to Grafana.
  2. Click + → Dashboard or open an existing dashboard and click the gear for Settings.
  3. Add a panel. Choose the datasource:
    • Prometheus (FetcherPay) for app/site/DB metrics
    • Prometheus (K8s Observability) for cluster/node metrics
    • Loki for logs
    • Tempo for traces
  4. Write the query (see reusable queries below).
  5. Save. Give it a clear title, tag it (health, squaremcp, fetcherpay), and pick a folder.

AI-agent workflow (API)

Use the Grafana API to import/export dashboards. See 03-api-reference.md for full examples.

Quick import from a dashboard JSON file:

curl -u admin:admin_secure_2024 \
  -X POST https://dashboard.fetcherpay.com/api/dashboards/db \
  -H 'Content-Type: application/json' \
  -d @dashboard.json

Reusable PromQL queries

Websites / external endpoints

# All sites up/down (1 = up)
probe_success{job="blackbox-http"}

# Percentage of healthy sites
avg(probe_success{job="blackbox-http"}) * 100

# Response time
probe_duration_seconds{job="blackbox-http"}

# SSL certificate days remaining
(probe_ssl_earliest_cert_expiry{job="blackbox-http"} - time()) / 86400

Infrastructure services

# Up/down for all infra exporters
up{job=~"mysql|redis|node-exporter|kube-state-metrics|prometheus|otel-collector"}

# Combined single table (infra + websites)
label_replace(
  up{job=~"mysql|redis|node-exporter|kube-state-metrics|prometheus|otel-collector"},
  "server", "$1", "instance", "(.+)"
)
or
label_replace(
  probe_success{job="blackbox-http"},
  "server", "$1", "instance", "(.+)"
)

Kubernetes

# Pod running ratio
sum(kube_pod_status_phase{phase="Running"}) / sum(kube_pod_status_phase)

# Pods by namespace and phase
sum by (namespace, phase) (kube_pod_status_phase)

# Top restarting containers
topk(10, kube_pod_container_status_restarts_total)

# Ingress controller restarts
kube_pod_container_status_restarts_total{namespace="ingress", pod=~".*nginx-ingress.*"}

# Node CPU %
100 - (avg by (instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)

# Node memory %
100 * (1 - ((node_memory_MemAvailable_bytes) / node_memory_MemTotal_bytes))

# Node disk usage %
100 - ((node_filesystem_avail_bytes{mountpoint="/"} * 100) / node_filesystem_size_bytes{mountpoint="/"})

Databases and caches

# MySQL up
up{job="mysql"}

# MySQL connections
mysql_global_status_threads_connected
mysql_global_status_threads_running

# MySQL slow queries/sec
irate(mysql_global_status_slow_queries[5m])

# Redis up
redis_up

# Redis memory
redis_memory_used_bytes

# Redis clients
redis_connected_clients

# Redis hit ratio
rate(redis_keyspace_hits_total[5m]) /
  clamp_min(rate(redis_keyspace_hits_total[5m]) + rate(redis_keyspace_misses_total[5m]), 1)

OpenTelemetry Collector

# Collector uptime
otelcol_process_uptime_total

# Metrics sent per second
rate(otelcol_exporter_sent_metric_points_total[5m])

# Exporter queue size
otelcol_exporter_queue_size

# Failed sends/sec
rate(otelcol_exporter_send_failed_metric_points_total[5m])

If you extend the health dashboard, consider adding:

  • SSL expiry alert panel — min of (probe_ssl_earliest_cert_expiry - time()) / 86400 with threshold 14 days.
  • Top memory-consuming pods — from K8s Prometheus: topk(10, container_memory_usage_bytes{container!=""}).
  • Error log rate — from Loki: {job="hermes-mcp"} |= "error" or {namespace="fetcherpay"} |= "ERROR".
  • Trace error rate — from Tempo: search for spans with status:error.

How to add a new website to monitor

  1. Edit monitoring/prometheus-config.yaml.
  2. Add the URL under static_configs.targets in the blackbox-http job.
  3. Apply: microk8s kubectl apply -f monitoring/prometheus-config.yaml.
  4. Restart Prometheus to reload: microk8s kubectl rollout restart deployment/prometheus -n fetcherpay.
  5. Verify: curl -u admin:admin_secure_2024 'https://dashboard.fetcherpay.com/api/datasources/proxy/uid/ffpaxh13af2f4e/api/v1/query?query=probe_success{instance="https://new-site.com"}'.

How to add a new exporter

  1. Create or reuse a Deployment + Service manifest in monitoring/.
  2. Add a scrape job to monitoring/prometheus-config.yaml.
  3. Apply both.
  4. Restart Prometheus.
  5. Add a panel to the health dashboard.