Grafana: Difference between revisions

imported>Nadrog
m Updated based on instructions at https://grafana.com/tutorials/run-grafana-behind-a-proxy/
Add section on how to configure Grafana using `nix`
Line 38: Line 38:
</syntaxhighlight>
</syntaxhighlight>


== Usage ==
== Configuration ==


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:
Everything else (data sources, users, dashboards, ...) can be configured either in the Web UI, or as code.
 
=== Via Web UI ===
 
Log into the Grafana web application (using default user: admin, password: admin). Refer to the official documentation on how to do it:


* [https://grafana.com/docs/grafana/latest/datasources/add-a-data-source/ Add a data source]
* [https://grafana.com/docs/grafana/latest/datasources/add-a-data-source/ Add a data source]
* [https://grafana.com/docs/grafana/latest/administration/manage-users-and-permissions/manage-server-users/add-user/ Add a user]
* [https://grafana.com/docs/grafana/latest/administration/manage-users-and-permissions/manage-server-users/add-user/ Add a user]
* [https://grafana.com/docs/grafana/latest/dashboards/dashboard-create/ Create dashboard]
* [https://grafana.com/docs/grafana/latest/dashboards/dashboard-create/ Create dashboard]
=== Declarative configuration ===
<syntaxhighlight lang=nix>
services.grafana = {
  enable = true;
  declarativePlugins = with pkgs.grafanaPlugins; [ ... ];
  provision = {
    enable = true;
    dashboards.settings.providers = [{
      name = "my dashboards";
      options.path = "/etc/grafana-dashboards";
    }];
    datasources.settings.datasources = [
      # "Built-in" datasources can be provisioned https://grafana.com/docs/grafana/latest/administration/provisioning/#data-sources
      {
        name = "Prometheus";
        type = "prometheus";
        url = "${config.services.prometheus.listenAddress}:${toString config.services.prometheus.port}";
      }
      # Some plugins also can https://grafana.com/docs/plugins/yesoreyeram-infinity-datasource/latest/setup/provisioning/
      {
        name = "Infinity";
        type = "yesoreyeram-infinity-datasource";
      }
      # But not all, c.f. https://github.com/fr-ser/grafana-sqlite-datasource/issues/141
    ];
    # Note: removing attributes from the above `datasources.settings.datasources` is not enough for them to be deleted on `grafana`;
    # One needs to use the following option:
    # datasources.settings.deleteDatasources = [ { name = "foo"; orgId = 1; } { name = "bar"; orgId = 1; } ];
  };
};
environment.etc = [{
  source = ./. + "/grafana-dashboards/some-dashboard.json";
  group = "grafana";
  user = "grafana";
}];
</syntaxhighlight>


== External Links ==
== External Links ==