45 lines
1.1 KiB
Nix
45 lines
1.1 KiB
Nix
{ config, lib, ... }:
|
|
with lib;
|
|
with types;
|
|
let
|
|
cfg = config.components.monitor.prometheus;
|
|
in
|
|
{
|
|
options.components.monitor.prometheus = {
|
|
enable = mkOption {
|
|
type = lib.types.bool;
|
|
default = config.components.monitor.metrics.enable;
|
|
};
|
|
port = mkOption {
|
|
type = int;
|
|
default = 8090;
|
|
description = "port to provide Prometheus export";
|
|
};
|
|
};
|
|
|
|
config = mkMerge [
|
|
|
|
(mkIf config.components.monitor.prometheus.enable {
|
|
services.prometheus = {
|
|
checkConfig = "syntax-only";
|
|
enable = true;
|
|
};
|
|
})
|
|
|
|
(mkIf config.components.monitor.prometheus.enable {
|
|
services.opentelemetry-collector.settings = {
|
|
exporters.prometheus.endpoint = "127.0.0.1:${toString cfg.port}";
|
|
service.pipelines.metrics.exporters = [ "prometheus" ];
|
|
};
|
|
services.prometheus.scrapeConfigs = [
|
|
{
|
|
job_name = "opentelemetry";
|
|
metrics_path = "/metrics";
|
|
scrape_interval = "10s";
|
|
static_configs = [ { targets = [ "localhost:${toString cfg.port}" ]; } ];
|
|
}
|
|
];
|
|
})
|
|
|
|
];
|
|
}
|