mirror of
https://github.com/nmasur/dotfiles
synced 2025-01-31 12:12:03 +00:00
56 lines
1.3 KiB
Nix
56 lines
1.3 KiB
Nix
# VictoriaMetrics is a more efficient drop-in replacement for Prometheus and
|
|
# InfluxDB (timeseries databases built for monitoring system metrics).
|
|
|
|
{
|
|
config,
|
|
lib,
|
|
pkgs-stable,
|
|
...
|
|
}:
|
|
|
|
let
|
|
|
|
cfg = config.nmasur.presets.services.vm-agent;
|
|
|
|
username = "prometheus";
|
|
|
|
prometheusConfig = {
|
|
scrape_configs = [
|
|
{
|
|
job_name = config.networking.hostName;
|
|
stream_parse = true;
|
|
static_configs = [ { targets = config.prometheus.scrapeTargets; } ];
|
|
}
|
|
];
|
|
};
|
|
|
|
in
|
|
{
|
|
|
|
options.nmasur.presets.services.vm-agent.enable =
|
|
lib.mkEnableOption "vm-agent VictoriaMetrics collector";
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services.vmagent = {
|
|
enable = true;
|
|
package = pkgs-stable.vmagent;
|
|
prometheusConfig = prometheusConfig;
|
|
remoteWrite = {
|
|
url = "https://${config.hostnames.prometheus}/api/v1/write";
|
|
basicAuthUsername = username;
|
|
basicAuthPasswordFile = config.secrets.vmagent.dest;
|
|
};
|
|
};
|
|
|
|
secrets.vmagent = {
|
|
source = ../../../private/prometheus.age;
|
|
dest = "${config.secretsDirectory}/vmagent";
|
|
};
|
|
systemd.services.vmagent-secret = lib.mkIf config.services.vmagent.enable {
|
|
requiredBy = [ "vmagent.service" ];
|
|
before = [ "vmagent.service" ];
|
|
};
|
|
};
|
|
}
|