configure loki and grafana

This commit is contained in:
Ingolf Wagner 2023-02-07 21:56:04 +01:00
parent 531d660edd
commit 49533a5aad
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
8 changed files with 143 additions and 13 deletions

View file

@ -19,6 +19,8 @@ let
"transmission2.robi" = hosts.robi; "transmission2.robi" = hosts.robi;
"loki.robi" = hosts.robi; "loki.robi" = hosts.robi;
"loki.pepe" = hosts.pepe; "loki.pepe" = hosts.pepe;
"grafana.pepe" = hosts.pepe;
"prometheus.pepe" = hosts.pepe;
"tts.pepe" = hosts.pepe; "tts.pepe" = hosts.pepe;
}; };
network = "private"; network = "private";

View file

@ -24,7 +24,10 @@
./wireguard.nix ./wireguard.nix
#./tts.nix #./tts.nix
#./loki.nix ./loki.nix
./loki-promtail.nix
./prometheus.nix
./grafana.nix
]; ];

View file

@ -0,0 +1,22 @@
{ config, ... }:
{
services.nginx.virtualHosts.${config.services.grafana.domain} = {
extraConfig = ''
allow ${config.tinc.private.subnet};
deny all;
'';
locations."/" = {
proxyPass = "http://localhost:${toString config.services.grafana.port}";
proxyWebsockets = true;
};
};
services.grafana = {
enable = true;
domain = "grafana.pepe.private";
port = 2342;
addr = "localhost";
};
}

View file

@ -1,6 +1,35 @@
{ config, ... }:
{ {
services.promtail = { services.promtail = {
enable = true; enable = true;
configuration = { }; configuration = {
server = {
http_listen_port = 28183;
grpc_listen_port = 0;
};
positions.filename = "/tmp/positions.yaml";
clients = [
{ url = "http://127.0.0.1:3100/loki/api/v1/push"; }
];
scrape_configs = [
{
job_name = "journal";
journal = {
max_age = "12h";
labels = {
job = "systemd-journal";
host = config.networking.hostName;
};
};
relabel_configs = [{
source_labels = [ "__journal__systemd_unit" ];
target_label = "unit";
}];
}
];
};
}; };
} }

View file

@ -4,7 +4,10 @@
services.loki = { services.loki = {
enable = true; enable = true;
configuration = { configuration = {
server.http_listen_port = 3100; server = {
http_listen_port = 3100;
log_level = "warn";
};
auth_enabled = false; auth_enabled = false;
ingester = { ingester = {

View file

@ -0,0 +1,54 @@
{ config, pkgs, lib, ... }: {
services.nginx = {
enable = true;
statusPage = true;
virtualHosts = {
"prometheus.pepe.private" = {
extraConfig = ''
allow ${config.tinc.private.subnet};
deny all;
'';
locations."/" = { proxyPass = "http://localhost:${toString config.services.prometheus.port}"; };
};
};
};
services.prometheus = {
enable = true;
# keep data for 30 days
extraFlags = [ "--storage.tsdb.retention.time=30d" ];
exporters = {
node = {
enable = true;
enabledCollectors = [ "systemd" ];
port = 9002;
};
};
scrapeConfigs = [
{
job_name = "netdata";
metrics_path = "/api/v1/allmetrics";
params.format = [ "prometheus" ];
scrape_interval = "5s";
static_configs = [
{
targets = [ "localhost:19999" ];
labels = {
service = "netdata";
server = "pepe";
};
}
];
}
{
job_name = "systemd";
static_configs = [{
targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ];
}];
}
];
};
}

View file

@ -20,7 +20,7 @@
homeassistant = true; homeassistant = true;
# allow new devices to join # allow new devices to join
permit_join = true; permit_join = false;
# MQTT settings # MQTT settings
mqtt = { mqtt = {
@ -44,11 +44,14 @@
# you own network key, # you own network key,
# 16 numbers between 0 and 255 # 16 numbers between 0 and 255
# see https://www.zigbee2mqtt.io/how_tos/how_to_secure_network.html # see https://www.zigbee2mqtt.io/how_tos/how_to_secure_network.html
advanced.network_key = import "${private_assets}/zigbee/networkKey.nix"; advanced = {
advanced.log_output = [ "console" ]; network_key = import "${private_assets}/zigbee/networkKey.nix";
advanced.pan_id = 1337; log_output = [ "console" ];
log_level = "warn";
pan_id = 1337;
# add last seen information # add last seen information
advanced.last_seen = "ISO_8601_local"; last_seen = "ISO_8601_local";
};
# configure web ui # configure web ui
frontend.port = 9666; frontend.port = 9666;

View file

@ -25,10 +25,7 @@
href = "http://${host}:19999/"; href = "http://${host}:19999/";
image = "https://media.giphy.com/media/BkjdN6MQCDPaw/giphy.gif"; image = "https://media.giphy.com/media/BkjdN6MQCDPaw/giphy.gif";
}) })
(map (name: { inherit name; }) [ (map (name: { inherit name; }) [ "robi" "pepe" "sterni" ]);
"robi"
"pepe"
]);
} }
{ {
text = "Home"; text = "Home";
@ -48,6 +45,23 @@
href = "http://pepe:8096/"; href = "http://pepe:8096/";
image = "https://media.giphy.com/media/fyLi0OuWysotq/giphy.gif"; image = "https://media.giphy.com/media/fyLi0OuWysotq/giphy.gif";
} }
{
label = "pepe - logs";
href = "http://grafana.pepe.private/explore";
image = "https://raw.githubusercontent.com/cncf/landscape/master/hosted_logos/grafana-loki.svg";
}
{
label = "pepe - grafana";
href = "http://http://grafana.pepe.private/";
image = "https://www.vectorlogo.zone/logos/grafana/grafana-icon.svg";
}
{
label = "pepe - prometheus";
href = "http://prometheus.pepe.private/";
image = "https://www.vectorlogo.zone/logos/prometheusio/prometheusio-icon.svg";
}
]; ];
} }
{ {