feat: implement website alerting plan with Blackbox Exporter and VictoriaMetrics integration
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
{ config, pkgs, ... }:
|
||||
{ config, lib, pkgs, ... }:
|
||||
with lib;
|
||||
let
|
||||
configure_prom = builtins.toFile "prometheus.yml" ''
|
||||
scrape_configs:
|
||||
@@ -28,29 +29,41 @@ let
|
||||
- source_labels: [name]
|
||||
regex: '(container@git|microvm@git-runner-|postfix|dovecot|openldap|wireguard-wg_cloonar).*\.service'
|
||||
action: keep
|
||||
|
||||
${concatStringsSep "\n " config.services.victoriametrics.extraScrapeConfigs}
|
||||
'';
|
||||
in {
|
||||
sops.secrets.victoria-agent-env = {
|
||||
sopsFile = ./secrets.yaml;
|
||||
options.services.victoriametrics = {
|
||||
extraScrapeConfigs = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = "Additional Prometheus scrape job YAML snippets for Blackbox Exporter probes";
|
||||
};
|
||||
};
|
||||
|
||||
# Node exporter for system metrics
|
||||
services.prometheus.exporters.node = {
|
||||
enable = true;
|
||||
enabledCollectors = [
|
||||
"systemd" # Enable systemd collector for service monitoring
|
||||
];
|
||||
};
|
||||
|
||||
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} -envflag.enable -remoteWrite.url=https://victoria-server.cloonar.com/api/v1/write";
|
||||
config = {
|
||||
sops.secrets.victoria-agent-env = {
|
||||
sopsFile = ./secrets.yaml;
|
||||
};
|
||||
|
||||
serviceConfig = {
|
||||
EnvironmentFile=config.sops.secrets.victoria-agent-env.path;
|
||||
# Node exporter for system metrics
|
||||
services.prometheus.exporters.node = {
|
||||
enable = true;
|
||||
enabledCollectors = [
|
||||
"systemd" # Enable systemd collector for service monitoring
|
||||
];
|
||||
};
|
||||
|
||||
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} -envflag.enable -remoteWrite.url=https://victoria-server.cloonar.com/api/v1/write";
|
||||
|
||||
serviceConfig = {
|
||||
EnvironmentFile=config.sops.secrets.victoria-agent-env.path;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user