refactoring

This commit is contained in:
Ingolf Wagner 2024-05-15 01:31:07 +02:00
parent 6f527173d9
commit a7f72610d4
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
4 changed files with 42 additions and 40 deletions

View file

@ -18,6 +18,7 @@
./telemetry/opentelemetry.nix ./telemetry/opentelemetry.nix
./telemetry/prometheus.nix ./telemetry/prometheus.nix
./telemetry/prometheus-exporter-node.nix
./telemetry/telegraf.nix ./telemetry/telegraf.nix
]; ];

View file

@ -1,29 +1,5 @@
{ pkgs, config, ... }: { pkgs, config, ... }:
let
prometheus_port = 8090;
in
{ {
imports = [
# prometheus export
{
services.opentelemetry-collector.settings = {
exporters.prometheus.endpoint = "127.0.0.1:${toString prometheus_port}";
service.pipelines.metrics.exporters = [ "prometheus" ];
};
services.prometheus.scrapeConfigs = [
{
job_name = "opentelemetry";
metrics_path = "/metrics";
scrape_interval = "10s";
static_configs = [{ targets = [ "localhost:${toString prometheus_port}" ]; }];
}
];
}
];
services.opentelemetry-collector = { services.opentelemetry-collector = {
enable = true; enable = true;
package = pkgs.unstable.opentelemetry-collector-contrib; package = pkgs.unstable.opentelemetry-collector-contrib;
@ -61,13 +37,6 @@ in
} }
]; ];
} }
{
job_name = "node-exporter";
static_configs = [{
targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ];
}];
}
]; ];
}; };

View file

@ -0,0 +1,17 @@
{ config, ... }:
{
services.opentelemetry-collector.settings.receivers.prometheus.config.scrape_configs = [
{
job_name = "node-exporter";
static_configs = [{
targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ];
}];
}
];
services.prometheus.exporters.node = {
enable = true;
enabledCollectors = [ "systemd" ];
port = 9002;
};
}

View file

@ -1,4 +1,8 @@
{ config, pkgs, lib, ... }: { { config, pkgs, lib, ... }:
let
prometheus_port = 8090;
in
{
services.nginx = { services.nginx = {
enable = true; enable = true;
@ -17,13 +21,24 @@
services.prometheus = { services.prometheus = {
checkConfig = "syntax-only"; checkConfig = "syntax-only";
enable = true; enable = true;
exporters = {
node = {
enable = true;
enabledCollectors = [ "systemd" ];
port = 9002;
};
}; };
imports = [
# open telemetry connection
{
services.opentelemetry-collector.settings = {
exporters.prometheus.endpoint = "127.0.0.1:${toString prometheus_port}";
service.pipelines.metrics.exporters = [ "prometheus" ];
}; };
services.prometheus.scrapeConfigs = [
{
job_name = "opentelemetry";
metrics_path = "/metrics";
scrape_interval = "10s";
static_configs = [{ targets = [ "localhost:${toString prometheus_port}" ]; }];
}
];
}
];
} }