Skip to content

Commit

Permalink
WIP Add prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
rhoriguchi committed Nov 30, 2024
1 parent 1a53e2a commit 2614c96
Showing 1 changed file with 49 additions and 10 deletions.
59 changes: 49 additions & 10 deletions configuration/devices/headless/server/log-management.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
{ config, secrets, ... }: {
fileSystems = {
"/mnt/Data/Monitoring/loki" = {
depends = [ "/mnt/Data/Monitoring" ];
device = config.services.loki.dataDir;
fsType = "none";
options = [ "bind" ];
};

"/mnt/Data/Monitoring/prometheus" = {
depends = [ "/mnt/Data/Monitoring" ];
device = "/var/lib/${config.services.prometheus.stateDir}";
fsType = "none";
options = [ "bind" ];
};
};

services = {
nginx = {
enable = true;
Expand Down Expand Up @@ -62,22 +78,35 @@
datasources.settings = {
apiVersion = 1;

datasources = [{
name = "Loki";
type = "loki";
access = "direct";
url = "http://127.0.0.1:${toString config.services.loki.configuration.server.http_listen_port}";
isDefault = true;
}];
datasources = [
{
name = "Loki";
type = "loki";
access = "direct";
url = "http://127.0.0.1:${toString config.services.loki.configuration.server.http_listen_port}";
isDefault = true;
}
{
name = "Prometheus";
type = "prometheus";
access = "proxy";
url = "http://127.0.0.1:${toString config.services.prometheus.port}";

jsonData = {
manageAlerts = true;
prometheusType = "Prometheus";
prometheusVersion = config.services.prometheus.package.version;
cacheLevel = "High";
};
}
];
};
};
};

loki = {
enable = true;

dataDir = "/mnt/Data/Monitoring/loki";

extraFlags = [ "-print-config-stderr" ];

configuration = {
Expand Down Expand Up @@ -134,9 +163,19 @@
};
};

prometheus = {
enable = true;

enableReload = true;

pushgateway.enable = true;

# configText = '';
};

log-shipping.useLocalhost = true;
};

networking.firewall.interfaces.${config.services.wireguard-network.interfaceName}.allowedTCPPorts =
[ config.services.loki.configuration.server.http_listen_port ];
[ config.services.loki.configuration.server.http_listen_port config.services.prometheus.port ];
}

0 comments on commit 2614c96

Please sign in to comment.