working with nix
This commit is contained in:
parent
dfe7918cdb
commit
e0f20e0e9d
4 changed files with 81 additions and 199 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }@attrs:
|
||||||
|
|
||||||
let
|
let
|
||||||
secretName = "grafanaSecret";
|
secretName = "grafanaSecret";
|
||||||
|
|
@ -20,6 +20,7 @@ in
|
||||||
enable = true;
|
enable = true;
|
||||||
declarativePlugins = [ ];
|
declarativePlugins = [ ];
|
||||||
settings = {
|
settings = {
|
||||||
|
"auth.anonymous".enabled = true;
|
||||||
analytics.feedback_links_enabled = false;
|
analytics.feedback_links_enabled = false;
|
||||||
users.default_theme = "system";
|
users.default_theme = "system";
|
||||||
server = {
|
server = {
|
||||||
|
|
@ -35,6 +36,23 @@ in
|
||||||
admin_user = "quadradical";
|
admin_user = "quadradical";
|
||||||
admin_password = "$__file{${credentialDirectory}${passwordName}}";
|
admin_password = "$__file{${credentialDirectory}${passwordName}}";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dashboards.default_home_dashboard_path = toString (
|
||||||
|
(import ../../../lib/status.nix attrs) [
|
||||||
|
{
|
||||||
|
name = "Continuwuity (Matrix)";
|
||||||
|
service = "continuwuity.service";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "Forgejo (Git)";
|
||||||
|
service = "forgejo.service";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "SearXNG (Search)";
|
||||||
|
service = "searx.service";
|
||||||
|
}
|
||||||
|
]
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
provision = {
|
provision = {
|
||||||
|
|
@ -50,23 +68,6 @@ in
|
||||||
];
|
];
|
||||||
|
|
||||||
dashboards.settings.providers = [
|
dashboards.settings.providers = [
|
||||||
{
|
|
||||||
name = "Status";
|
|
||||||
options.path = (import ../../../lib/status.nix { inherit pkgs; }) [
|
|
||||||
{
|
|
||||||
name = "Continuwuity (Matrix)";
|
|
||||||
service = "continuwuity.service";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
name = "Forgejo (Git)";
|
|
||||||
service = "forgejo.service";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
name = "SearXNG (Search)";
|
|
||||||
service = "searx.service";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
name = "Node exporter";
|
name = "Node exporter";
|
||||||
options.path = pkgs.fetchurl {
|
options.path = pkgs.fetchurl {
|
||||||
|
|
@ -78,10 +79,8 @@ in
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
caddy.virtualHosts."${domain}".extraConfig = ''
|
caddy.virtualHosts."${domain}".extraConfig =
|
||||||
redir / /public-dashboards/cf91b463711b401b8bf6336125f70cd3
|
"reverse_proxy unix/${config.services.grafana.settings.server.socket}";
|
||||||
reverse_proxy unix/${config.services.grafana.settings.server.socket}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
users.users.caddy.extraGroups = [ "grafana" ];
|
users.users.caddy.extraGroups = [ "grafana" ];
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
enable = true;
|
enable = true;
|
||||||
listenAddress = "127.0.0.7";
|
listenAddress = "127.0.0.7";
|
||||||
|
|
||||||
globalConfig.scrape_interval = "10s";
|
globalConfig.scrape_interval = "3s";
|
||||||
scrapeConfigs = [
|
scrapeConfigs = [
|
||||||
{
|
{
|
||||||
job_name = "node";
|
job_name = "node";
|
||||||
|
|
|
||||||
|
|
@ -1,176 +0,0 @@
|
||||||
{
|
|
||||||
"annotations": {
|
|
||||||
"list": []
|
|
||||||
},
|
|
||||||
"editable": true,
|
|
||||||
"fiscalYearStartMonth": 0,
|
|
||||||
"graphTooltip": 0,
|
|
||||||
"links": [],
|
|
||||||
"liveNow": false,
|
|
||||||
"panels": [
|
|
||||||
{
|
|
||||||
"datasource": {
|
|
||||||
"type": "prometheus",
|
|
||||||
"uid": "prometheus"
|
|
||||||
},
|
|
||||||
"fieldConfig": {
|
|
||||||
"defaults": {
|
|
||||||
"color": {
|
|
||||||
"mode": "thresholds"
|
|
||||||
},
|
|
||||||
"mappings": [
|
|
||||||
{
|
|
||||||
"options": {
|
|
||||||
"1": {
|
|
||||||
"color": "green",
|
|
||||||
"index": 0,
|
|
||||||
"text": "Running"
|
|
||||||
},
|
|
||||||
"0": {
|
|
||||||
"color": "red",
|
|
||||||
"index": 1,
|
|
||||||
"text": "Failed"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "value"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"thresholds": {
|
|
||||||
"mode": "absolute",
|
|
||||||
"steps": [
|
|
||||||
{
|
|
||||||
"color": "red",
|
|
||||||
"value": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"color": "green",
|
|
||||||
"value": 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"unit": "none"
|
|
||||||
},
|
|
||||||
"overrides": []
|
|
||||||
},
|
|
||||||
"gridPos": {
|
|
||||||
"h": 5,
|
|
||||||
"w": 6,
|
|
||||||
"x": 0,
|
|
||||||
"y": 0
|
|
||||||
},
|
|
||||||
"id": 1,
|
|
||||||
"options": {
|
|
||||||
"colorMode": "value",
|
|
||||||
"graphMode": "none",
|
|
||||||
"justifyMode": "center",
|
|
||||||
"orientation": "auto",
|
|
||||||
"reduceOptions": {
|
|
||||||
"calcs": ["lastNotNull"],
|
|
||||||
"fields": "",
|
|
||||||
"values": false
|
|
||||||
},
|
|
||||||
"textMode": "value"
|
|
||||||
},
|
|
||||||
"pluginVersion": "11.2.0",
|
|
||||||
"targets": [
|
|
||||||
{
|
|
||||||
"expr": "node_systemd_unit_state{name=\"continuwuity.service\",state=\"active\"}",
|
|
||||||
"legendFormat": "Matrix",
|
|
||||||
"refId": "A"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"title": "Matrix",
|
|
||||||
"type": "stat"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"datasource": {
|
|
||||||
"type": "prometheus",
|
|
||||||
"uid": "prometheus"
|
|
||||||
},
|
|
||||||
"fieldConfig": {
|
|
||||||
"defaults": {
|
|
||||||
"color": {
|
|
||||||
"mode": "thresholds"
|
|
||||||
},
|
|
||||||
"mappings": [
|
|
||||||
{
|
|
||||||
"options": {
|
|
||||||
"1": {
|
|
||||||
"color": "green",
|
|
||||||
"index": 0,
|
|
||||||
"text": "Running"
|
|
||||||
},
|
|
||||||
"0": {
|
|
||||||
"color": "red",
|
|
||||||
"index": 1,
|
|
||||||
"text": "Failed"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"type": "value"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"thresholds": {
|
|
||||||
"mode": "absolute",
|
|
||||||
"steps": [
|
|
||||||
{
|
|
||||||
"color": "red",
|
|
||||||
"value": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"color": "green",
|
|
||||||
"value": 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"unit": "none"
|
|
||||||
},
|
|
||||||
"overrides": []
|
|
||||||
},
|
|
||||||
"gridPos": {
|
|
||||||
"h": 5,
|
|
||||||
"w": 6,
|
|
||||||
"x": 6,
|
|
||||||
"y": 0
|
|
||||||
},
|
|
||||||
"id": 2,
|
|
||||||
"options": {
|
|
||||||
"colorMode": "value",
|
|
||||||
"graphMode": "none",
|
|
||||||
"justifyMode": "center",
|
|
||||||
"orientation": "auto",
|
|
||||||
"reduceOptions": {
|
|
||||||
"calcs": ["lastNotNull"],
|
|
||||||
"fields": "",
|
|
||||||
"values": false
|
|
||||||
},
|
|
||||||
"textMode": "value"
|
|
||||||
},
|
|
||||||
"pluginVersion": "11.2.0",
|
|
||||||
"targets": [
|
|
||||||
{
|
|
||||||
"expr": "node_systemd_unit_state{name=\"forgejo.service\",state=\"active\"}",
|
|
||||||
"legendFormat": "Forgejo (Git)",
|
|
||||||
"refId": "A"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"title": "Forgejo (Git)",
|
|
||||||
"type": "stat"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"refresh": "10s",
|
|
||||||
"schemaVersion": 39,
|
|
||||||
"style": "dark",
|
|
||||||
"tags": ["systemd", "status"],
|
|
||||||
"templating": {
|
|
||||||
"list": []
|
|
||||||
},
|
|
||||||
"time": {
|
|
||||||
"from": "now-5m",
|
|
||||||
"to": "now"
|
|
||||||
},
|
|
||||||
"timezone": "",
|
|
||||||
"title": "Service Status Dashboard",
|
|
||||||
"uid": "service-status-dashboard",
|
|
||||||
"version": 1,
|
|
||||||
"weekStart": ""
|
|
||||||
}
|
|
||||||
59
lib/status.nix
Normal file
59
lib/status.nix
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
{ pkgs, lib, ... }:
|
||||||
|
services:
|
||||||
|
pkgs.writers.writeJSON "status.json" {
|
||||||
|
title = "Service Status";
|
||||||
|
panels = map (
|
||||||
|
{ name, service }:
|
||||||
|
{
|
||||||
|
datasource = {
|
||||||
|
type = "prometheus";
|
||||||
|
uid = "prometheus";
|
||||||
|
};
|
||||||
|
fieldConfig = {
|
||||||
|
defaults = {
|
||||||
|
color = {
|
||||||
|
mode = "thresholds";
|
||||||
|
};
|
||||||
|
mappings = [
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
"0" = {
|
||||||
|
color = "red";
|
||||||
|
index = 1;
|
||||||
|
text = "Failed";
|
||||||
|
};
|
||||||
|
"1" = {
|
||||||
|
color = "green";
|
||||||
|
index = 0;
|
||||||
|
text = "Running";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
type = "value";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
thresholds = {
|
||||||
|
mode = "absolute";
|
||||||
|
steps = [
|
||||||
|
{
|
||||||
|
color = "red";
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
color = "green";
|
||||||
|
value = 1;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
unit = "none";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
targets = [
|
||||||
|
{
|
||||||
|
expr = "node_systemd_unit_state{name=\"${service}\",state=\"active\"}";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
title = name;
|
||||||
|
type = "stat";
|
||||||
|
}
|
||||||
|
) services;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue