Grafana: Difference between revisions

From NixOS Wiki
imported>Iraizo
m missed opening bracket
imported>Schoettl
After upgrade to NixOS 23.11, Grafana didn't work for me anymore. I had an Moved Permanently redirect loop when trying to access myhost/grafana/. Removing the last slash solved it. Solution from here: https://community.grafana.com/t/redirect-loop-on-grafa
Line 30: Line 30:
   enableACME = true;
   enableACME = true;
   locations."/grafana/" = {
   locations."/grafana/" = {
       proxyPass = "http://${toString config.services.grafana.settings.server.http_addr}:${toString config.services.grafana.settings.server.http_port}/";
       proxyPass = "http://${toString config.services.grafana.settings.server.http_addr}:${toString config.services.grafana.settings.server.http_port}";
       proxyWebsockets = true;
       proxyWebsockets = true;
   };
   };

Revision as of 13:24, 18 December 2023

Grafana is an open-source, general purpose dashboarding tool, which runs as a web application. It can be used to create a variety of time-series graphs and also for displaying logs. It supports Prometheus, graphite, InfluxDB, opentsdb, Grafana Loki, PostgreSQL and many other data sources.

See Grafana options

Installation

Grafana is available as NixOS module, it can be enabled using the following config:

services.grafana = {
  enable = true;
  settings = {
    server = {
      # Listening Address
      http_addr = "127.0.0.1";
      # and Port
      http_port = 3000;
      # Grafana needs to know on which domain and URL it's running
      domain = "your.domain";
      root_url = "https://your.domain/grafana/"; # Not needed if it is `https://your.domain/`
    };
  };
};

This will make Grafana available only at localhost. On a server, it might be used through SSH tunnel or made publicly available using nginx with TLS. For example the follwing Nginx configuration can be used:

services.nginx.virtualHosts."your.domain" = {
  addSSL = true;
  enableACME = true;
  locations."/grafana/" = {
      proxyPass = "http://${toString config.services.grafana.settings.server.http_addr}:${toString config.services.grafana.settings.server.http_port}";
      proxyWebsockets = true;
  };
};

Usage

Log into the Grafana web application (using default user: admin, password: admin). Everything else (data sources, users, dashboards, ...) is configured in the Web UI. Refer to the official documentation on how to do it:

External Links