aboutsummaryrefslogblamecommitdiff
path: root/profiles/core-metrics.nix
blob: 3f817e558803a879e313c6c919ac1a4c7a976d40 (plain) (tree)





























































                                                             
{ hostName, ... }:
let
  relabel_configs = [
    {
      action = "replace";
      replacement = hostName;
      target_label = "instance";
    }
  ];
in
{
  services.prometheus.exporters = {
    node.enable = true;
    systemd.enable = true;
    process.enable = true;
  };
  services.vmagent = {
    enable = true;
    remoteWrite.url = "http://10.100.0.60:8428/api/v1/write";
    prometheusConfig = {
      global = {
        external_labels = {
          "host" = hostName;
        };
      };
      scrape_configs = [
        {
          job_name = "node";
          scrape_interval = "10s";
          static_configs = [
            { targets = [ "127.0.0.1:9100" ]; }
          ];
          inherit relabel_configs;
        }
        {
          job_name = "systemd";
          scrape_interval = "10s";
          static_configs = [
            { targets = [ "127.0.0.1:9558" ]; }
          ];
          inherit relabel_configs;
        }
        {
          job_name = "process";
          scrape_interval = "10s";
          static_configs = [
            { targets = [ "127.0.0.1:9256" ]; }
          ];
          inherit relabel_configs;
        }
        {
          job_name = "vmagent";
          scrape_interval = "10s";
          static_configs = [
            { targets = [ "127.0.0.1:8429" ]; }
          ];
          inherit relabel_configs;
        }
      ];
    };
  };
}