2024-05-15 11:59:24 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
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" ];
|
|
|
|
};
|
|
|
|
services.telegraf.extraConfig.outputs.influxdb_v2.urls = [ "http://127.0.0.1:${toString cfg.influxDBPort}" ];
|
|
|
|
})
|
|
|
|
|
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 = { };
|
|
|
|
ping = [{ urls = [ "10.100.0.1" ]; }]; # actually important to make machine visible over wireguard
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
|
|
|
}
|