grafana: split up configuration + postgres

- Move `services/grafana.nix` to `services/grafana/default.nix`
- Split up all data collectors into separate files under
  `services/grafana`
- Make grafana use postgres as its database
This commit is contained in:
Oystein Kristoffer Tveit 2022-11-24 15:20:43 +01:00
parent 850eaa9b1a
commit f2a89d7c82
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
6 changed files with 101 additions and 77 deletions

View File

@ -7,7 +7,7 @@
# ./services/dokuwiki.nix
./services/gitea
# ./services/gitlab
./services/grafana.nix
./services/grafana
./services/hydra.nix
# ./services/jitsi.nix
./services/jupyter.nix

View File

@ -1,76 +0,0 @@
{ config, lib, secrets, ... }:
{
services.grafana = {
enable = true;
domain = "log.nani.wtf";
port = secrets.ports.grafana;
addr = "0.0.0.0";
};
# services.influxdb = {
# enable = true;
# dataDir = "/data/var/influxdb";
# extraConfig = {
# udp = {
# enabled = true;
# bind-address = "0.0.0.0:8089";
# database = "proxmox";
# batch-size = 1000;
# batch-timeout = "1s";
# };
# };
# };
services.prometheus = {
enable = true;
port = secrets.ports.prometheus;
scrapeConfigs = [
{
job_name = "synapse";
scrape_interval = "15s";
metrics_path = "/_synapse/metrics";
static_configs = [
{
targets = [ "localhost:${toString secrets.ports.matrix.listener}" ];
}
];
}
{
job_name = "minecraft";
# scrape_interval = "15s";
# metrics_path = "/_synapse/metrics";
static_configs = [
{
targets = [ "${secrets.ips.crafty}:${toString secrets.ports.prometheus-crafty}" ];
labels = {
server_name = "my-minecraft-server";
};
}
];
}
];
exporters = {
jitsi.enable = true;
nginx.enable = true;
nginxlog.enable = true;
systemd.enable = true;
# postgres.enable = true;
};
# globalConfig = {
# };
};
# services.loki = {
# enable = true;
# configFile = ./loki-local-config.yaml;
# config = {
# };
# };
}

View File

@ -0,0 +1,22 @@
{ config, lib, secrets, ... }:
{
imports = [
./prometheus.nix
./influxdb.nix
./loki.nix
];
services.grafana = {
enable = true;
domain = "log.nani.wtf";
port = secrets.ports.grafana;
addr = "0.0.0.0";
dataDir = "${config.machineVars.dataDrives.default}/var/grafana";
database = {
type = "postgres";
user = "grafana";
host = "localhost:${toString secrets.ports.postgres}";
};
};
}

View File

@ -0,0 +1,16 @@
{ config, secrets, ... }:
{
# services.influxdb = {
# enable = true;
# dataDir = "${config.machineVars.dataDrives.default}/var/influxdb";
# extraConfig = {
# udp = {
# enabled = true;
# bind-address = "0.0.0.0:8089";
# database = "proxmox";
# batch-size = 1000;
# batch-timeout = "1s";
# };
# };
# };
}

View File

@ -0,0 +1,10 @@
{ ... }:
{
# services.loki = {
# enable = true;
# configFile = ./loki-local-config.yaml;
# config = {
# };
# };
}

View File

@ -0,0 +1,52 @@
{ secrets, ... }: {
services.prometheus = {
enable = true;
port = secrets.ports.prometheus;
scrapeConfigs = [
{
job_name = "synapse";
scrape_interval = "15s";
metrics_path = "/_synapse/metrics";
static_configs = [
{
targets = [ "localhost:${toString secrets.ports.matrix.listener}" ];
}
];
}
# {
# job_name = "minecraft";
# # scrape_interval = "15s";
# # metrics_path = "/_synapse/metrics";
# static_configs = [
# {
# targets = [ "${secrets.ips.crafty}:${toString secrets.ports.prometheus-crafty}" ];
# labels = {
# server_name = "my-minecraft-server";
# };
# }
# ];
# }
];
exporters = {
# jitsi.enable = true;
nginx.enable = true;
nginxlog.enable = true;
systemd.enable = true;
# openldap
# openvpn
# nextcloud
# influxdb
# wireguard
# postgres = {
# enable = true;
# };
};
# globalConfig = {
# };
};
}