Format using alejandra
All checks were successful
/ Build Nix targets (push) Successful in 3m36s

This commit is contained in:
Théo Barnouin 2025-01-23 14:13:19 +01:00
parent 1a25b198ef
commit 781ce2d5e9
24 changed files with 610 additions and 505 deletions

View file

@ -1,8 +1,11 @@
{ lib, config, pkgs, ... }:
let
cfg = config.services.vm_grafana;
in
{
lib,
config,
pkgs,
...
}: let
cfg = config.services.vm_grafana;
in {
options.services.vm_grafana = {
enable = lib.mkEnableOption "Enable minimal config";
vm_ip = lib.mkOption {
@ -19,16 +22,16 @@ in
};
};
config = lib.mkIf cfg.enable {
age.secrets ={
age.secrets = {
grafana-db = {
file = ./secrets/grafana-db.age;
file = ./secrets/grafana-db.age;
owner = "grafana";
};
grafana-oauth_secret = {
file = ./secrets/grafana-oauth_secret.age;
file = ./secrets/grafana-oauth_secret.age;
owner = "grafana";
};
kuma-token.file = ./secrets/kuma-token.age;
kuma-token.file = ./secrets/kuma-token.age;
};
services.rsyslogd = {
enable = true;
@ -59,22 +62,22 @@ in
serve_from_sub_path = false;
};
database = {
type = "postgres";
host = "${cfg.pgsql_ip}:5432";
name = "grafana";
user = "grafana";
type = "postgres";
host = "${cfg.pgsql_ip}:5432";
name = "grafana";
user = "grafana";
password = "\$__file{${config.age.secrets.grafana-db.path}}";
};
"auth.generic_oauth" = {
enabled = "true";
name = "authentik";
enabled = "true";
name = "authentik";
allow_sign_up = "true";
client_id = "9HV82G8F92Jcbw4nP8eppMcPpLcAw5uYpejfReLy";
client_id = "9HV82G8F92Jcbw4nP8eppMcPpLcAw5uYpejfReLy";
client_secret = "\$__file{${config.age.secrets.grafana-oauth_secret.path}}";
scopes = "openid email profile";
auth_url = "https://authentik.le43.eu/application/o/authorize/";
token_url = "https://authentik.le43.eu/application/o/token/";
api_url = "https://authentik.le43.eu/application/o/userinfo/";
scopes = "openid email profile";
auth_url = "https://authentik.le43.eu/application/o/authorize/";
token_url = "https://authentik.le43.eu/application/o/token/";
api_url = "https://authentik.le43.eu/application/o/userinfo/";
role_attribute_path = "contains(groups, 'admin') && 'Admin' || contains(groups, 'admin') && 'Editor' || 'Viewer';role_attribute_strict = false";
allow_assign_grafana_admin = "true";
};
@ -88,95 +91,125 @@ in
job_name = "kuma";
scrape_interval = "30s";
scheme = "http";
static_configs = [{
targets = [ "192.168.1.90:3001" ];
}];
static_configs = [
{
targets = ["192.168.1.90:3001"];
}
];
basic_auth.username = "tbarnouin";
basic_auth.password_file = config.age.secrets.kuma-token.path;
}
{
job_name = "grafana";
static_configs = [{
targets = [ "127.0.0.1:9002" ];
}];
static_configs = [
{
targets = ["127.0.0.1:9002"];
}
];
}
{
job_name = "openmediavault_cadvisor";
static_configs = [{
targets = [ "192.168.1.125:8080" ];
}];
static_configs = [
{
targets = ["192.168.1.125:8080"];
}
];
}
{
job_name = "opportunity";
static_configs = [{
targets = [ "192.168.1.125:9100" ];
}];
static_configs = [
{
targets = ["192.168.1.125:9100"];
}
];
}
{
job_name = "nginx";
static_configs = [{
targets = [ "${cfg.proxy_ip}:9002" ];
}];
static_configs = [
{
targets = ["${cfg.proxy_ip}:9002"];
}
];
}
{
job_name = "redis";
static_configs = [{
targets = [ "192.168.1.16:9002" ];
}];
static_configs = [
{
targets = ["192.168.1.16:9002"];
}
];
}
{
job_name = "ingenuity";
static_configs = [{
targets = [ "192.168.1.90:9100" ];
}];
static_configs = [
{
targets = ["192.168.1.90:9100"];
}
];
}
{
job_name = "gitea";
static_configs = [{
targets = [ "192.168.1.14:9100" ];
}];
static_configs = [
{
targets = ["192.168.1.14:9100"];
}
];
}
{
job_name = "postgresql";
static_configs = [{
targets = [ "192.168.1.13:9100" ];
}];
static_configs = [
{
targets = ["192.168.1.13:9100"];
}
];
}
{
job_name = "nextcloud";
static_configs = [{
targets = [ "192.168.1.44:9100" ];
}];
static_configs = [
{
targets = ["192.168.1.44:9100"];
}
];
}
{
job_name = "deluge";
static_configs = [{
targets = [ "192.168.1.18:9100" ];
}];
static_configs = [
{
targets = ["192.168.1.18:9100"];
}
];
}
{
job_name = "netbox";
static_configs = [{
targets = [ "192.168.1.45:9100" ];
}];
static_configs = [
{
targets = ["192.168.1.45:9100"];
}
];
}
{
job_name = "jellyfin";
static_configs = [{
targets = [ "192.168.1.42:9100" ];
}];
static_configs = [
{
targets = ["192.168.1.42:9100"];
}
];
}
{
job_name = "authentik-ldap";
static_configs = [{
targets = [ "192.168.1.41:9100" ];
}];
static_configs = [
{
targets = ["192.168.1.41:9100"];
}
];
}
{
job_name = "authentik";
static_configs = [{
targets = [ "192.168.1.25:9002" ];
}];
static_configs = [
{
targets = ["192.168.1.25:9002"];
}
];
}
];
};
@ -202,16 +235,18 @@ in
chunk_retain_period = "30s";
};
schema_config = {
configs = [{
from = "2022-06-06";
store = "boltdb-shipper";
object_store = "filesystem";
schema = "v13";
index = {
prefix = "index_";
period = "24h";
};
}];
configs = [
{
from = "2022-06-06";
store = "boltdb-shipper";
object_store = "filesystem";
schema = "v13";
index = {
prefix = "index_";
period = "24h";
};
}
];
};
storage_config = {
boltdb_shipper = {
@ -255,14 +290,16 @@ in
positions = {
filename = "/tmp/positions.yaml";
};
clients = [{
url = "http://127.0.0.1:3100/loki/api/v1/push";
}];
clients = [
{
url = "http://127.0.0.1:3100/loki/api/v1/push";
}
];
scrape_configs = [
{
job_name = "syslog";
syslog = {
listen_address = "0.0.0.0:1514";
listen_address = "0.0.0.0:1514";
listen_protocol = "tcp";
idle_timeout = "60s";
labels = {
@ -271,27 +308,27 @@ in
};
relabel_configs = [
{
source_labels = [ "__syslog_message_hostname" ];
source_labels = ["__syslog_message_hostname"];
target_label = "host";
}
{
source_labels = [ "__syslog_message_hostname" ];
source_labels = ["__syslog_message_hostname"];
target_label = "hostname";
}
{
source_labels = [ "__syslog_message_severity" ];
source_labels = ["__syslog_message_severity"];
target_label = "level";
}
{
source_labels = [ "__syslog_message_app_name" ];
source_labels = ["__syslog_message_app_name"];
target_label = "application";
}
{
source_labels = [ "__syslog_message_facility" ];
source_labels = ["__syslog_message_facility"];
target_label = "facility";
}
{
source_labels = [ "__syslog_connection_hostname" ];
source_labels = ["__syslog_connection_hostname"];
target_label = "connection_hostname";
}
];
@ -301,7 +338,7 @@ in
};
# Open ports in the firewall.
networking.firewall.allowedTCPPorts = [ 3000 3100 3101 8086 9001 1514 514 ];
networking.firewall.allowedUDPPorts = [ 514 ];
networking.firewall.allowedTCPPorts = [3000 3100 3101 8086 9001 1514 514];
networking.firewall.allowedUDPPorts = [514];
};
}