8cf7f3cc4a
Visualize the ingested HAProxy request logs in Grafana. - add a `richie-postgres` datasource connecting to the Richie DB over the local Unix socket (/run/postgresql; pg_hba trust for user richie) - order grafana after postgresql.service - add the "HAProxy Requests" dashboard: request rate by backend, response -time percentiles (p50-p99), top user-agents/IPs/endpoints, status mix
97 lines
2.3 KiB
Nix
97 lines
2.3 KiB
Nix
{
|
|
...
|
|
}:
|
|
let
|
|
vars = import ../vars.nix;
|
|
grafanaDataDir = "${vars.services}/grafana";
|
|
in
|
|
{
|
|
networking.firewall.allowedTCPPorts = [ 3000 ];
|
|
|
|
services.grafana = {
|
|
enable = true;
|
|
dataDir = grafanaDataDir;
|
|
settings = {
|
|
database.type = "sqlite3";
|
|
security = {
|
|
admin_password = "$__file{${vars.secrets}/services/grafana/admin_password}";
|
|
admin_user = "admin";
|
|
secret_key = "$__file{${vars.secrets}/services/grafana/secret_key}";
|
|
};
|
|
server = {
|
|
http_addr = "192.168.90.40";
|
|
http_port = 3000;
|
|
root_url = "http://192.168.90.40:3000/";
|
|
};
|
|
};
|
|
provision = {
|
|
enable = true;
|
|
dashboards.settings = {
|
|
apiVersion = 1;
|
|
providers = [
|
|
{
|
|
name = "monitoring";
|
|
folder = "Monitoring";
|
|
type = "file";
|
|
disableDeletion = false;
|
|
editable = false;
|
|
allowUiUpdates = false;
|
|
updateIntervalSeconds = 30;
|
|
options.path = ../monitoring/dashboards;
|
|
}
|
|
];
|
|
};
|
|
datasources.settings = {
|
|
apiVersion = 1;
|
|
prune = true;
|
|
datasources = [
|
|
{
|
|
access = "proxy";
|
|
editable = false;
|
|
isDefault = true;
|
|
name = "prom-main";
|
|
type = "prometheus";
|
|
uid = "prom-main";
|
|
url = "http://127.0.0.1:9090";
|
|
}
|
|
{
|
|
access = "proxy";
|
|
editable = false;
|
|
name = "prom-pid-short";
|
|
type = "prometheus";
|
|
uid = "prom-pid-short";
|
|
url = "http://127.0.0.1:9092";
|
|
}
|
|
{
|
|
access = "proxy";
|
|
editable = false;
|
|
name = "richie-postgres";
|
|
type = "postgres";
|
|
uid = "richie-postgres";
|
|
url = "/run/postgresql";
|
|
user = "richie";
|
|
jsonData = {
|
|
database = "richie";
|
|
sslmode = "disable";
|
|
postgresVersion = 1700;
|
|
timescaledb = false;
|
|
};
|
|
}
|
|
];
|
|
};
|
|
};
|
|
};
|
|
|
|
systemd = {
|
|
services.grafana.after = [
|
|
"prometheus-main.service"
|
|
"prometheus-pid-short.service"
|
|
"postgresql.service"
|
|
];
|
|
|
|
tmpfiles.rules = [
|
|
"d ${grafanaDataDir} 0750 grafana grafana - -"
|
|
];
|
|
};
|
|
}
|