Prometheus: Difference between revisions

Axka (talk | contribs)
Linked to Grafana
m Fixed link to loki
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
[https://prometheus.io/ Prometheus] is a free software application used for event monitoring and alerting. It records metrics in a time series database built using an HTTP pull model, with flexible queries and real-time alerting.
'''[https://prometheus.io/ Prometheus]''' is an open-source event monitoring and alerting application. It records metrics in a time series database built by pulling (also known as ''scraping'') metrics from different services, with flexible queries and real-time alerting.


See [[Grafana]] for the dashboarding tool that is often used with Prometheus.
{{infobox application
  |name=Prometheus
  |image=Prometheus software logo.svg
  |type=Metrics aggregation system
  |status=Active
  |license=Apache License 2.0
  |programmingLanguage=Go
  |github=prometheus/prometheus
  |documentation=https://prometheus.io/docs/introduction/overview/
}}


== Client/Agent: Prometheus exporter ==
== Prometheus exporters ==
It is documented in the [https://nixos.org/manual/nixos/stable/#module-services-prometheus-exporters NixOS manual].


== Client example ==
Prometheus works by scraping from HTTP endpoints, which are often provided by '''Prometheus exporters'''.
Example of [https://prometheus.io/docs/guides/node-exporter/ prometheus node_exporter] with additional collectors enabled:<syntaxhighlight lang="nix">
 
=== <code>node_exporter</code> ===
Below is an example of [https://prometheus.io/docs/guides/node-exporter/ prometheus node_exporter] with additional collectors enabled. [https://nixos.org/manual/nixos/stable/#module-services-prometheus-exporters <code>node_exporter</code> is documented in the NixOS manual].
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{ config, pkgs, ... }:
{ config, pkgs, ... }:
{
{
Line 20: Line 32:
   };
   };
}
}
</syntaxhighlight>
</nowiki>}}
== Server ==
 
The Prometheus service daemon can be enabled and configured by further options.<syntaxhighlight lang="nix">
== Usage ==
services.prometheus.enable = true;
 
</syntaxhighlight>Another example:<syntaxhighlight lang="nix">
The Prometheus service daemon can be enabled and configured by further options.
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
  services.prometheus.enable = true;
}
</nowiki>}}
 
Another example:
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{ config, pkgs, ... }:
{ config, pkgs, ... }:
{
{
Line 34: Line 55:
     globalConfig.scrape_interval = "10s"; # "1m"
     globalConfig.scrape_interval = "10s"; # "1m"
     scrapeConfigs = [
     scrapeConfigs = [
    {
      {
      job_name = "node";
        job_name = "node";
      static_configs = [{
        static_configs = [{
        targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ];
          targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ];
      }];
        }];
    }
      }
     ];
     ];
   };
   };
}
}
</syntaxhighlight>
</nowiki>}}
 
== See also ==


* [[Grafana]], the dashboarding tool often used with Prometheus.
* [[Grafana Loki|Loki]], the equivalent of Prometheus for logs.


[[Category:Server]]
[[Category:Server]]
[[Category:NixOS Manual]]
[[Category:NixOS Manual]]