services-flake/doc/grafana.md
Shivaraj B H c0a1021f54
Development and contribution guidelines (#112)
---------

Co-authored-by: Sridhar Ratnakumar <srid@srid.ca>
Co-authored-by: Sridhar Ratnakumar <3998+srid@users.noreply.github.com>
2024-02-24 17:54:57 +05:30

1.3 KiB

Grafana

Grafana open source 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";
  };
}