Set labels for victoria* metrics

This commit is contained in:
SebastianStork 2025-09-20 23:37:30 +02:00
parent 387af935d1
commit 3294e96bf9
2 changed files with 11 additions and 5 deletions

View file

@ -64,8 +64,8 @@ in
} }
prometheus.scrape "node_exporter" { prometheus.scrape "node_exporter" {
targets = prometheus.exporter.unix.default.targets targets = prometheus.exporter.unix.default.targets
forward_to = [prometheus.remote_write.default.receiver] forward_to = [prometheus.remote_write.default.receiver]
scrape_interval = "15s" scrape_interval = "15s"
} }
''; '';
@ -76,8 +76,10 @@ in
prometheus.scrape "victorialogs" { prometheus.scrape "victorialogs" {
targets = [{ targets = [{
__address__ = "localhost:${builtins.toString config.custom.services.victorialogs.port}", __address__ = "localhost:${builtins.toString config.custom.services.victorialogs.port}",
job = "victorialogs",
instance = constants.hostname,
}] }]
forward_to = [prometheus.remote_write.default.receiver] forward_to = [prometheus.remote_write.default.receiver]
scrape_interval = "15s" scrape_interval = "15s"
} }
''; '';
@ -86,7 +88,7 @@ in
"alloy/sshd-logs.alloy" = lib.mkIf cfg.collect.sshdLogs { "alloy/sshd-logs.alloy" = lib.mkIf cfg.collect.sshdLogs {
text = '' text = ''
loki.source.journal "sshd" { loki.source.journal "sshd" {
matches = "_SYSTEMD_UNIT=sshd.service" matches = "_SYSTEMD_UNIT=sshd.service"
forward_to = [loki.write.default.receiver] forward_to = [loki.write.default.receiver]
} }
''; '';

View file

@ -50,7 +50,11 @@ in
} }
); );
listenAddress = "localhost:${builtins.toString cfg.port}"; listenAddress = "localhost:${builtins.toString cfg.port}";
extraOptions = [ "-selfScrapeInterval=15s" ]; extraOptions = [
"-selfScrapeInterval=15s"
"-selfScrapeJob=victoriametrics"
"-selfScrapeInstance=${config.networking.hostName}"
];
}; };
custom.persist.directories = [ "/var/lib/${config.services.victoriametrics.stateDir}" ]; custom.persist.directories = [ "/var/lib/${config.services.victoriametrics.stateDir}" ];