refactoring
This commit is contained in:
parent
6f527173d9
commit
a7f72610d4
4 changed files with 42 additions and 40 deletions
|
@ -18,6 +18,7 @@
|
|||
|
||||
./telemetry/opentelemetry.nix
|
||||
./telemetry/prometheus.nix
|
||||
./telemetry/prometheus-exporter-node.nix
|
||||
./telemetry/telegraf.nix
|
||||
|
||||
];
|
||||
|
|
|
@ -1,29 +1,5 @@
|
|||
{ 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 = {
|
||||
enable = true;
|
||||
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}" ];
|
||||
}];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
|
|
17
nixos/machines/cherry/telemetry/prometheus-exporter-node.nix
Normal file
17
nixos/machines/cherry/telemetry/prometheus-exporter-node.nix
Normal 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;
|
||||
};
|
||||
|
||||
}
|
|
@ -1,4 +1,8 @@
|
|||
{ config, pkgs, lib, ... }: {
|
||||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
prometheus_port = 8090;
|
||||
in
|
||||
{
|
||||
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
|
@ -17,13 +21,24 @@
|
|||
services.prometheus = {
|
||||
checkConfig = "syntax-only";
|
||||
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}" ]; }];
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue