Live status from Grafana
Health, recent logs and traces on your diagrams, from your own Grafana.
Create a read-only token
In Grafana, open Administration › Service accounts, add one named FlowShape with the role Viewer, then Add service account token and copy it.
Start the agent with it
Put the token in an environment variable, so it stays out of your shell history:
FLOWSHAPE_GRAFANA_TOKEN=<token> node flowshape-agent.mjs --key <key> --grafana https://grafana.example.comOr keep it in a file: --grafana-token-file <path>.
Turn on Live status
Open a diagram in FlowShape and press Live status.
The token stays on this machine. FlowShape gets only the answers, and Grafana's address without any user name or password in it.
How items are matched
An item on a diagram is matched by name to the series whose service label has that name. Use
--grafana-label <label> for another label.
Your own queries
The defaults read up (or service_up), http_requests_total and
http_request_duration_seconds_bucket. Replace any of them with
--grafana-queries <file.json>: a JSON object with any of these keys. $label, $names and
$name are filled in.
{
"status": "max by ($label) (up{$label=~\"$names\"})",
"errors": "sum by ($label) (rate(http_requests_total{$label=~\"$names\",status=~\"5..\"}[5m])) / sum by ($label) (rate(http_requests_total{$label=~\"$names\"}[5m]))",
"latency": "histogram_quantile(0.95, sum by ($label, le) (rate(http_request_duration_seconds_bucket{$label=~\"$names\"}[5m])))",
"rate": "sum by ($label) (rate(http_requests_total{$label=~\"$names\"}[5m])) * 60",
"logs": "{$label=\"$name\"}",
"traceTag": "service.name"
}