2023-12-03 13:19:30 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
flake,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
{
|
|
|
|
age.secrets.grafana-admin-password = {
|
|
|
|
file = "${flake.self}/secrets/grafana-admin-password.age";
|
2024-05-12 20:18:28 +00:00
|
|
|
mode = "440";
|
2023-12-03 13:19:30 +00:00
|
|
|
owner = "grafana";
|
|
|
|
};
|
|
|
|
age.secrets.grafana-smtp-password = {
|
|
|
|
file = "${flake.self}/secrets/grafana-smtp-password.age";
|
2024-05-12 20:18:28 +00:00
|
|
|
mode = "440";
|
2023-12-03 13:19:30 +00:00
|
|
|
owner = "grafana";
|
|
|
|
};
|
|
|
|
age.secrets.grafana-keycloak-client-secret = {
|
|
|
|
file = "${flake.self}/secrets/grafana-keycloak-client-secret.age";
|
2024-05-12 20:18:28 +00:00
|
|
|
mode = "440";
|
2023-12-03 13:19:30 +00:00
|
|
|
owner = "grafana";
|
|
|
|
};
|
|
|
|
|
2023-12-05 12:52:39 +00:00
|
|
|
environment.etc = {
|
|
|
|
"grafana-dashboards/node-exporter-full_rev33.json" = {
|
|
|
|
source = ./grafana-dashboards/node-exporter-full_rev33.json;
|
|
|
|
group = "grafana";
|
|
|
|
user = "grafana";
|
|
|
|
};
|
2024-01-30 19:00:41 +00:00
|
|
|
"grafana-dashboards/synapse.json" = {
|
|
|
|
source = ./grafana-dashboards/synapse.json;
|
|
|
|
group = "grafana";
|
|
|
|
user = "grafana";
|
|
|
|
};
|
2023-12-05 12:52:39 +00:00
|
|
|
};
|
|
|
|
|
2024-05-08 17:47:47 +00:00
|
|
|
services.caddy.virtualHosts."grafana.${config.pub-solar-os.networking.domain}" = {
|
2024-04-28 15:25:40 +00:00
|
|
|
logFormat = lib.mkForce ''
|
|
|
|
output discard
|
|
|
|
'';
|
|
|
|
extraConfig = ''
|
|
|
|
reverse_proxy :${toString config.services.grafana.settings.server.http_port}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-12-03 13:19:30 +00:00
|
|
|
services.grafana = {
|
|
|
|
enable = true;
|
|
|
|
settings = {
|
|
|
|
server = {
|
|
|
|
# Listening Address
|
|
|
|
http_addr = "127.0.0.1";
|
|
|
|
# and Port
|
|
|
|
http_port = 3000;
|
|
|
|
# Grafana needs to know on which domain and URL it's running
|
2024-05-08 17:47:47 +00:00
|
|
|
domain = "grafana.${config.pub-solar-os.networking.domain}";
|
|
|
|
root_url = "https://grafana.${config.pub-solar-os.networking.domain}";
|
2023-12-03 13:19:30 +00:00
|
|
|
enable_gzip = true;
|
|
|
|
};
|
|
|
|
smtp = {
|
|
|
|
enabled = true;
|
2024-05-27 15:51:32 +00:00
|
|
|
host = "mail.pub.solar:465";
|
2023-12-03 13:19:30 +00:00
|
|
|
user = "admins@pub.solar";
|
|
|
|
password = "\$__file{${config.age.secrets.grafana-smtp-password.path}}";
|
|
|
|
from_address = "no-reply@pub.solar";
|
|
|
|
from_name = "grafana.pub.solar";
|
|
|
|
ehlo_identity = "flora-6.pub.solar";
|
|
|
|
};
|
|
|
|
security = {
|
|
|
|
admin_email = "crew@pub.solar";
|
|
|
|
admin_password = "\$__file{${config.age.secrets.grafana-admin-password.path}}";
|
|
|
|
};
|
|
|
|
"auth.generic_oauth" = {
|
|
|
|
enabled = true;
|
|
|
|
name = "pub.solar ID";
|
|
|
|
allow_sign_up = true;
|
|
|
|
client_id = "grafana";
|
|
|
|
client_secret = "\$__file{${config.age.secrets.grafana-keycloak-client-secret.path}}";
|
|
|
|
scopes = "openid email profile offline_access roles";
|
|
|
|
email_attribute_path = "email";
|
|
|
|
login_attribute_path = "preferred_username";
|
|
|
|
name_attribute_path = "full_name";
|
2024-05-08 17:47:47 +00:00
|
|
|
auth_url = "https://auth.${config.pub-solar-os.networking.domain}/realms/${config.pub-solar-os.auth.realm}/protocol/openid-connect/auth";
|
|
|
|
token_url = "https://auth.${config.pub-solar-os.networking.domain}/realms/${config.pub-solar-os.auth.realm}/protocol/openid-connect/token";
|
|
|
|
api_url = "https://auth.${config.pub-solar-os.networking.domain}/realms/${config.pub-solar-os.auth.realm}/protocol/openid-connect/userinfo";
|
2023-12-13 16:50:15 +00:00
|
|
|
role_attribute_path = "contains(roles[*], 'admin') && 'GrafanaAdmin' || 'Viewer'";
|
2023-12-03 13:19:30 +00:00
|
|
|
allow_assign_grafana_admin = true;
|
|
|
|
};
|
|
|
|
};
|
2023-12-05 12:52:39 +00:00
|
|
|
provision = {
|
|
|
|
enable = true;
|
|
|
|
datasources = {
|
|
|
|
settings = {
|
|
|
|
datasources = [
|
|
|
|
{
|
|
|
|
name = "Prometheus";
|
|
|
|
type = "prometheus";
|
|
|
|
access = "proxy";
|
|
|
|
url = "http://127.0.0.1:${toString config.services.prometheus.port}";
|
|
|
|
isDefault = true;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "Loki";
|
|
|
|
type = "loki";
|
|
|
|
access = "proxy";
|
|
|
|
url = "http://127.0.0.1:${toString config.services.loki.configuration.server.http_listen_port}";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
dashboards = {
|
|
|
|
settings = {
|
|
|
|
providers = [
|
|
|
|
{
|
|
|
|
name = "pub.solar Dashboards";
|
|
|
|
options.path = "/etc/grafana-dashboards";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-12-03 13:19:30 +00:00
|
|
|
};
|
|
|
|
}
|