monitoring: initial config for victoriametrics

This commit is contained in:
Payas Relekar 2023-06-10 14:26:58 +05:30
parent 455259f5a2
commit 3b0174fb1a

View file

@ -1,4 +1,14 @@
{ config, ... }:
{ config, pkgs, ... }:
let
configure_prom = builtins.toFile "prometheus.yml" ''
scrape_configs:
- job_name: 'bebop'
stream_parse: true
static_configs:
- targets:
- 127.0.0.1:9100
'';
in
{
# Open grafana port, but only for local network
networking.firewall.extraCommands = ''
@ -10,10 +20,13 @@
'';
services = {
victoriametrics = {
enable = true;
};
# Collect data with conveniently declared 'scrapers'
prometheus = {
enable = true;
enable = false;
port = 9001;
# Enable prometheus to collect data from systemd
@ -99,12 +112,12 @@
};
influxdb = {
enable = true;
enable = false;
# dataDir = "~/.config/influxdb";
};
telegraf = {
enable = true;
enable = false;
extraConfig = {
inputs = {
# zfs = { poolMetrics = true; };
@ -174,4 +187,12 @@
};
};
};
systemd.services.export-to-prometheus = {
path = with pkgs; [ victoriametrics ];
enable = true;
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
script = "vmagent -promscrape.config=${configure_prom} -remoteWrite.url=http://127.0.0.1:8428/api/v1/write";
};
}