Enable prometheus, add loki config example, we don't have a global log system so it's not useful though

This commit is contained in:
Lillian Violet 2024-03-26 14:34:28 +01:00
parent b5be1009cf
commit fe1dbd4f95
5 changed files with 107 additions and 1 deletions

View file

@ -9,6 +9,6 @@
imports = [ imports = [
./grafana ./grafana
#./loki #./loki
#./prometheus ./prometheus
]; ];
} }

View file

@ -9,6 +9,24 @@
domain = "grafana.lillianviolet.dev"; domain = "grafana.lillianviolet.dev";
http_port = 2342; http_port = 2342;
http_addr = "127.0.0.1"; http_addr = "127.0.0.1";
provision = {
datasources = [
{
name = "Prometheus";
type = "prometheus";
access = "proxy";
url = "http://localhost:${config.services.prometheus.port}";
isDefault = true;
}
{
name = "Loki";
type = "loki";
access = "proxy";
url = "http://localhost:${config.services.loki.port}";
isDefault = true;
}
];
};
}; };
# nginx reverse proxy # nginx reverse proxy

View file

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

View file

@ -0,0 +1,40 @@
# Enables authentication through the X-Scope-OrgID header, which must be present
# if true. If false, the OrgID will always be set to "fake".
auth_enabled: false
server:
http_listen_address: "0.0.0.0"
http_listen_port: 3100
ingester:
lifecycler:
address: "127.0.0.1"
ring:
kvstore:
store: inmemory
replication_factor: 1
final_sleep: 0s
chunk_idle_period: 5m
chunk_retain_period: 30s
schema_config:
configs:
- from: 2020-05-15
store: boltdb
object_store: filesystem
schema: v11
index:
prefix: index_
period: 168h
storage_config:
boltdb:
directory: /tmp/loki/index
filesystem:
directory: /tmp/loki/chunks
limits_config:
enforce_metric_name: false
reject_old_samples: true
reject_old_samples_max_age: 168h

View file

@ -0,0 +1,38 @@
{
config,
pkgs,
...
}: {
services.prometheus = {
enable = true;
port = 9001;
# Export the current system metrics
exporters = {
node = {
enable = true;
enabledCollectors = ["systemd"];
port = 9002;
};
};
scrapeConfigs = [
# Scrape the current system
{
job_name = "GrafanaService system";
static_configs = [
{
targets = ["127.0.0.1:9002"];
}
];
}
# Scrape the Loki service
# {
# job_name = "Loki service";
# static_configs = [
# {
# targets = ["127.0.0.1:3100"];
# }
# ];
# }
];
};
}