homeassistant -> prometheus

This commit is contained in:
Ingolf Wagner 2023-02-10 04:16:40 +01:00
parent 860baf6203
commit 421d89d1d8
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
2 changed files with 21 additions and 4 deletions

View file

@ -908,11 +908,11 @@
"secrets": { "secrets": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1675861033, "lastModified": 1675998131,
"narHash": "sha256-N7jtUdy718AzP097ItsqzzxutiNmiBSfEd9AuL1yCoQ=", "narHash": "sha256-j17u/hZeFk/qJsqi8R3//UZbMZUFmuhM3EgqL/DdByo=",
"ref": "main", "ref": "main",
"rev": "847d654dd6393ad31627484785ffb28a73fe034f", "rev": "035d16fc7f29ee294da3091f74a4a909d46f197d",
"revCount": 44, "revCount": 45,
"type": "git", "type": "git",
"url": "ssh://gitea@git.ingolf-wagner.de/palo/nixos-secrets.git" "url": "ssh://gitea@git.ingolf-wagner.de/palo/nixos-secrets.git"
}, },

View file

@ -1,5 +1,7 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }: {
sops.secrets.hass_long_term_token = { };
services.nginx = { services.nginx = {
enable = true; enable = true;
statusPage = true; statusPage = true;
@ -15,6 +17,7 @@
}; };
services.prometheus = { services.prometheus = {
checkConfig = "syntax-only";
enable = true; enable = true;
# keep data for 30 days # keep data for 30 days
extraFlags = [ "--storage.tsdb.retention.time=30d" ]; extraFlags = [ "--storage.tsdb.retention.time=30d" ];
@ -49,6 +52,20 @@
targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ]; targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ];
}]; }];
} }
{
# see https://www.home-assistant.io/integrations/prometheus/
job_name = "home-assistant";
scrape_interval = "60s";
metrics_path = "/api/prometheus";
bearer_token_file = toString config.sops.secrets.hass_long_term_token.path;
static_configs = [{
targets = [ "localhost:8123" ];
labels = {
service = "hass";
server = "pepe";
};
}];
}
]; ];
}; };
} }