kube-prometheus: remove duplication in grafana dashboards

Datasource links were duplicated in the grafana dashboads. This now also
allows exporting grafana dashboards from the UI and just dropping them
into the assets directory and they will be wrapped by the manifest
generation script.
This commit is contained in:
Frederic Branczyk
2017-03-13 12:08:30 +01:00
parent 9ed63f191f
commit d9086e9875
8 changed files with 6689 additions and 6714 deletions

View File

@@ -1,39 +1,37 @@
{
"dashboard":
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "prometheus",
"description": "",
"type": "datasource",
"label": "prometheus",
"name": "DS_PROMETHEUS",
"pluginId": "prometheus",
"pluginName": "Prometheus"
"pluginName": "Prometheus",
"type": "datasource"
}
],
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"type": "grafana",
"version": "4.1.1"
},
{
"type": "panel",
"id": "graph",
"name": "Graph",
"type": "panel",
"version": ""
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"type": "datasource",
"version": "1.0.0"
},
{
"type": "panel",
"id": "singlestat",
"name": "Singlestat",
"type": "panel",
"version": ""
}
],
@@ -847,14 +845,4 @@
"timezone": "browser",
"title": "All Nodes",
"version": 1
},
"inputs": [
{
"name": "DS_PROMETHEUS",
"pluginId": "prometheus",
"type": "datasource",
"value": "prometheus"
}
],
"overwrite": true
}

View File

@@ -1,49 +1,48 @@
{
"dashboard": {
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "prometheus",
"description": "",
"type": "datasource",
"label": "prometheus",
"name": "DS_PROMETHEUS",
"pluginId": "prometheus",
"pluginName": "Prometheus"
"pluginName": "Prometheus",
"type": "datasource"
}
],
"__requires": [
{
"type": "panel",
"id": "singlestat",
"name": "Singlestat",
"type": "panel",
"version": ""
},
{
"type": "panel",
"id": "graph",
"name": "Graph",
"type": "panel",
"version": ""
},
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"type": "grafana",
"version": "3.1.1"
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"type": "datasource",
"version": "1.0.0"
}
],
"id": null,
"title": "Deployment",
"tags": [],
"style": "dark",
"timezone": "browser",
"annotations": {
"list": []
},
"editable": true,
"gnetId": null,
"hideControls": false,
"sharedCrosshair": true,
"id": null,
"links": [],
"rows": [
{
"collapse": false,
@@ -51,37 +50,107 @@
"height": "200px",
"panels": [
{
"title": "CPU",
"error": false,
"span": 4,
"cacheTimeout": null,
"colorBackground": false,
"colorValue": false,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"datasource": "${DS_PROMETHEUS}",
"editable": true,
"type": "singlestat",
"isNew": true,
"error": false,
"format": "none",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": true
},
"id": 8,
"interval": null,
"isNew": true,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "cores",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"span": 4,
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": true
},
"targets": [
{
"refId": "A",
"expr": "sum(rate(container_cpu_usage_seconds_total{namespace=\"$deployment_namespace\",pod_name=~\"$deployment_name.*\"}[3m])) ",
"intervalFactor": 2,
"refId": "A",
"step": 600
}
],
"links": [],
"datasource": "${DS_PROMETHEUS}",
"maxDataPoints": 100,
"interval": null,
"cacheTimeout": null,
"format": "none",
"prefix": "",
"postfix": "cores",
"nullText": null,
"thresholds": "",
"title": "CPU",
"type": "singlestat",
"valueFontSize": "110%",
"valueMaps": [
{
"value": "null",
"op": "=",
"text": "N/A"
"text": "N/A",
"value": "null"
}
],
"valueName": "avg"
},
{
"cacheTimeout": null,
"colorBackground": false,
"colorValue": false,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"datasource": "${DS_PROMETHEUS}",
"editable": true,
"error": false,
"format": "none",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": true
},
"id": 9,
"interval": null,
"isNew": true,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
@@ -92,73 +161,73 @@
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "GB",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "80%",
"rangeMaps": [
{
"from": "null",
"to": "null",
"text": "N/A"
"text": "N/A",
"to": "null"
}
],
"mappingType": 1,
"nullPointMode": "connected",
"valueName": "avg",
"prefixFontSize": "50%",
"valueFontSize": "110%",
"postfixFontSize": "50%",
"thresholds": "",
"colorBackground": false,
"colorValue": false,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"span": 4,
"sparkline": {
"show": true,
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"fillColor": "rgba(31, 118, 189, 0.18)"
"show": true
},
"gauge": {
"show": false,
"minValue": 0,
"maxValue": 100,
"thresholdMarkers": true,
"thresholdLabels": false
}
},
{
"title": "Memory",
"error": false,
"span": 4,
"editable": true,
"type": "singlestat",
"isNew": true,
"id": 9,
"targets": [
{
"refId": "A",
"expr": "sum(container_memory_usage_bytes{namespace=\"$deployment_namespace\",pod_name=~\"$deployment_name.*\"}) / 1024^3",
"intervalFactor": 2,
"refId": "A",
"step": 600
}
],
"links": [],
"datasource": "${DS_PROMETHEUS}",
"maxDataPoints": 100,
"interval": null,
"cacheTimeout": null,
"format": "none",
"prefix": "",
"postfix": "GB",
"nullText": null,
"thresholds": "",
"title": "Memory",
"type": "singlestat",
"valueFontSize": "110%",
"valueMaps": [
{
"value": "null",
"op": "=",
"text": "N/A"
"text": "N/A",
"value": "null"
}
],
"valueName": "avg"
},
{
"cacheTimeout": null,
"colorBackground": false,
"colorValue": false,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"datasource": "${DS_PROMETHEUS}",
"editable": true,
"error": false,
"format": "Bps",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": false
},
"id": 7,
"interval": null,
"isNew": true,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
@@ -169,161 +238,83 @@
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"to": "null",
"text": "N/A"
"text": "N/A",
"to": "null"
}
],
"mappingType": 1,
"nullPointMode": "connected",
"valueName": "avg",
"prefixFontSize": "80%",
"valueFontSize": "110%",
"postfixFontSize": "50%",
"thresholds": "",
"colorBackground": false,
"colorValue": false,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"span": 4,
"sparkline": {
"show": true,
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"fillColor": "rgba(31, 118, 189, 0.18)"
"show": true
},
"gauge": {
"show": false,
"minValue": 0,
"maxValue": 100,
"thresholdMarkers": true,
"thresholdLabels": false
}
},
{
"title": "Network",
"error": false,
"span": 4,
"editable": true,
"type": "singlestat",
"isNew": true,
"id": 7,
"targets": [
{
"refId": "A",
"expr": "sum(rate(container_network_transmit_bytes_total{namespace=\"$deployment_namespace\",pod_name=~\"$deployment_name.*\"}[3m])) + sum(rate(container_network_receive_bytes_total{namespace=\"$deployment_namespace\",pod_name=~\"$deployment_name.*\"}[3m])) ",
"intervalFactor": 2,
"refId": "A",
"step": 600
}
],
"links": [],
"datasource": "${DS_PROMETHEUS}",
"maxDataPoints": 100,
"interval": null,
"cacheTimeout": null,
"format": "Bps",
"prefix": "",
"postfix": "",
"nullText": null,
"thresholds": "",
"title": "Network",
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"value": "null",
"op": "=",
"text": "N/A"
"text": "N/A",
"value": "null"
}
],
"mappingTypes": [
{
"name": "value to text",
"value": 1
"valueName": "avg"
}
],
"showTitle": false,
"title": "Row"
},
{
"name": "range to text",
"value": 2
}
],
"rangeMaps": [
{
"from": "null",
"to": "null",
"text": "N/A"
}
],
"mappingType": 1,
"nullPointMode": "connected",
"valueName": "avg",
"prefixFontSize": "50%",
"valueFontSize": "80%",
"postfixFontSize": "50%",
"thresholds": "",
"colorBackground": false,
"colorValue": false,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"sparkline": {
"show": true,
"full": false,
"lineColor": "rgb(31, 120, 193)",
"fillColor": "rgba(31, 118, 189, 0.18)"
},
"gauge": {
"show": false,
"minValue": 0,
"maxValue": 100,
"thresholdMarkers": false,
"thresholdLabels": false
}
}
],
"title": "Row",
"showTitle": false
},
{
"title": "New row",
"height": "100px",
"editable": true,
"collapse": false,
"editable": true,
"height": "100px",
"panels": [
{
"title": "Desired Replicas",
"error": false,
"span": 3,
"editable": true,
"type": "singlestat",
"isNew": true,
"id": 5,
"targets": [
{
"refId": "A",
"expr": "max(kube_deployment_spec_replicas{deployment=\"$deployment_name\",namespace=\"$deployment_namespace\"}) without (instance)",
"intervalFactor": 2,
"step": 600,
"metric": "kube_deployment_spec_replicas"
}
],
"links": [],
"datasource": "${DS_PROMETHEUS}",
"maxDataPoints": 100,
"interval": null,
"cacheTimeout": null,
"format": "none",
"prefix": "",
"postfix": "",
"nullText": null,
"valueMaps": [
{
"value": "null",
"op": "=",
"text": "N/A"
}
"colorBackground": false,
"colorValue": false,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"datasource": "${DS_PROMETHEUS}",
"decimals": null,
"editable": true,
"error": false,
"format": "none",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": false
},
"id": 5,
"interval": null,
"isNew": true,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
@@ -334,74 +325,74 @@
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"to": "null",
"text": "N/A"
"text": "N/A",
"to": "null"
}
],
"mappingType": 1,
"nullPointMode": "connected",
"valueName": "avg",
"prefixFontSize": "50%",
"valueFontSize": "80%",
"postfixFontSize": "50%",
"thresholds": "",
"colorBackground": false,
"colorValue": false,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"span": 3,
"sparkline": {
"show": false,
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"fillColor": "rgba(31, 118, 189, 0.18)"
"show": false
},
"gauge": {
"show": false,
"minValue": 0,
"maxValue": 100,
"thresholdMarkers": false,
"thresholdLabels": false
},
"decimals": null
},
{
"title": "Available Replicas",
"error": false,
"span": 3,
"editable": true,
"type": "singlestat",
"isNew": true,
"id": 6,
"targets": [
{
"refId": "A",
"expr": "min(kube_deployment_status_replicas_available{deployment=\"$deployment_name\",namespace=\"$deployment_namespace\"}) without (instance)",
"expr": "max(kube_deployment_spec_replicas{deployment=\"$deployment_name\",namespace=\"$deployment_namespace\"}) without (instance)",
"intervalFactor": 2,
"metric": "kube_deployment_spec_replicas",
"refId": "A",
"step": 600
}
],
"links": [],
"datasource": "${DS_PROMETHEUS}",
"maxDataPoints": 100,
"interval": null,
"cacheTimeout": null,
"format": "none",
"prefix": "",
"postfix": "",
"nullText": null,
"thresholds": "",
"title": "Desired Replicas",
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"value": "null",
"op": "=",
"text": "N/A"
"text": "N/A",
"value": "null"
}
],
"valueName": "avg"
},
{
"cacheTimeout": null,
"colorBackground": false,
"colorValue": false,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"datasource": "${DS_PROMETHEUS}",
"editable": true,
"error": false,
"format": "none",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": true
},
"id": 6,
"interval": null,
"isNew": true,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
@@ -412,40 +403,47 @@
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"to": "null",
"text": "N/A"
"text": "N/A",
"to": "null"
}
],
"mappingType": 1,
"nullPointMode": "connected",
"valueName": "avg",
"prefixFontSize": "50%",
"valueFontSize": "80%",
"postfixFontSize": "50%",
"thresholds": "",
"colorBackground": false,
"colorValue": false,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"span": 3,
"sparkline": {
"show": false,
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"fillColor": "rgba(31, 118, 189, 0.18)"
"show": false
},
"gauge": {
"show": false,
"minValue": 0,
"maxValue": 100,
"thresholdMarkers": true,
"thresholdLabels": false
"targets": [
{
"expr": "min(kube_deployment_status_replicas_available{deployment=\"$deployment_name\",namespace=\"$deployment_namespace\"}) without (instance)",
"intervalFactor": 2,
"refId": "A",
"step": 600
}
],
"thresholds": "",
"title": "Available Replicas",
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "null"
}
],
"valueName": "avg"
},
{
"cacheTimeout": null,
@@ -603,7 +601,8 @@
],
"valueName": "avg"
}
]
],
"title": "New row"
},
{
"collapse": false,
@@ -628,12 +627,12 @@
"legend": {
"avg": false,
"current": false,
"hideZero": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false,
"hideZero": false
"values": false
},
"lines": true,
"linewidth": 2,
@@ -694,6 +693,7 @@
"sort": 0,
"value_type": "cumulative"
},
"transparent": false,
"type": "graph",
"xaxis": {
"mode": "time",
@@ -718,43 +718,17 @@
"min": null,
"show": false
}
],
"transparent": false
}
],
"title": "New row",
"showTitle": false
}
],
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
}
],
"showTitle": false,
"title": "New row"
}
],
"schemaVersion": 12,
"sharedCrosshair": true,
"style": "dark",
"tags": [],
"templating": {
"list": [
{
@@ -797,21 +771,36 @@
}
]
},
"annotations": {
"list": []
"time": {
"from": "now-6h",
"to": "now"
},
"schemaVersion": 12,
"version": 2,
"links": [],
"gnetId": null
},
"inputs": [
{
"name": "DS_PROMETHEUS",
"pluginId": "prometheus",
"type": "datasource",
"value": "prometheus"
}
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"overwrite": true
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "browser",
"title": "Deployment",
"version": 2
}

View File

@@ -1,5 +1,4 @@
{
"dashboard": {
"__inputs": [
{
"description": "",
@@ -396,14 +395,4 @@
"timezone": "browser",
"title": "Pods",
"version": 26
},
"inputs": [
{
"name": "DS_PROMETHEUS",
"pluginId": "prometheus",
"type": "datasource",
"value": "prometheus"
}
],
"overwrite": true
}

View File

@@ -1,39 +1,37 @@
{
"dashboard":
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "prometheus",
"description": "",
"type": "datasource",
"label": "prometheus",
"name": "DS_PROMETHEUS",
"pluginId": "prometheus",
"pluginName": "Prometheus"
"pluginName": "Prometheus",
"type": "datasource"
}
],
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"type": "grafana",
"version": "4.1.1"
},
{
"type": "panel",
"id": "graph",
"name": "Graph",
"type": "panel",
"version": ""
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"type": "datasource",
"version": "1.0.0"
},
{
"type": "panel",
"id": "singlestat",
"name": "Singlestat",
"type": "panel",
"version": ""
}
],
@@ -867,14 +865,4 @@
"timezone": "browser",
"title": "Nodes",
"version": 1
},
"inputs": [
{
"name": "DS_PROMETHEUS",
"pluginId": "prometheus",
"type": "datasource",
"value": "prometheus"
}
],
"overwrite": true
}

View File

@@ -1,37 +1,37 @@
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "prometheus",
"description": "",
"type": "datasource",
"label": "prometheus",
"name": "DS_PROMETHEUS",
"pluginId": "prometheus",
"pluginName": "Prometheus"
"pluginName": "Prometheus",
"type": "datasource"
}
],
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"type": "grafana",
"version": "4.1.1"
},
{
"type": "panel",
"id": "graph",
"name": "Graph",
"type": "panel",
"version": ""
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"type": "datasource",
"version": "1.0.0"
},
{
"type": "panel",
"id": "singlestat",
"name": "Singlestat",
"type": "panel",
"version": ""
}
],

View File

@@ -8,7 +8,13 @@ metadata:
data:
EOF
for f in assets/grafana/*
for f in assets/grafana/*-dashboard.json
do
echo " $(basename $f): |+"
hack/scripts/wrap-dashboard.sh $f | sed "s/^/ /g"
done
for f in assets/grafana/*-datasource.json
do
echo " $(basename $f): |+"
cat $f | sed "s/^/ /g"

View File

@@ -8,12 +8,10 @@
# has error.
# * Download dashboard specification as JSON file in Grafana:
# Share -> Export -> Save to file.
# * Wrap dashboard specification to make it digestable by kube-prometheus:
# ./hack/scripts/wrap-dashboard.sh Nodes-1488465802729.json
# * Replace dashboard specification:
# * Drop dashboard specification in assets folder:
# mv Nodes-1488465802729.json assets/grafana/node-dashboard.json
# * Regenerate Grafana configmap:
# ./hack/scripts/generate-configmaps.sh
# ./hack/scripts/generate-manifests.sh
# * Apply new configmap:
# kubectl -n monitoring apply -f manifests/grafana/grafana-cm.yaml
@@ -22,17 +20,16 @@ if [ "$#" -ne 1 ]; then
exit 1
fi
json=$1
temp=$(tempfile -m 0644)
dashboardjson=$1
cat >> $temp <<EOF
cat <<EOF
{
"dashboard":
EOF
cat $json >> $temp
cat $dashboardjson
cat >> $temp <<EOF
cat <<EOF
,
"inputs": [
{
@@ -46,5 +43,3 @@ cat >> $temp <<EOF
}
EOF
mv $temp $json

File diff suppressed because it is too large Load Diff