2023-02-24 16:16:15 +02:00
|
|
|
{ cluster, config, depot, lib, tools, ... }:
|
2022-05-15 01:34:09 +03:00
|
|
|
let
|
|
|
|
inherit (tools.meta) domain;
|
|
|
|
|
2022-06-18 03:44:51 +03:00
|
|
|
inherit (config) links;
|
2022-05-15 01:34:09 +03:00
|
|
|
|
2022-08-04 00:36:50 +03:00
|
|
|
inherit (cluster.config.links) loki-ingest;
|
|
|
|
|
2022-05-16 01:09:07 +03:00
|
|
|
cfg = { inherit (config.services) loki; };
|
|
|
|
|
2022-12-17 21:22:49 +02:00
|
|
|
iniList = lib.concatStringsSep " ";
|
2022-05-15 01:34:09 +03:00
|
|
|
|
|
|
|
login = x: "https://login.${domain}/auth/realms/master/protocol/openid-connect/${x}";
|
|
|
|
in
|
|
|
|
{
|
2022-06-17 21:48:20 +03:00
|
|
|
imports = [
|
|
|
|
./tracing.nix
|
|
|
|
];
|
2022-05-15 01:34:09 +03:00
|
|
|
age.secrets.grafana-secrets = {
|
|
|
|
file = ../../../../secrets/grafana-secrets.age;
|
|
|
|
};
|
|
|
|
|
2022-06-18 03:44:51 +03:00
|
|
|
links = {
|
|
|
|
grafana.protocol = "http";
|
|
|
|
prometheus.protocol = "http";
|
|
|
|
loki-grpc = {
|
|
|
|
protocol = "grpc";
|
|
|
|
};
|
|
|
|
};
|
2022-05-15 01:34:09 +03:00
|
|
|
services.grafana = {
|
|
|
|
enable = true;
|
2023-02-24 16:16:15 +02:00
|
|
|
package = depot.packages.grafana;
|
2022-05-15 01:34:09 +03:00
|
|
|
dataDir = "/srv/storage/private/grafana";
|
2022-12-17 21:22:49 +02:00
|
|
|
settings = {
|
2022-12-17 21:28:27 +02:00
|
|
|
server = {
|
|
|
|
root_url = "https://monitoring.${domain}/";
|
|
|
|
http_port = links.grafana.port;
|
|
|
|
};
|
|
|
|
analytics.reporting_enabled = false;
|
2022-12-17 21:22:49 +02:00
|
|
|
"auth.generic_oauth" = {
|
2022-05-15 01:34:09 +03:00
|
|
|
enabled = true;
|
|
|
|
allow_sign_up = true;
|
|
|
|
client_id = "net.privatevoid.monitoring1";
|
|
|
|
auth_url = login "auth";
|
|
|
|
token_url = login "token";
|
|
|
|
api_url = login "userinfo";
|
2022-12-17 21:22:49 +02:00
|
|
|
scopes = iniList [ "openid" "profile" "email" "roles" ];
|
2022-05-15 01:34:09 +03:00
|
|
|
role_attribute_strict = true;
|
|
|
|
role_attribute_path = "resource_access.monitoring.roles[0]";
|
|
|
|
};
|
|
|
|
security = {
|
|
|
|
cookie_secure = true;
|
|
|
|
disable_gravatar = true;
|
|
|
|
};
|
2022-12-17 21:22:49 +02:00
|
|
|
feature_toggles.enable = iniList [
|
2022-06-18 23:33:30 +03:00
|
|
|
"tempoSearch"
|
|
|
|
"tempoBackendSearch"
|
|
|
|
"tempoServiceGraph"
|
|
|
|
];
|
2022-05-15 01:34:09 +03:00
|
|
|
};
|
|
|
|
provision = {
|
|
|
|
enable = true;
|
2022-12-17 21:03:51 +02:00
|
|
|
datasources.settings.datasources = [
|
2022-05-15 01:34:09 +03:00
|
|
|
{
|
|
|
|
name = "Prometheus";
|
2022-12-17 21:03:51 +02:00
|
|
|
uid = "PBFA97CFB590B2093";
|
2022-06-18 03:44:51 +03:00
|
|
|
inherit (links.prometheus) url;
|
2022-05-15 01:34:09 +03:00
|
|
|
type = "prometheus";
|
|
|
|
isDefault = true;
|
|
|
|
}
|
2022-05-16 01:09:07 +03:00
|
|
|
{
|
|
|
|
name = "Loki";
|
2022-12-17 21:03:51 +02:00
|
|
|
uid = "P8E80F9AEF21F6940";
|
2022-08-04 00:36:50 +03:00
|
|
|
inherit (loki-ingest) url;
|
2022-05-16 01:09:07 +03:00
|
|
|
type = "loki";
|
|
|
|
}
|
2022-05-15 01:34:09 +03:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.grafana.serviceConfig = {
|
|
|
|
EnvironmentFile = config.age.secrets.grafana-secrets.path;
|
|
|
|
};
|
|
|
|
|
2022-06-18 03:44:51 +03:00
|
|
|
services.nginx.virtualHosts."monitoring.${domain}" = lib.recursiveUpdate (tools.nginx.vhosts.proxy links.grafana.url) {
|
2022-05-16 01:11:36 +03:00
|
|
|
locations."/".proxyWebsockets = true;
|
|
|
|
};
|
2022-05-15 01:34:09 +03:00
|
|
|
|
|
|
|
services.prometheus = {
|
|
|
|
enable = true;
|
2022-06-18 03:44:51 +03:00
|
|
|
listenAddress = links.prometheus.ipv4;
|
|
|
|
inherit (links.prometheus) port;
|
2022-06-19 00:24:12 +03:00
|
|
|
extraFlags = [ "--enable-feature=remote-write-receiver" ];
|
2022-05-15 01:34:09 +03:00
|
|
|
globalConfig = {
|
|
|
|
scrape_interval = "60s";
|
|
|
|
};
|
|
|
|
scrapeConfigs = [
|
|
|
|
{
|
|
|
|
job_name = "node";
|
2022-08-04 02:10:11 +03:00
|
|
|
static_configs = lib.flip lib.mapAttrsToList cluster.config.vars.mesh (name: host: {
|
|
|
|
targets = [ "${host.meshIp}:9100" ];
|
2022-05-15 01:34:09 +03:00
|
|
|
labels.instance = name;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
{
|
|
|
|
job_name = "jitsi";
|
|
|
|
static_configs = [
|
|
|
|
{
|
2022-08-04 02:10:11 +03:00
|
|
|
targets = [ "${cluster.config.vars.mesh.prophet.meshIp}:9700" ];
|
2022-05-15 01:34:09 +03:00
|
|
|
labels.instance = "meet.${domain}";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
2022-05-16 01:10:58 +03:00
|
|
|
{
|
|
|
|
job_name = "ipfs";
|
|
|
|
scheme = "https";
|
|
|
|
metrics_path = "/debug/metrics/prometheus";
|
|
|
|
static_configs = [
|
|
|
|
{
|
|
|
|
targets = [ "ipfs.admin.${domain}" ];
|
|
|
|
labels.instance = "VEGAS";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
2022-05-15 01:34:09 +03:00
|
|
|
];
|
|
|
|
};
|
2022-05-16 01:09:07 +03:00
|
|
|
|
2022-08-04 00:36:50 +03:00
|
|
|
systemd.services.loki.after = [ "wireguard-wgmesh.service" ];
|
2022-05-16 01:09:07 +03:00
|
|
|
services.loki = {
|
|
|
|
enable = true;
|
|
|
|
dataDir = "/srv/storage/private/loki";
|
|
|
|
configuration = {
|
|
|
|
auth_enabled = false;
|
|
|
|
server = {
|
2022-05-31 22:28:03 +03:00
|
|
|
log_level = "warn";
|
2022-08-04 00:36:50 +03:00
|
|
|
http_listen_address = loki-ingest.ipv4;
|
|
|
|
http_listen_port = loki-ingest.port;
|
2022-06-18 03:44:51 +03:00
|
|
|
grpc_listen_address = links.loki-grpc.ipv4;
|
|
|
|
grpc_listen_port = links.loki-grpc.port;
|
2022-05-16 01:09:07 +03:00
|
|
|
};
|
2022-06-18 03:44:51 +03:00
|
|
|
frontend_worker.frontend_address = links.loki-grpc.tuple;
|
2022-05-16 01:09:07 +03:00
|
|
|
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 = "2022-05-14";
|
|
|
|
store = "boltdb";
|
|
|
|
object_store = "filesystem";
|
|
|
|
schema = "v11";
|
|
|
|
index = {
|
|
|
|
prefix = "index_";
|
|
|
|
period = "168h";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
storage_config = {
|
|
|
|
boltdb.directory = "${cfg.loki.dataDir}/boltdb-index";
|
|
|
|
filesystem.directory = "${cfg.loki.dataDir}/storage-chunks";
|
|
|
|
};
|
|
|
|
limits_config = {
|
|
|
|
enforce_metric_name = false;
|
|
|
|
reject_old_samples = true;
|
|
|
|
reject_old_samples_max_age = "168h";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2022-05-15 01:34:09 +03:00
|
|
|
}
|