Skip to content

Commit ca1eaf7

Browse files
committed
wip: grafana
1 parent 9ba9f43 commit ca1eaf7

File tree

2 files changed

+97
-45
lines changed

2 files changed

+97
-45
lines changed

SwarselSystems.org

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6592,24 +6592,26 @@ Also, the system state version is set here. No need to touch it.
65926592
enable = true;
65936593
datasources.settings = {
65946594
datasources = [
6595-
{
6595+
{
65966596
name = "prometheus";
65976597
type = "prometheus";
65986598
url = "https://status.swarsel.win/prometheus";
6599-
editable = true;
6599+
editable = false;
66006600
access = "proxy";
66016601
basicAuth = true;
66026602
basicAuthUser = "admin";
6603-
basicAuthPassword = "$__file{/run/secrets/prometheusadminpass}";
66046603
jsonData = {
66056604
httpMethod = "POST";
66066605
manageAlerts = true;
66076606
prometheusType = "Prometheus";
6608-
prometheusVersion = ">2.50.x";
6607+
prometheusVersion = "> 2.50.x";
66096608
cacheLevel = "High";
66106609
disableRecordingRules = false;
66116610
incrementalQueryOverlapWindow = "10m";
66126611
};
6612+
secureJsonData = {
6613+
basicAuthPassword = "$__file{/run/secrets/prometheusadminpass}";
6614+
};
66136615
}
66146616
];
66156617
};
@@ -6631,8 +6633,31 @@ Also, the system state version is set here. No need to touch it.
66316633
webExternalUrl = "https://status.swarsel.win/prometheus";
66326634
port = 9090;
66336635
listenAddress = "127.0.0.1";
6636+
globalConfig = {
6637+
scrape_interval = "10s";
6638+
};
66346639
webConfigFile = ../../../programs/server/prometheus/web.config;
6640+
scrapeConfigs = [
6641+
{
6642+
job_name = "node";
6643+
static_configs = [{
6644+
targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ];
6645+
}];
6646+
}
6647+
{
6648+
job_name = "zfs";
6649+
static_configs = [{
6650+
targets = [ "localhost:${toString config.services.prometheus.exporters.zfs.port}" ];
6651+
}];
6652+
}
6653+
];
66356654
exporters = {
6655+
node = {
6656+
enable = true;
6657+
port = 9000;
6658+
enabledCollectors = [ "systemd" ];
6659+
extraFlags = [ "--collector.ethtool" "--collector.softirqs" "--collector.tcpstat" "--collector.wifi" ];
6660+
};
66366661
zfs = {
66376662
enable = true;
66386663
port = 9134;
@@ -6642,31 +6667,32 @@ Also, the system state version is set here. No need to touch it.
66426667
};
66436668
};
66446669
};
6670+
};
66456671

6646-
services.nginx = {
6647-
virtualHosts = {
6648-
"status.swarsel.win" = {
6649-
enableACME = true;
6650-
forceSSL = true;
6651-
acmeRoot = null;
6652-
locations = {
6653-
"/" = {
6654-
proxyPass = "http://localhost:3000";
6655-
extraConfig = ''
6656-
client_max_body_size 0;
6657-
'';
6658-
};
6659-
"/prometheus" = {
6660-
proxyPass = "http://localhost:9090";
6661-
extraConfig = ''
6662-
client_max_body_size 0;
6663-
'';
6664-
};
6672+
services.nginx = {
6673+
virtualHosts = {
6674+
"status.swarsel.win" = {
6675+
enableACME = true;
6676+
forceSSL = true;
6677+
acmeRoot = null;
6678+
locations = {
6679+
"/" = {
6680+
proxyPass = "http://localhost:3000";
6681+
extraConfig = ''
6682+
client_max_body_size 0;
6683+
'';
6684+
};
6685+
"/prometheus" = {
6686+
proxyPass = "http://localhost:9090";
6687+
extraConfig = ''
6688+
client_max_body_size 0;
6689+
'';
66656690
};
66666691
};
66676692
};
66686693
};
66696694
};
6695+
};
66706696

66716697
}
66726698
#+end_src

profiles/server/common/monitoring.nix

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,22 @@
2525
name = "prometheus";
2626
type = "prometheus";
2727
url = "https://status.swarsel.win/prometheus";
28-
editable = true;
28+
editable = false;
2929
access = "proxy";
3030
basicAuth = true;
3131
basicAuthUser = "admin";
32-
basicAuthPassword = "$__file{/run/secrets/prometheusadminpass}";
3332
jsonData = {
3433
httpMethod = "POST";
3534
manageAlerts = true;
3635
prometheusType = "Prometheus";
37-
prometheusVersion = ">2.50.x";
36+
prometheusVersion = "> 2.50.x";
3837
cacheLevel = "High";
3938
disableRecordingRules = false;
4039
incrementalQueryOverlapWindow = "10m";
4140
};
41+
secureJsonData = {
42+
basicAuthPassword = "$__file{/run/secrets/prometheusadminpass}";
43+
};
4244
}
4345
];
4446
};
@@ -60,8 +62,31 @@
6062
webExternalUrl = "https://status.swarsel.win/prometheus";
6163
port = 9090;
6264
listenAddress = "127.0.0.1";
65+
globalConfig = {
66+
scrape_interval = "10s";
67+
};
6368
webConfigFile = ../../../programs/server/prometheus/web.config;
69+
scrapeConfigs = [
70+
{
71+
job_name = "node";
72+
static_configs = [{
73+
targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ];
74+
}];
75+
}
76+
{
77+
job_name = "zfs";
78+
static_configs = [{
79+
targets = [ "localhost:${toString config.services.prometheus.exporters.zfs.port}" ];
80+
}];
81+
}
82+
];
6483
exporters = {
84+
node = {
85+
enable = true;
86+
port = 9000;
87+
enabledCollectors = [ "systemd" ];
88+
extraFlags = [ "--collector.ethtool" "--collector.softirqs" "--collector.tcpstat" "--collector.wifi" ];
89+
};
6590
zfs = {
6691
enable = true;
6792
port = 9134;
@@ -71,30 +96,31 @@
7196
};
7297
};
7398
};
99+
};
74100

75-
services.nginx = {
76-
virtualHosts = {
77-
"status.swarsel.win" = {
78-
enableACME = true;
79-
forceSSL = true;
80-
acmeRoot = null;
81-
locations = {
82-
"/" = {
83-
proxyPass = "http://localhost:3000";
84-
extraConfig = ''
85-
client_max_body_size 0;
86-
'';
87-
};
88-
"/prometheus" = {
89-
proxyPass = "http://localhost:9090";
90-
extraConfig = ''
91-
client_max_body_size 0;
92-
'';
93-
};
101+
services.nginx = {
102+
virtualHosts = {
103+
"status.swarsel.win" = {
104+
enableACME = true;
105+
forceSSL = true;
106+
acmeRoot = null;
107+
locations = {
108+
"/" = {
109+
proxyPass = "http://localhost:3000";
110+
extraConfig = ''
111+
client_max_body_size 0;
112+
'';
113+
};
114+
"/prometheus" = {
115+
proxyPass = "http://localhost:9090";
116+
extraConfig = ''
117+
client_max_body_size 0;
118+
'';
94119
};
95120
};
96121
};
97122
};
98123
};
124+
};
99125

100126
}

0 commit comments

Comments
 (0)