MyNixOS website logo
option

services.grafana-agent.settings

Configuration for grafana-agent.

See https://grafana.com/docs/agent/latest/configuration/

Declarations
Type
YAML value
Default
{
  metrics = {
    wal_directory = "\${STATE_DIRECTORY}";
    global.scrape_interval = "5s";
  };
  integrations = {
    agent.enabled = true;
    agent.scrape_integration = true;
    node_exporter.enabled = true;
  };
}
Example
{
  logs = {
    configs = [
      {
        clients = [
          {
            basic_auth = {
              password_file = "\${CREDENTIALS_DIRECTORY}/logs_remote_write_password";
              username = "\${LOGS_REMOTE_WRITE_USERNAME}";
            };
            url = "\${LOGS_REMOTE_WRITE_URL}";
          }
        ];
        name = "default";
        positions = {
          filename = "\${STATE_DIRECTORY}/loki_positions.yaml";
        };
        scrape_configs = [
          {
            job_name = "journal";
            journal = {
              labels = {
                job = "systemd-journal";
              };
              max_age = "12h";
            };
            relabel_configs = [
              {
                source_labels = [
                  "__journal__systemd_unit"
                ];
                target_label = "systemd_unit";
              }
              {
                source_labels = [
                  "__journal__hostname"
                ];
                target_label = "nodename";
              }
              {
                source_labels = [
                  "__journal_syslog_identifier"
                ];
                target_label = "syslog_identifier";
              }
            ];
          }
        ];
      }
    ];
  };
  metrics = {
    global = {
      remote_write = [
        {
          basic_auth = {
            password_file = "\${CREDENTIALS_DIRECTORY}/metrics_remote_write_password";
            username = "\${METRICS_REMOTE_WRITE_USERNAME}";
          };
          url = "\${METRICS_REMOTE_WRITE_URL}";
        }
      ];
    };
  };
}