services-flake/doc/prometheus.md
Abhishek Singh bdd6dde41a
add prometheus service (#114)
* prometheus: init service

* prometheus: add doc

* prometheus: update doc
2024-02-28 11:00:52 +05:30

1.2 KiB

Prometheus

Prometheus is a systems and service monitoring system. It collects metrics from configured targets at given intervals, evaluates rule expressions, displays the results, and can trigger alerts when specified conditions are observed.

Getting Started

# In `perSystem.process-compose.<name>`
{
  services.prometheus."pro1".enable = true;
}

{#tips}

Tips & Tricks

{#scrape-configs}

Adding Scrape Configs

scrape_configs controls what resources Prometheus monitors.

Since Prometheus also exposes data about itself as an HTTP endpoint it can scrape and monitor its own health. In the default example configuration there is a single job, called prometheus. We can add it to scrape_configs using the following config:

{
  services.prometheus."pro1" = {
    enable = true;
    # scrape prometheus
    extraConfig = {
      scrape_configs = [{
        job_name = "prometheus";
        static_configs = [{
          targets = [ "localhost:9090" ];
        }];
      }];
    };
  };
}