Skip to content

Buchtl/grafana

Repository files navigation

Usage

Basic usage on local dev (using localhost and local ip)

  1. generate certs for testing: ./certs_generate_local.sh
  2. deploy and start the stack: swarm_start.sh
  3. when done stop and delete the stack: swarm_delete.sh

Postgres

Dump

#pg_dump -U app -d appdb -F c -f /tmp/appdb.dump

Fix backup made with pgadmin4

sed -i '/transaction_timeout/d' ./data/postgres/appdb.sql

Grafana

Provisioning

Expected wrapper of the exported JSON

{
  "apiVersion": 1,
  "providers": [
    {
      "name": "Provisioned Dashboards",
      "type": "file",
      "disableDeletion": false,
      "editable": true,
      "options": {
        "path": "/etc/grafana/provisioning/dashboards"
      }
    }
  ]
}

Export Dashboard

curl -H "Authorization: Bearer <API_KEY>" \
  http://<grafana-host>:<PORT>/api/dashboards/uid/<DASHBOARD_UID> \
  | jq '.'

Add another aggregated column to the same query:

SELECT
  $__timeGroupAlias(creation_date, '1d'),
  sum(size)   AS total_size,
  count(*)    AS entry_count          -- or count(size) if you only want non‑NULL sizes
FROM grafana_file
WHERE $__timeFilter(creation_date)
GROUP BY 1
ORDER BY 1;

Grafana will return two series per day: total_size and entry_count. If you also want the average size per entry:

SELECT
  $__timeGroupAlias(creation_date, '1d'),
  sum(size)                AS total_size,
  count(*)                 AS entry_count,
  sum(size)::double precision / NULLIF(count(*), 0) AS avg_size
FROM grafana_file
WHERE $__timeFilter(creation_date)
GROUP BY 1
ORDER BY 1;

Make sure the panel is Format: Time series (or Panel type: Time series).

About

Dev Setup Grafana

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages