services-flake/doc/grafana.md

1.5 KiB

Grafana

Grafana open source1 is open source visualization and analytics software. It allows you to query, visualize, alert on, and explore your metrics, logs, and traces no matter where they are stored. It provides you with tools to turn your time-series database (TSDB) data into insightful graphs and visualizations.

Getting Started

# In `perSystem.process-compose.<name>`
{
  services.grafana."gf1".enable = true;
}

{#tips}

Tips & Tricks

{#change-database}

Changing Grafana database

By default, Grafana stores data in the sqlite3 database. It also supports mysql and postgres.

To change the database to postgres, we can use the following config:

{
  services.postgres.pg1 = {
    enable = true;
    listen_addresses = "127.0.0.1";
    initialScript.after = "CREATE USER root SUPERUSER;";
  };
  services.grafana.gf1 = {
    enable = true;
    extraConf.database = with config.services.postgres.pg1; {
      type = "postgres";
      host = "${listen_addresses}:${builtins.toString port}";
      name = "postgres"; # database name
    };
  };
  settings.processes."gf1".depends_on."pg1".condition = "process_healthy";
  };
}

  1. Grafana is broken on Darwin since 11.0.0 (https://github.com/NixOS/nixpkgs/pull/311701). Also see the issue to track the fix: https://github.com/NixOS/nixpkgs/issues/316954 ↩︎