Comments (5)
The crux of the issue is that Prometheus only stores "non-null" samples. So if the exporter or textfile collector doesn't expose a value (even a zero value) for a particular label set, then nothing gets stored by Prometheus.
You could add multiple queries to your dashboard, with explicit origin
label matchers, combining that with or vector(0)
, and explicitly specify the legend label in Grafana. However this approach is essentially incompatible with the regex origin=~".*Security.*"
matcher, where the exact origin
labels are not known in advance.
from node-exporter-textfile-collector-scripts.
Ok, thanks for the explanation. I was looking at the PromQL functions and hadn't find anything relevant indeed :-(
Ideally I'm hoping to make the dashboards and alerts only rely on labels and variables, avoiding anything too specific so that it can be shared and replicate easily.
So far I've defined my grafana dashboard like this (if it can help anyone, and any suggestion welcome!) :
grafana dashboard JSON for apt_info (Click me)
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
],
"__elements": {},
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "9.3.1"
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"version": "1.0.0"
},
{
"type": "panel",
"id": "stat",
"name": "Stat",
"version": ""
},
{
"type": "panel",
"id": "timeseries",
"name": "Time series",
"version": ""
}
],
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": null,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"fieldConfig": {
"defaults": {
"mappings": [
{
"options": {
"0": {
"color": "dark-green",
"index": 0,
"text": "ok"
},
"1": {
"color": "dark-orange",
"index": 1,
"text": "reboot"
}
},
"type": "value"
}
],
"noValue": "N/A",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 1
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 24,
"x": 0,
"y": 0
},
"id": 8,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"text": {
"titleSize": 15
},
"textMode": "value_and_name"
},
"pluginVersion": "9.3.1",
"targets": [
{
"$$hashKey": "object:24",
"aggregation": "Last",
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"decimals": 2,
"displayAliasType": "Warning / Critical",
"displayType": "Regular",
"displayValueWithAlias": "Never",
"editorMode": "code",
"exemplar": false,
"expr": "node_reboot_required",
"format": "time_series",
"instant": true,
"legendFormat": "{{instance}}",
"range": false,
"refId": "A",
"units": "none",
"valueHandler": "Number Threshold"
}
],
"title": "Reboot required ?",
"transformations": [
{
"id": "renameByRegex",
"options": {
"regex": "nodeexporter.(.*):80",
"renamePattern": "$1"
}
}
],
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 9,
"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": "#EAB839",
"value": 5
},
{
"color": "red",
"value": 20
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 24,
"x": 0,
"y": 4
},
"id": 6,
"options": {
"legend": {
"calcs": [
"last"
],
"displayMode": "table",
"placement": "bottom",
"showLegend": true,
"sortBy": "Last",
"sortDesc": true
},
"tooltip": {
"mode": "multi",
"sort": "asc"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "builder",
"expr": "sum by(instance) (apt_upgrades_pending)",
"legendFormat": "{{instance}}",
"range": true,
"refId": "A"
}
],
"title": "apt_upgrades_pending",
"transformations": [
{
"id": "renameByRegex",
"options": {
"regex": "nodeexporter.(.*):80",
"renamePattern": "$1"
}
}
],
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"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": 5
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 24,
"x": 0,
"y": 13
},
"id": 9,
"options": {
"legend": {
"calcs": [
"last"
],
"displayMode": "table",
"placement": "bottom",
"showLegend": true,
"sortBy": "Last",
"sortDesc": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "code",
"expr": "sum by(instance) (apt_upgrades_pending{origin=~\".*security.*\"}) or vector(0)",
"legendFormat": "__auto",
"range": true,
"refId": "A"
}
],
"title": "security apt_upgrades_pending",
"transformations": [
{
"id": "renameByRegex",
"options": {
"regex": "nodeexporter.(.*):80",
"renamePattern": "$1"
}
}
],
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"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": 24,
"x": 0,
"y": 22
},
"id": 4,
"options": {
"legend": {
"calcs": [
"last"
],
"displayMode": "table",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "builder",
"expr": "sum by(instance) (apt_upgrades_held)",
"legendFormat": "{{instance}}",
"range": true,
"refId": "A"
}
],
"title": "apt_upgrades_held",
"transformations": [
{
"id": "renameByRegex",
"options": {
"regex": "nodeexporter.(.*):80",
"renamePattern": "$1"
}
}
],
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"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": 10,
"w": 24,
"x": 0,
"y": 30
},
"id": 2,
"options": {
"legend": {
"calcs": [
"last"
],
"displayMode": "table",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "builder",
"expr": "sum by(instance) (apt_autoremove_pending)",
"legendFormat": "{{instance}}",
"range": true,
"refId": "A"
}
],
"title": "apt_autoremove_pending",
"transformations": [
{
"id": "renameByRegex",
"options": {
"regex": "nodeexporter.(.*):80",
"renamePattern": "$1"
}
}
],
"type": "timeseries"
}
],
"schemaVersion": 37,
"style": "dark",
"tags": [],
"templating": {
"list": [
{
"current": {},
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"definition": "label_values(node_reboot_required, instance)",
"hide": 0,
"includeAll": true,
"multi": true,
"name": "instance",
"options": [],
"query": {
"query": "label_values(node_reboot_required, instance)",
"refId": "StandardVariableQuery"
},
"refresh": 1,
"regex": "/nodeexporter.(.*):80/",
"skipUrlSync": false,
"sort": 0,
"type": "query"
}
]
},
"time": {
"from": "now-5m",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "APT-ugrades",
"uid": "gTSdTxtVk",
"version": 21,
"weekStart": ""
}
Edit : I shared my current dashboard here, but I'm not sure where would be the best place to do so to have it linked to the apt_info.py
script
from node-exporter-textfile-collector-scripts.
Grafana has a community site for sharing dashboards at https://grafana.com/grafana/dashboards/
from node-exporter-textfile-collector-scripts.
@dswarbrick you need a paid subscription to be able to publish there
from node-exporter-textfile-collector-scripts.
@copolycube Yes, you need a Grafana account - but AFAIK, the "free forever cloud" account type should be sufficient.
from node-exporter-textfile-collector-scripts.
Related Issues (20)
- nvme_metrics.sh invalidly quotes numbers. HOT 2
- nvme_metrics.sh does not write in given file HOT 2
- nvme_metrics.sh does not work at crontab HOT 2
- smartmon scripts: quote in value HOT 20
- smartmon collector missing node info HOT 2
- monitor LVM cache usage
- Issue with smartmon.sh and type cciss
- freeipmi collector? HOT 2
- Is it possible to run apt_info.py inside a container? HOT 1
- apt_info.py can hang for hours HOT 1
- apt info should report cache age HOT 4
- apt cache age computed incorrectly
- storcli: "BBU Status" field not available in HPE MegaRID controller
- apt_info.py - pending_upgrades always empty
- apt_info.py - wrong cache timestamps
- storcli could not extract drive temperature HOT 1
- mellanox_hca_temp: suppress errors when virtual functions present HOT 2
- Add HP RAID Smart Array support for smartmon.sh
- Cant open smartmon.prom HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-exporter-textfile-collector-scripts.