Skip to content

Commit

Permalink
Experiment with netdata
Browse files Browse the repository at this point in the history
  • Loading branch information
diamondburned committed Mar 6, 2024
1 parent 2be5044 commit cc3d9ac
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 31 deletions.
Binary file added secrets/netdata-key
Binary file not shown.
1 change: 1 addition & 0 deletions servers/cirno/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
(modulesPath + "/virtualisation/amazon-image.nix")
<acm-aws/servers/base.nix>
./services.nix
./telemetry.nix
];

networking.hostName = "cirno";
Expand Down
31 changes: 0 additions & 31 deletions servers/cirno/services.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,37 +48,6 @@ in
};
};

# Gather system metrics using Telegraf into cirno's VictoriaMetrics.
services.telegraf = {
enable = true;
extraConfig = {
inputs = {
net = {};
mem = {};
disk = {};
swap = {};
system = {};
diskio = {};
processes = {};
prometheus = {
urls = [
"http://localhost:2019/metrics" # Caddy
];
};
systemd_units = {};
internet_speed = {
interval = "2h";
};
};
outputs = {
influxdb = {
database = "telegraf";
urls = [ "http://cs306:8428" ];
};
};
};
};

services.christmasd-test = {
enable = true;
ledPointsFile = builtins.fetchurl
Expand Down
60 changes: 60 additions & 0 deletions servers/cirno/telemetry.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{ config, lib, pkgs, ... }:

{
# Enable netdata, which is a lightweight alternative to Grafana.
# https://nixos.wiki/wiki/Netdata
# https://dataswamp.org/~solene/2022-09-16-netdata-cloud-nixos.html
services.netdata = {
enable = true;
config = {
global = {
# Disable storage of metrics on disk.
"memory mode" = "none";
};
web = {
# Disable the web UI.
"mode" = "none";
"accept a streaming request every seconds" = 0;
};
};
configDir = {
"stream.conf" = pkgs.writeText "stream.conf" ''
[stream]
enabled = yes
api key = ${builtins.readFile <acm-aws/secrets/netdata-key>}
destination = cs306:19999
'';
};
};

# Gather system metrics using Telegraf into cirno's VictoriaMetrics.
services.telegraf = {
enable = true;
extraConfig = {
inputs = {
net = {};
mem = {};
disk = {};
swap = {};
system = {};
diskio = {};
processes = {};
prometheus = {
urls = [
"http://localhost:2019/metrics" # Caddy
];
};
systemd_units = {};
internet_speed = {
interval = "2h";
};
};
outputs = {
influxdb = {
database = "telegraf";
urls = [ "http://cs306:8428" ];
};
};
};
};
}
20 changes: 20 additions & 0 deletions servers/cs306/telemetry.nix
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,24 @@
};
};
};

# Enable netdata, which is a lightweight alternative to Grafana.
# https://nixos.wiki/wiki/Netdata
# https://dataswamp.org/~solene/2022-09-16-netdata-cloud-nixos.html
services.netdata = {
enable = true;
configDir = {
"stream.conf" = pkgs.writeText "stream.conf" ''
[stream]
enabled = yes
enable compression = yes
[${builtins.readFile <acm-aws/secrets/netdata-key>}]
enabled = yes
allow from = 100.*
default memory mode = dbengine
health enabled by default = yes
'';
};
};
}

0 comments on commit cc3d9ac

Please sign in to comment.