flake/systems/etna/metrics.nix

71 lines
1.5 KiB
Nix
Raw Normal View History

2024-07-30 12:07:43 +02:00
{
config,
mystia,
_utils,
...
}: let
vmcfg = config.services.victoriametrics;
2024-07-30 12:07:43 +02:00
secrets = _utils.setupSharedSecrets config {secrets = ["vmAuthToken"];};
in {
2024-07-30 12:07:43 +02:00
imports = [
mystia.nixosModules.vmauth
secrets.generate
];
cfTunnels = {
"grafana.uku3lig.net" = "http://localhost:2432";
"metrics.uku3lig.net" = {
service = "http://localhost:9089";
path = "/api/.*/write";
};
};
2024-07-20 14:28:40 +02:00
services.grafana = {
enable = true;
settings = {
server = {
http_port = 2432;
root_url = "https://grafana.uku3lig.net";
};
};
};
services.victoriametrics = {
2024-07-20 14:28:40 +02:00
enable = true;
listenAddress = "127.0.0.1:9090";
retentionPeriod = 5 * 12; # 5 years !!!!
};
2024-07-20 14:28:40 +02:00
services.vmagent = {
enable = true;
prometheusConfig = {
global.scrape_interval = "15s";
2024-07-20 14:28:40 +02:00
2024-07-30 12:07:43 +02:00
# node scraping is sent to vm directly via vmauth
scrape_configs = [
{
job_name = "victoriametrics";
static_configs = [{targets = ["${builtins.toString vmcfg.listenAddress}"];}];
}
2024-07-20 14:28:40 +02:00
{
job_name = "api-rs";
static_configs = [{targets = ["localhost:5001"];}];
}
];
};
2024-07-20 14:28:40 +02:00
};
2024-07-30 12:07:43 +02:00
services.vmauth = {
enable = true;
listenAddress = "127.0.0.1:9089";
environmentFile = secrets.get "vmAuthToken";
authConfig.users = [
{
bearer_token = "%{VM_AUTH_TOKEN}";
url_prefix = "http://${vmcfg.listenAddress}";
}
];
};
2024-07-20 14:28:40 +02:00
}