2024-08-29 03:26:04 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2024-05-15 11:59:24 +02:00
|
|
|
with lib;
|
|
|
|
with types;
|
|
|
|
let
|
2024-05-18 12:02:21 +02:00
|
|
|
cfg = config.components.monitor.telegraf;
|
2024-05-15 11:59:24 +02:00
|
|
|
in
|
|
|
|
{
|
2024-05-18 12:02:21 +02:00
|
|
|
options.components.monitor.telegraf = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = config.components.monitor.metrics.enable;
|
|
|
|
};
|
2024-05-15 11:59:24 +02:00
|
|
|
influxDBPort = mkOption {
|
|
|
|
type = int;
|
|
|
|
default = 8088;
|
|
|
|
description = "Port to listen on influxDB input";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkMerge [
|
2024-05-18 12:02:21 +02:00
|
|
|
(mkIf config.components.monitor.telegraf.enable {
|
2024-05-15 11:59:24 +02:00
|
|
|
# opentelemetry wireing
|
|
|
|
services.opentelemetry-collector.settings = {
|
|
|
|
receivers.influxdb.endpoint = "127.0.0.1:${toString cfg.influxDBPort}";
|
|
|
|
service.pipelines.metrics.receivers = [ "influxdb" ];
|
|
|
|
};
|
2024-08-29 03:26:04 +02:00
|
|
|
services.telegraf.extraConfig.outputs.influxdb_v2.urls = [
|
|
|
|
"http://127.0.0.1:${toString cfg.influxDBPort}"
|
|
|
|
];
|
2024-05-15 11:59:24 +02:00
|
|
|
})
|
|
|
|
|
2024-05-18 12:02:21 +02:00
|
|
|
(mkIf config.components.monitor.telegraf.enable {
|
2024-05-15 11:59:24 +02:00
|
|
|
|
|
|
|
systemd.services.telegraf.path = [ pkgs.inetutils ];
|
|
|
|
|
|
|
|
services.telegraf = {
|
|
|
|
enable = true;
|
|
|
|
extraConfig = {
|
|
|
|
# https://github.com/influxdata/telegraf/tree/master/plugins/inputs < all them plugins
|
|
|
|
inputs = {
|
|
|
|
cpu = { };
|
|
|
|
diskio = { };
|
|
|
|
processes = { };
|
|
|
|
system = { };
|
|
|
|
systemd_units = { };
|
2024-08-29 03:26:04 +02:00
|
|
|
ping = [ { urls = [ "10.100.0.1" ]; } ]; # actually important to make machine visible over wireguard
|
2024-05-15 11:59:24 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
|
|
|
}
|