mirror of
https://github.com/tuxdotrs/nixos-config.git
synced 2025-07-06 17:56:35 +05:30
add grafana loki promtail for monitoring
This commit is contained in:
46
modules/nixos/monitoring/grafana.nix
Normal file
46
modules/nixos/monitoring/grafana.nix
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
lib,
|
||||
username,
|
||||
...
|
||||
}: {
|
||||
services = {
|
||||
grafana = {
|
||||
enable = true;
|
||||
settings = {
|
||||
server.http_port = 8888;
|
||||
security = {
|
||||
admin_user = "${username}";
|
||||
admin_email = "0xtux@pm.me";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nginx = {
|
||||
enable = lib.mkForce true;
|
||||
virtualHosts = {
|
||||
"grafana.0xtux.com" = {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
locations = {
|
||||
"/" = {
|
||||
proxyPass = "http://localhost:8888";
|
||||
extraConfig = ''
|
||||
proxy_set_header Host $host;
|
||||
'';
|
||||
};
|
||||
|
||||
"/api/live/" = {
|
||||
proxyPass = "http://localhost:8888";
|
||||
extraConfig = ''
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header Host $host;
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
77
modules/nixos/monitoring/loki.nix
Normal file
77
modules/nixos/monitoring/loki.nix
Normal file
@ -0,0 +1,77 @@
|
||||
{lib, ...}: {
|
||||
services = {
|
||||
loki = {
|
||||
enable = true;
|
||||
configuration = {
|
||||
auth_enabled = false;
|
||||
server = {
|
||||
http_listen_port = 3100;
|
||||
};
|
||||
common = {
|
||||
ring = {
|
||||
instance_addr = "127.0.0.1";
|
||||
kvstore = {
|
||||
store = "inmemory";
|
||||
};
|
||||
};
|
||||
replication_factor = 1;
|
||||
path_prefix = "/tmp/loki";
|
||||
};
|
||||
schema_config = {
|
||||
configs = [
|
||||
{
|
||||
from = "2020-05-15";
|
||||
store = "tsdb";
|
||||
object_store = "filesystem";
|
||||
schema = "v13";
|
||||
index = {
|
||||
prefix = "index_";
|
||||
period = "24h";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
storage_config = {
|
||||
filesystem = {
|
||||
directory = "/tmp/loki/chunks";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nginx = {
|
||||
enable = lib.mkForce true;
|
||||
virtualHosts = {
|
||||
"loki.0xtux.com" = {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
locations = {
|
||||
"/" = {
|
||||
proxyPass = "http://localhost:3100";
|
||||
extraConfig = ''
|
||||
proxy_http_version 1.1;
|
||||
proxy_read_timeout 1800s;
|
||||
proxy_connect_timeout 1600s;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header Connection "Keep-Alive";
|
||||
proxy_set_header Proxy-Connection "Keep-Alive";
|
||||
proxy_redirect off;
|
||||
'';
|
||||
};
|
||||
|
||||
"/ready" = {
|
||||
proxyPass = "http://localhost:3100";
|
||||
extraConfig = ''
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "Keep-Alive";
|
||||
proxy_set_header Proxy-Connection "Keep-Alive";
|
||||
proxy_redirect off;
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
40
modules/nixos/monitoring/promtail.nix
Normal file
40
modules/nixos/monitoring/promtail.nix
Normal file
@ -0,0 +1,40 @@
|
||||
{...}: {
|
||||
services = {
|
||||
promtail = {
|
||||
enable = true;
|
||||
configuration = {
|
||||
server = {
|
||||
http_listen_port = 9080;
|
||||
grpc_listen_port = 0;
|
||||
};
|
||||
positions = {
|
||||
filename = "/var/lib/promtail/positions.yaml";
|
||||
};
|
||||
clients = [
|
||||
{
|
||||
url = "https://loki.0xtux.com/loki/api/v1/push";
|
||||
}
|
||||
];
|
||||
scrape_configs = [
|
||||
{
|
||||
job_name = "journal";
|
||||
journal = {
|
||||
max_age = "12h";
|
||||
labels = {
|
||||
job = "systemd-journal";
|
||||
};
|
||||
};
|
||||
relabel_configs = [
|
||||
{
|
||||
source_labels = [
|
||||
"__journal__systemd_unit"
|
||||
];
|
||||
target_label = "unit";
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user