nixos-config/nixos/machines/chungus/telemetry/opentelemetry-hass.nix

39 lines
1.2 KiB
Nix
Raw Normal View History

{ config, ... }:
{
#{
# name = "home-assistant";
# rules = [
# {
# record = "home_open_window_sum";
# expr = ''sum( homeassistant_binary_sensor_state{entity=~"binary_sensor\\.window_02_contact|binary_sensor\\.window_03_contact|binary_sensor\\.window_04_contact|binary_sensor\\.window_05_contact|binary_sensor\\.window_06_contact|binary_sensor\\.window_07_contact"} )'';
# }
# ] ++ (map
# (number:
# {
# record = "home_at_least_n_windows_open";
# expr = ''home_open_window_sum >= bool ${toString number}'';
# labels.n = number;
# }) [ 1 2 3 ]);
#};
sops.secrets.hass_long_term_token.owner = "prometheus";
services.opentelemetry-collector.settings = {
service.pipelines.metrics.receivers = [ "prometheus" ];
receivers.prometheus.config.scrape_configs = [
{
# 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 = [{
2024-05-18 12:02:21 +02:00
targets = [ "127.0.0.1:8123" ];
}];
}
];
};
}