add influx listener to telegraf

This commit is contained in:
fuckwit 2025-04-27 18:35:23 +02:00
parent 72fffad326
commit fa4fafa7a9
No known key found for this signature in database
3 changed files with 89 additions and 64 deletions

View File

@ -2,6 +2,7 @@
config, config,
lib, lib,
pkgs, pkgs,
mypkgs,
... ...
}: let }: let
makeVirtualHost = { makeVirtualHost = {
@ -78,7 +79,7 @@ in {
firewall = { firewall = {
enable = true; enable = true;
allowedTCPPorts = [22 111 443 2049 4000 4001 4002 20048]; allowedTCPPorts = [22 111 443 2049 4000 4001 4002 9999 20048];
allowedUDPPorts = [53 111 2049 4000 4001 4002 20048]; allowedUDPPorts = [53 111 2049 4000 4001 4002 20048];
}; };
}; };
@ -97,6 +98,7 @@ in {
rtl_433 rtl_433
dump1090 dump1090
rtl-sdr rtl-sdr
mypkgs.nixvim
]; ];
users.users."root".openssh.authorizedKeys.keys = [ users.users."root".openssh.authorizedKeys.keys = [
@ -258,13 +260,16 @@ in {
environmentFiles = [config.sops.secrets."telegraf_api_token".path]; environmentFiles = [config.sops.secrets."telegraf_api_token".path];
extraConfig = { extraConfig = {
inputs = { inputs = {
influxdb_v2_listener = {
service_address = "127.0.0.1:9998";
};
prometheus = { prometheus = {
urls = [ urls = [
"http://127.0.0.1:${builtins.toString config.services.prometheus.exporters.zfs.port}" "http://127.0.0.1:${builtins.toString config.services.prometheus.exporters.zfs.port}"
"http://127.0.0.1:${builtins.toString config.services.prometheus.exporters.smartctl.port}" "http://127.0.0.1:${builtins.toString config.services.prometheus.exporters.smartctl.port}"
"http://127.0.0.1:${builtins.toString config.services.prometheus.exporters.systemd.port}" "http://127.0.0.1:${builtins.toString config.services.prometheus.exporters.systemd.port}"
"http://127.0.0.1:${builtins.toString config.services.prometheus.exporters.node.port}" "http://127.0.0.1:${builtins.toString config.services.prometheus.exporters.node.port}"
"http://127.0.0.1:8123"
]; ];
}; };
}; };
@ -274,7 +279,7 @@ in {
token = "\${TELEGRAF_API_TOKEN}"; token = "\${TELEGRAF_API_TOKEN}";
organization = "fuckwit.dev"; organization = "fuckwit.dev";
bucket = "world"; bucket = "world";
timeout = "10s"; timeout = "60s";
}; };
}; };
}; };
@ -283,56 +288,74 @@ in {
nginx = { nginx = {
enable = true; enable = true;
clientMaxBodySize = "500m"; clientMaxBodySize = "500m";
virtualHosts = makeVirtualHosts [ virtualHosts =
# Tasmota devices check /health of the influxdb2 server.
# Telegraf does not provide this endpoint so we fake it via nginx
# https://github.com/influxdata/telegraf/issues/16321
{ {
subdomain = "jdownloader"; "influxdb-proxy.fuckwit.dev" = {
port = 5800; listen = [
{
port = 9999;
addr = "0.0.0.0";
}
];
locations = {
"/health".return = "200 ''";
"/".proxyPass = "http://127.0.0.1:9998";
};
};
} }
{ // makeVirtualHosts [
subdomain = "jellyfin"; {
port = 8096; subdomain = "jdownloader";
} port = 5800;
{ }
subdomain = "sonarr"; {
port = 8989; subdomain = "jellyfin";
} port = 8096;
{ }
subdomain = "radarr"; {
port = 7878; subdomain = "sonarr";
} port = 8989;
{ }
subdomain = "lidarr"; {
port = 8686; subdomain = "radarr";
} port = 7878;
{ }
subdomain = "prowlarr"; {
port = 9696; subdomain = "lidarr";
} port = 8686;
{ }
subdomain = "paperless"; {
port = 28981; subdomain = "prowlarr";
} port = 9696;
{ }
subdomain = "homepage"; {
port = 8082; subdomain = "paperless";
} port = 28981;
{ }
subdomain = "photoprism"; {
port = 2342; subdomain = "homepage";
} port = 8082;
{ }
subdomain = "immich"; {
port = 2283; subdomain = "photoprism";
} port = 2342;
{ }
subdomain = "qbittorrent"; {
port = 8080; subdomain = "immich";
} port = 2283;
{ }
subdomain = "shimmie"; {
port = 8000; subdomain = "qbittorrent";
} port = 8080;
]; }
{
subdomain = "shimmie";
port = 8000;
}
];
}; };
paperless = { paperless = {
@ -582,17 +605,17 @@ in {
]; ];
}; };
qbittorrent-exporter = { # qbittorrent-exporter = {
image = "docker.io/esanchezm/prometheus-qbittorrent-exporter"; # image = "docker.io/esanchezm/prometheus-qbittorrent-exporter";
autoStart = true; # autoStart = true;
networks = ["container:gluetun"]; # networks = ["container:gluetun"];
dependsOn = ["qbittorrent"]; # dependsOn = ["qbittorrent"];
environment = { # environment = {
QBITTORRENT_PORT = "8080"; # QBITTORRENT_PORT = "8080";
QBITTORRENT_HOST = "127.0.0.1"; # QBITTORRENT_HOST = "127.0.0.1";
EXPORTER_PORT = "8123"; # EXPORTER_PORT = "8123";
}; # };
}; # };
}; };
}; };
}; };

View File

@ -4,6 +4,7 @@
sops-nix, sops-nix,
lanzaboote, lanzaboote,
simple-nixos-mailserver, simple-nixos-mailserver,
nixvim,
inputs, inputs,
... ...
}: let }: let
@ -50,7 +51,7 @@
}: }:
np.lib.nixosSystem { np.lib.nixosSystem {
inherit system; inherit system;
specialArgs = {mypkgs = customPkgs."${system}";}; specialArgs = {mypkgs = customPkgs."${system}" // { nixvim = nixvim.packages.${system}.default;};};
modules = modules =
defaultModules defaultModules
++ [ ++ [

View File

@ -16,6 +16,7 @@
}; };
}; };
certificateScheme = "acme-nginx"; certificateScheme = "acme";
acmeCertificateName = "fuckwit.dev";
}; };
} }