Add more exporters (#16)

This commit is contained in:
Patrick Stevens
2023-07-22 21:16:52 +01:00
committed by GitHub
parent 63eaf5b072
commit e5254f4e1c
5 changed files with 258 additions and 36 deletions

View File

@@ -18,7 +18,6 @@
"editable": true, "editable": true,
"fiscalYearStartMonth": 0, "fiscalYearStartMonth": 0,
"graphTooltip": 0, "graphTooltip": 0,
"id": 1,
"links": [], "links": [],
"liveNow": false, "liveNow": false,
"panels": [ "panels": [
@@ -27,7 +26,6 @@
"type": "prometheus", "type": "prometheus",
"uid": "P40645DF18AF953B4" "uid": "P40645DF18AF953B4"
}, },
"description": "",
"fieldConfig": { "fieldConfig": {
"defaults": { "defaults": {
"color": { "color": {
@@ -76,7 +74,8 @@
"value": 80 "value": 80
} }
] ]
} },
"unit": "d"
}, },
"overrides": [] "overrides": []
}, },
@@ -86,7 +85,7 @@
"x": 0, "x": 0,
"y": 0 "y": 0
}, },
"id": 5, "id": 10,
"options": { "options": {
"legend": { "legend": {
"calcs": [], "calcs": [],
@@ -106,15 +105,13 @@
"uid": "P40645DF18AF953B4" "uid": "P40645DF18AF953B4"
}, },
"editorMode": "builder", "editorMode": "builder",
"exemplar": false, "expr": "domain_expiry_days",
"expr": "rate(node_cpu_seconds_total{mode!=\"idle\"}[5m])", "legendFormat": "{{domain}}",
"hide": false,
"legendFormat": "{{mode}}",
"range": true, "range": true,
"refId": "A" "refId": "A"
} }
], ],
"title": "CPU usage", "title": "Domain expiry time",
"type": "timeseries" "type": "timeseries"
}, },
{ {
@@ -263,8 +260,6 @@
} }
}, },
"mappings": [], "mappings": [],
"max": 1,
"min": 0,
"thresholds": { "thresholds": {
"mode": "absolute", "mode": "absolute",
"steps": [ "steps": [
@@ -278,7 +273,7 @@
} }
] ]
}, },
"unit": "percentunit" "unit": "none"
}, },
"overrides": [] "overrides": []
}, },
@@ -288,7 +283,7 @@
"x": 0, "x": 0,
"y": 8 "y": 8
}, },
"id": 7, "id": 9,
"options": { "options": {
"legend": { "legend": {
"calcs": [], "calcs": [],
@@ -308,26 +303,13 @@
"uid": "P40645DF18AF953B4" "uid": "P40645DF18AF953B4"
}, },
"editorMode": "builder", "editorMode": "builder",
"expr": "node_filesystem_free_bytes / node_filesystem_size_bytes{job=\"node\"}", "expr": "rate(nginx_http_requests_total[5m])",
"hide": false, "legendFormat": "{{instance}}",
"legendFormat": "{{mountpoint}} ({{device}})",
"range": true, "range": true,
"refId": "A" "refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "P40645DF18AF953B4"
},
"editorMode": "builder",
"expr": "node_filesystem_size_bytes{job=\"node\"}",
"hide": true,
"legendFormat": "{{mountpoint}} ({{device}})",
"range": true,
"refId": "B"
} }
], ],
"title": "Free disk", "title": "Nginx HTTP requests/5min",
"type": "timeseries" "type": "timeseries"
}, },
{ {
@@ -422,6 +404,209 @@
"title": "Disk I/O", "title": "Disk I/O",
"type": "timeseries" "type": "timeseries"
}, },
{
"datasource": {
"type": "prometheus",
"uid": "P40645DF18AF953B4"
},
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 16
},
"id": 5,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "P40645DF18AF953B4"
},
"editorMode": "builder",
"exemplar": false,
"expr": "rate(node_cpu_seconds_total{mode!=\"idle\"}[5m])",
"hide": false,
"legendFormat": "{{mode}}",
"range": true,
"refId": "A"
}
],
"title": "CPU usage",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "P40645DF18AF953B4"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"max": 1,
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "percentunit"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 16
},
"id": 7,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "P40645DF18AF953B4"
},
"editorMode": "builder",
"expr": "node_filesystem_free_bytes / node_filesystem_size_bytes{job=\"node\"}",
"hide": false,
"legendFormat": "{{mountpoint}} ({{device}})",
"range": true,
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "P40645DF18AF953B4"
},
"editorMode": "builder",
"expr": "node_filesystem_size_bytes{job=\"node\"}",
"hide": true,
"legendFormat": "{{mountpoint}} ({{device}})",
"range": true,
"refId": "B"
}
],
"title": "Free disk",
"type": "timeseries"
},
{ {
"datasource": { "datasource": {
"type": "datasource", "type": "datasource",
@@ -431,7 +616,7 @@
"h": 3, "h": 3,
"w": 24, "w": 24,
"x": 0, "x": 0,
"y": 16 "y": 24
}, },
"id": 1, "id": 1,
"targets": [ "targets": [
@@ -454,7 +639,7 @@
"h": 15, "h": 15,
"w": 12, "w": 12,
"x": 0, "x": 0,
"y": 19 "y": 27
}, },
"id": 3, "id": 3,
"links": [], "links": [],
@@ -491,7 +676,7 @@
"h": 15, "h": 15,
"w": 12, "w": 12,
"x": 12, "x": 12,
"y": 19 "y": 27
}, },
"id": 4, "id": 4,
"links": [], "links": [],
@@ -512,7 +697,7 @@
"type": "news" "type": "news"
} }
], ],
"refresh": "", "refresh": false,
"schemaVersion": 38, "schemaVersion": 38,
"style": "dark", "style": "dark",
"tags": [], "tags": [],
@@ -520,8 +705,8 @@
"list": [] "list": []
}, },
"time": { "time": {
"from": "now-12h", "from": "2023-07-22T01:55:10.667Z",
"to": "now" "to": "2023-07-23T01:55:10.667Z"
}, },
"timepicker": { "timepicker": {
"hidden": true, "hidden": true,
@@ -553,6 +738,6 @@
"timezone": "browser", "timezone": "browser",
"title": "Node", "title": "Node",
"uid": "d872af8a-0e64-4b22-8d97-7db77958960b", "uid": "d872af8a-0e64-4b22-8d97-7db77958960b",
"version": 3, "version": 1,
"weekStart": "" "weekStart": ""
} }

View File

@@ -55,6 +55,9 @@
recommendedGzipSettings = true; recommendedGzipSettings = true;
recommendedProxySettings = true; recommendedProxySettings = true;
# For Prometheus exporter
statusPage = true;
virtualHosts."${config.services.nginx-config.domain}" = { virtualHosts."${config.services.nginx-config.domain}" = {
globalRedirect = "${config.services.nginx-config.webrootSubdomain}.${config.services.nginx-config.domain}"; globalRedirect = "${config.services.nginx-config.webrootSubdomain}.${config.services.nginx-config.domain}";
addSSL = true; addSSL = true;

View File

@@ -0,0 +1,3 @@
{
"domains": ["%%DOMAINS%%"]
}

View File

@@ -20,6 +20,11 @@
}; };
config = { config = {
# For the domain exporter
environment.etc."domain-exporter/domains.yaml" = {
source = builtins.replaceStrings ["%%DOMAINS%%"] ["patrickstevens.co.uk"] ./domains.yaml;
};
services.prometheus = { services.prometheus = {
enable = true; enable = true;
port = config.services.prometheus-config.port; port = config.services.prometheus-config.port;
@@ -29,6 +34,13 @@
enabledCollectors = ["systemd"]; enabledCollectors = ["systemd"];
port = config.services.prometheus-config.node-exporter-port; port = config.services.prometheus-config.node-exporter-port;
}; };
nginx = {
enable = true;
};
domain = {
enable = true;
extraFlags = ["--config=/etc/domain-exporter/domains.yaml"];
};
}; };
scrapeConfigs = [ scrapeConfigs = [
@@ -40,6 +52,24 @@
} }
]; ];
} }
{
job_name = "nginx";
static_configs = [
{
# Non-configurable magic port used for nginx status
targets = ["localhost:9113"];
}
];
}
{
job_name = "domain";
static_configs = [
{
# Non-configurable magic port used for domain exporter
targets = ["localhost:9222"];
}
];
}
]; ];
}; };
}; };

View File

@@ -49,6 +49,7 @@
<Content Include="Nix\grafana\grafana.nix" /> <Content Include="Nix\grafana\grafana.nix" />
<Content Include="Nix\grafana\node.json" /> <Content Include="Nix\grafana\node.json" />
<Content Include="Nix\prometheus\prometheus.nix" /> <Content Include="Nix\prometheus\prometheus.nix" />
<Content Include="Nix\prometheus\domains.yaml" />
<Content Include="Nix\miniflux\miniflux.nix" /> <Content Include="Nix\miniflux\miniflux.nix" />
<None Include="Nix\nginx\nginx-config.nix" /> <None Include="Nix\nginx\nginx-config.nix" />
<Content Include="config.schema.json" /> <Content Include="config.schema.json" />