Skip to content

Instantly share code, notes, and snippets.

@michal-kazmierczak
Last active October 13, 2024 11:02
Show Gist options
  • Save michal-kazmierczak/1538bd8df46e4a1fbf9c859bfa045126 to your computer and use it in GitHub Desktop.
Save michal-kazmierczak/1538bd8df46e4a1fbf9c859bfa045126 to your computer and use it in GitHub Desktop.
Prometheus Metrics Management
{
"__inputs": [
{
"name": "default",
"label": "default",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
],
"__elements": {},
"__requires": [
{
"type": "panel",
"id": "barchart",
"name": "Bar chart",
"version": ""
},
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "11.2.2"
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"version": "1.0.0"
},
{
"type": "panel",
"id": "stat",
"name": "Stat",
"version": ""
},
{
"type": "panel",
"id": "table",
"name": "Table",
"version": ""
}
],
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"description": "Inspect the cardinality of your metrics ",
"editable": true,
"fiscalYearStartMonth": 0,
"gnetId": 19341,
"graphTooltip": 0,
"id": null,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic-by-name"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 8,
"x": 0,
"y": 0
},
"id": 6,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"percentChangeColorMode": "standard",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showPercentChange": false,
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "11.2.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${default}"
},
"editorMode": "code",
"exemplar": false,
"expr": "count(count({__name__!=\"\"}) by (job))",
"format": "table",
"instant": true,
"range": false,
"refId": "A"
}
],
"title": "Total jobs (scrape targets)",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic-by-name"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 8,
"x": 8,
"y": 0
},
"id": 2,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"percentChangeColorMode": "standard",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showPercentChange": false,
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "11.2.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${default}"
},
"editorMode": "code",
"exemplar": false,
"expr": "count(count({__name__!=\"\"}) by (__name__))",
"format": "table",
"instant": true,
"range": false,
"refId": "A"
}
],
"title": "Total metrics",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"fixedColor": "super-light-green",
"mode": "palette-classic-by-name"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 8,
"x": 16,
"y": 0
},
"id": 4,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"percentChangeColorMode": "standard",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showPercentChange": false,
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "11.2.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${default}"
},
"editorMode": "code",
"exemplar": false,
"expr": "count({__name__!=\"\"})",
"format": "table",
"instant": true,
"range": false,
"refId": "A"
}
],
"title": "Total series",
"type": "stat"
},
{
"datasource": {
"default": false,
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"fillOpacity": 80,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineWidth": 1,
"scaleDistribution": {
"type": "linear"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [
{
"options": {
"mongodb": {
"index": 1,
"text": "mariadb"
},
"third-party-api": {
"index": 0,
"text": "customer-facing-api"
}
},
"type": "value"
}
],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "job"
},
"properties": []
}
]
},
"gridPos": {
"h": 9,
"w": 8,
"x": 0,
"y": 4
},
"id": 5,
"options": {
"barRadius": 0,
"barWidth": 0.97,
"fullHighlight": false,
"groupWidth": 0.7,
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": false
},
"orientation": "vertical",
"showValue": "always",
"stacking": "none",
"tooltip": {
"mode": "single",
"sort": "none"
},
"xTickLabelMaxLength": 10,
"xTickLabelRotation": -45,
"xTickLabelSpacing": 0
},
"pluginVersion": "11.2.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${default}"
},
"editorMode": "code",
"exemplar": false,
"expr": "topk(10, count({__name__!=\"\"}) by (job))",
"format": "table",
"instant": true,
"range": false,
"refId": "A"
}
],
"title": "Series by job (top 10)",
"transformations": [
{
"id": "renameByRegex",
"options": {
"regex": "third-party-api",
"renamePattern": "abc"
}
}
],
"type": "barchart"
},
{
"datasource": {
"default": false,
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"fillOpacity": 80,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineWidth": 1,
"scaleDistribution": {
"type": "linear"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [
{
"options": {
"operator_latency_seconds": {
"index": 3,
"text": "customer_latency_seconds"
},
"round_latency_seconds_bucket": {
"index": 0,
"text": "rack_server_"
},
"round_latency_seconds_count": {
"index": 1,
"text": "customer_latency_seconds_count"
},
"round_latency_seconds_sum": {
"index": 2,
"text": "customer_latency_seconds_sum"
}
},
"type": "value"
}
],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Metric"
},
"properties": [
{
"id": "links",
"value": [
{
"title": "",
"url": "/d/b0b89a23-8f37-4bfe-962a-f329a654e987/metrics-management?var-metric=${__data.fields[\"Metric\"]}&${datasource:queryparam}&${job:queryparam}"
}
]
}
]
},
{
"matcher": {
"id": "byName",
"options": "Series count"
},
"properties": []
},
{
"matcher": {
"id": "byName",
"options": "% of total"
},
"properties": []
}
]
},
"gridPos": {
"h": 9,
"w": 8,
"x": 8,
"y": 4
},
"id": 8,
"options": {
"barRadius": 0,
"barWidth": 0.97,
"fullHighlight": false,
"groupWidth": 0.7,
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": false
},
"orientation": "vertical",
"showValue": "auto",
"stacking": "none",
"tooltip": {
"mode": "single",
"sort": "none"
},
"xField": "__name__",
"xTickLabelMaxLength": 10,
"xTickLabelRotation": -45,
"xTickLabelSpacing": 0
},
"pluginVersion": "11.2.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${default}"
},
"editorMode": "code",
"exemplar": false,
"expr": "topk(10, count({__name__!=\"\",job=~\"$job\"}) by (__name__))",
"format": "table",
"instant": true,
"range": false,
"refId": "A"
}
],
"title": "Series by metric (top 10)",
"type": "barchart"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": "auto",
"cellOptions": {
"type": "auto"
},
"inspect": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Distinct Count"
},
"properties": [
{
"id": "color",
"value": {
"mode": "continuous-GrYlRd"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "Distinct Count"
},
"properties": [
{
"id": "custom.cellOptions",
"value": {
"mode": "basic",
"type": "gauge",
"valueDisplayMode": "text"
}
},
{
"id": "custom.align",
"value": "left"
}
]
},
{
"matcher": {
"id": "byName",
"options": "A sample observed value"
},
"properties": [
{
"id": "custom.align",
"value": "center"
}
]
}
]
},
"gridPos": {
"h": 21,
"w": 8,
"x": 16,
"y": 4
},
"id": 3,
"options": {
"cellHeight": "sm",
"footer": {
"countRows": false,
"enablePagination": false,
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"showHeader": true,
"sortBy": [
{
"desc": true,
"displayName": "Label"
}
]
},
"pluginVersion": "11.2.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${default}"
},
"editorMode": "code",
"exemplar": false,
"expr": "$metric",
"format": "table",
"hide": false,
"instant": true,
"range": false,
"refId": "A"
}
],
"title": "Cardinality for selected metric by label",
"transformations": [
{
"id": "organize",
"options": {
"excludeByName": {
"Time": true,
"Value": true,
"__name__": false
},
"indexByName": {},
"renameByName": {}
}
},
{
"id": "reduce",
"options": {
"includeTimeField": false,
"labelsToFields": false,
"mode": "seriesToRows",
"reducers": [
"distinctCount",
"last"
]
}
},
{
"id": "organize",
"options": {
"excludeByName": {},
"indexByName": {
"Distinct Count": 1,
"Field": 0,
"Last": 2
},
"renameByName": {
"Distinct Count": "Cardinality (distinct values count)",
"Field": "Label",
"Last": "A sample observed value"
}
}
}
],
"type": "table"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": "auto",
"cellOptions": {
"type": "auto"
},
"inspect": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Job"
},
"properties": [
{
"id": "links",
"value": [
{
"title": "",
"url": "/d/b0b89a23-8f37-4bfe-962a-f329a654e987/metrics-management?var-job=${__data.fields[\"Job\"]}&${datasource:queryparam}&${metric:queryparam}"
}
]
}
]
}
]
},
"gridPos": {
"h": 12,
"w": 8,
"x": 0,
"y": 13
},
"id": 7,
"options": {
"cellHeight": "sm",
"footer": {
"countRows": false,
"enablePagination": true,
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"frameIndex": 124,
"showHeader": true,
"sortBy": []
},
"pluginVersion": "11.2.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${default}"
},
"editorMode": "code",
"exemplar": false,
"expr": "topk(100, count({__name__!=\"\"}) by (job))",
"format": "table",
"instant": true,
"range": false,
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"exemplar": false,
"expr": "count({__name__!=\"\"})",
"format": "table",
"hide": false,
"instant": true,
"range": false,
"refId": "B"
}
],
"title": "Series by job (top 100)",
"transformations": [
{
"id": "merge",
"options": {}
},
{
"id": "calculateField",
"options": {
"alias": "ratio",
"binary": {
"left": "Value #A",
"operator": "/",
"reducer": "sum",
"right": "Value #B"
},
"mode": "binary",
"reduce": {
"reducer": "sum"
},
"replaceFields": false
}
},
{
"id": "organize",
"options": {
"excludeByName": {},
"indexByName": {},
"renameByName": {
"Time": "",
"__name__": "Metric"
}
}
},
{
"id": "calculateField",
"options": {
"alias": "% of total",
"binary": {
"left": "ratio",
"operator": "*",
"reducer": "sum",
"right": "100"
},
"mode": "binary",
"reduce": {
"reducer": "sum"
}
}
},
{
"id": "organize",
"options": {
"excludeByName": {
"Time": true,
"Value #B": true,
"ratio": true
},
"indexByName": {},
"renameByName": {
"Value #A": "Series count",
"job": "Job"
}
}
}
],
"type": "table"
},
{
"datasource": {
"type": "prometheus",
"uid": "${default}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": "auto",
"cellOptions": {
"type": "auto"
},
"filterable": false,
"inspect": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Metric"
},
"properties": [
{
"id": "links",
"value": [
{
"title": "",
"url": "/d/b0b89a23-8f37-4bfe-962a-f329a654e987/metrics-management?var-metric=${__data.fields[\"Metric\"]}&${datasource:queryparam}&${job:queryparam}"
}
]
},
{
"id": "custom.width",
"value": 329
}
]
}
]
},
"gridPos": {
"h": 12,
"w": 8,
"x": 8,
"y": 13
},
"id": 1,
"options": {
"cellHeight": "sm",
"footer": {
"countRows": false,
"enablePagination": true,
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"frameIndex": 124,
"showHeader": true,
"sortBy": []
},
"pluginVersion": "11.2.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"editorMode": "code",
"exemplar": false,
"expr": "topk(100, count({__name__!=\"\",job=~\"$job\"}) by (__name__))",
"format": "table",
"instant": true,
"range": false,
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "${default}"
},
"editorMode": "code",
"exemplar": false,
"expr": "count({__name__!=\"\"})",
"format": "table",
"hide": false,
"instant": true,
"range": false,
"refId": "B"
}
],
"title": "Series by metric (top 100)",
"transformations": [
{
"id": "merge",
"options": {}
},
{
"id": "calculateField",
"options": {
"alias": "ratio",
"binary": {
"left": "Value #A",
"operator": "/",
"reducer": "sum",
"right": "Value #B"
},
"mode": "binary",
"reduce": {
"reducer": "sum"
},
"replaceFields": false
}
},
{
"id": "organize",
"options": {
"excludeByName": {},
"indexByName": {},
"renameByName": {
"Time": "",
"__name__": "Metric"
}
}
},
{
"id": "calculateField",
"options": {
"alias": "% of total",
"binary": {
"left": "ratio",
"operator": "*",
"reducer": "sum",
"right": "100"
},
"mode": "binary",
"reduce": {
"reducer": "sum"
}
}
},
{
"id": "organize",
"options": {
"excludeByName": {
"Time": true,
"Value #B": true,
"ratio": true
},
"indexByName": {},
"renameByName": {
"Value #A": "Series count"
}
}
}
],
"type": "table"
}
],
"refresh": "",
"schemaVersion": 39,
"tags": [],
"templating": {
"list": [
{
"current": {},
"hide": 0,
"includeAll": false,
"multi": false,
"name": "datasource",
"options": [],
"query": "prometheus",
"queryValue": "",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"type": "datasource"
},
{
"current": {},
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"definition": "label_values(__name__)",
"hide": 0,
"includeAll": false,
"multi": false,
"name": "metric",
"options": [],
"query": {
"query": "label_values(__name__)",
"refId": "PrometheusVariableQueryEditor-VariableQuery"
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 1,
"type": "query"
},
{
"allValue": ".+",
"current": {},
"datasource": {
"type": "prometheus",
"uid": "${default}"
},
"definition": "label_values(job)",
"hide": 0,
"includeAll": true,
"label": "job (filter for metrics)",
"multi": false,
"name": "job",
"options": [],
"query": {
"query": "label_values(job)",
"refId": "PrometheusVariableQueryEditor-VariableQuery"
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"type": "query"
}
]
},
"time": {
"from": "2024-10-02T12:00:00.000Z",
"to": "2024-10-02T13:19:59.000Z"
},
"timepicker": {},
"timezone": "",
"title": "Prometheus Metrics Management",
"uid": "b0b89a23-8f37-4bfe-962a-f329a654e987",
"version": 4,
"weekStart": ""
}
@michal-kazmierczak
Copy link
Author

michal-kazmierczak commented Aug 13, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment