This repository has no description
2.9 kB
120 lines
1{ lib, pkgs, ... }:
2{
3 #prometheus
4 krebs.iptables = {
5 enable = true;
6 tables.filter.INPUT.rules = [
7 {
8 predicate = "-i retiolum -p tcp --dport 80";
9 target = "ACCEPT";
10 } # nginx
11 # { predicate = "-i retiolum -p tcp --dport 3012"; target = "ACCEPT"; } # grafana
12 # { predicate = "-i retiolum -p tcp --dport 9093"; target = "ACCEPT"; } # alertmanager
13 # { predicate = "-i retiolum -p tcp --dport 9223"; target = "ACCEPT"; } # alertmanager
14 ];
15 };
16
17 services.nginx = {
18 enable = true;
19 virtualHosts = {
20 "prometheus.lass.r" = {
21 locations."/".proxyPass = "http://localhost:9090";
22 };
23 "alert.lass.r" = {
24 locations."/".proxyPass = "http://localhost:9093";
25 };
26 "grafana.lass.r" = {
27 locations."/".proxyPass = "http://localhost:3012";
28 };
29 };
30 };
31
32 services.grafana = {
33 enable = true;
34 addr = "0.0.0.0";
35 port = 3012;
36 auth.anonymous = {
37 enable = true;
38 org_role = "Admin";
39 };
40 };
41 services.prometheus = {
42 enable = true;
43 ruleFiles = [
44 (pkgs.writeText "prometheus-rules.yml" (
45 builtins.toJSON {
46 groups = [
47 {
48 name = "alerting-rules";
49 rules = import ./alert-rules.nix { inherit lib; };
50 }
51 ];
52 }
53 ))
54 ];
55 scrapeConfigs = [
56 {
57 job_name = "telegraf";
58 scrape_interval = "60s";
59 metrics_path = "/metrics";
60 static_configs = [
61 {
62 targets = [
63 "prism.r:9273"
64 "dishfire.r:9273"
65 "yellow.r:9273"
66 ];
67 }
68 ];
69 }
70 ];
71 alertmanagers = [
72 {
73 scheme = "http";
74 path_prefix = "/";
75 static_configs = [ { targets = [ "localhost:9093" ]; } ];
76 }
77 ];
78 alertmanager = {
79 enable = true;
80 webExternalUrl = "https://alert.lass.r";
81 listenAddress = "[::1]";
82 configuration = {
83 global = {
84 # The smarthost and SMTP sender used for mail notifications.
85 smtp_smarthost = "localhost:587";
86 smtp_from = "alertmanager@alert.lass.r";
87 # smtp_auth_username = "alertmanager@thalheim.io";
88 # smtp_auth_password = "$SMTP_PASSWORD";
89 };
90 route = {
91 receiver = "default";
92 routes = [
93 {
94 group_by = [ "host" ];
95 group_wait = "30s";
96 group_interval = "2m";
97 repeat_interval = "2h";
98 receiver = "all";
99 }
100 ];
101 };
102 receivers = [
103 {
104 name = "all";
105 webhook_configs = [
106 {
107 url = "http://127.0.0.1:9223/";
108 max_alerts = 5;
109 }
110 ];
111 }
112 {
113 name = "default";
114 }
115 ];
116 };
117 };
118 };
119
120}