nix-config/modules/data-hoarder/grafana.nix

123 lines
3.4 KiB
Nix
Raw Normal View History

{ config, lib, self, ... }: {
2022-05-12 20:04:06 +02:00
services = {
# metrics collector
prometheus = {
enable = true;
port = 9501;
retentionTime = "2d";
exporters = {
# node exports hardware information like memory, cpu usage and the like
node = {
enable = true;
enabledCollectors = [ "systemd" ];
port = 9502;
};
# used for pinging services and checking their health
2022-05-12 20:04:06 +02:00
blackbox = {
enable = true;
2022-05-29 02:25:08 +02:00
configFile = ../../services/blackbox.yaml;
2022-05-12 20:04:06 +02:00
};
};
scrapeConfigs = [
# hardware information
{
job_name = "data-hoarder hardware";
static_configs = [{
targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ];
}];
}
2022-11-19 01:59:36 +01:00
# funnel connection metrics
{
job_name = "funnel-connections";
static_configs = [
{
2022-12-30 18:29:13 +01:00
targets = [ "127.0.0.1:${toString config.TLMS.funnel.metrics.port}"];
2022-11-19 01:59:36 +01:00
}
];
}
2022-05-12 20:04:06 +02:00
# checks if the data-accumulator server is running
{
job_name = "blackbox-data-accumulator";
metrics_path = "/probe";
params = { module = [ "http_2xx" ]; };
static_configs = [{
targets = [
"127.0.0.1:8080"
2022-05-12 20:04:06 +02:00
];
}];
relabel_configs = [
{ source_labels = [ "__address__" ]; target_label = "__param_target"; }
{ source_labels = [ "__param_target" ]; target_label = "instance"; }
{ target_label = "__address__"; replacement = "127.0.0.1:9115"; }
];
}
# checks if the dvb-api server is running
{
job_name = "blackbox-dvb-api";
metrics_path = "/probe";
params = { module = [ "http_2xx" ]; };
static_configs = [{
targets = [
2022-12-30 18:29:13 +01:00
"api.${config.deployment-TLMS.domain}"
2022-05-12 20:04:06 +02:00
];
}];
relabel_configs = [
{ source_labels = [ "__address__" ]; target_label = "__param_target"; }
{ source_labels = [ "__param_target" ]; target_label = "instance"; }
{ target_label = "__address__"; replacement = "127.0.0.1:9115"; }
];
}
];
};
promtail = {
enable = true;
# doesn't have a configFile option so this has to do
configuration = builtins.fromJSON (lib.readFile "${self}/services/promtail.json");
2022-05-12 20:04:06 +02:00
};
# exports systemd logs and other
loki = {
enable = true;
configFile = self + /services/loki.yaml;
2022-05-12 20:04:06 +02:00
};
# visualizer
grafana = {
2022-12-09 23:16:10 +01:00
settings.server = {
2022-12-30 18:29:13 +01:00
domain = "monitoring.${config.deployment-TLMS.domain}";
2022-12-19 12:19:14 +01:00
http_port = 2342;
http_addr = "127.0.0.1";
2022-12-09 23:16:10 +01:00
};
2022-05-12 20:04:06 +02:00
enable = true;
};
# reverse proxy for grafana
nginx = {
enable = true;
virtualHosts = {
2022-12-09 23:16:10 +01:00
"${toString config.services.grafana.settings.server.domain}" = {
2022-05-12 20:04:06 +02:00
forceSSL = true;
enableACME = true;
2022-12-19 12:19:14 +01:00
locations."/" = let
cfg = config.services.grafana;
in {
2022-12-19 12:21:45 +01:00
proxyPass = "http://${cfg.settings.server.http_addr}:${toString cfg.settings.server.http_port}";
2022-05-12 20:04:06 +02:00
proxyWebsockets = true;
};
};
};
};
};
2022-05-14 22:48:07 +02:00
# noXlibs breaks pango/cairo
environment.noXlibs = false;
2022-05-12 20:04:06 +02:00
}