Skip to content

Instantly share code, notes, and snippets.

@jeschkies
Created September 22, 2021 11:19
Show Gist options
  • Save jeschkies/5568809483e0f9c7feae58d6f3a2c7e1 to your computer and use it in GitHub Desktop.
Save jeschkies/5568809483e0f9c7feae58d6f3a2c7e1 to your computer and use it in GitHub Desktop.
Update Usage Insights Dashboard for internal use
{
"__inputs": [
{
"name": "DS_LOKI",
"label": "loki-datasource",
"description": "",
"type": "datasource",
"pluginId": "loki",
"pluginName": "Loki"
}
],
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "7.3.6"
},
{
"type": "panel",
"id": "graph",
"name": "Graph",
"version": ""
},
{
"type": "datasource",
"id": "loki",
"name": "Loki",
"version": "1.0.0"
},
{
"type": "panel",
"id": "stat",
"name": "Stat",
"version": ""
},
{
"type": "panel",
"id": "table",
"name": "Table",
"version": ""
},
{
"type": "datasource",
"id": "testdata",
"name": "TestData DB",
"version": "1.0.0"
}
],
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": 13785,
"graphTooltip": 0,
"id": null,
"links": [
{
"icon": "dashboard",
"tags": [],
"title": "Usage insights per datasource",
"tooltip": "",
"type": "link",
"url": "/d/AEbrOO2Mz/usage-insights-for-datasource"
}
],
"panels": [
{
"collapsed": false,
"datasource": null,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 0
},
"id": 31,
"panels": [],
"title": "Usage Insight KPI",
"type": "row"
},
{
"datasource": "${DS_LOKI}",
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": null
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "purple",
"value": null
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 6,
"x": 0,
"y": 1
},
"id": 25,
"interval": "23.9h",
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "center",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"last"
],
"fields": "",
"values": false
},
"text": {},
"textMode": "value"
},
"pluginVersion": "7.3.6",
"targets": [
{
"expr": "sum(count_over_time({instance_type=\"grafana\"}[$__interval])) ",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": "24h",
"timeShift": null,
"title": "Total usage insights events ",
"transformations": [
{
"id": "reduce",
"options": {
"reducers": [
"sum"
]
}
}
],
"type": "stat"
},
{
"datasource": "${DS_LOKI}",
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": null,
"filterable": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "purple",
"value": null
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Requests"
},
"properties": [
{
"id": "custom.width",
"value": 100
}
]
}
]
},
"gridPos": {
"h": 4,
"w": 6,
"x": 6,
"y": 1
},
"id": 27,
"interval": "4.9m",
"options": {
"colorMode": "background",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"sum"
],
"fields": "",
"values": false
},
"text": {},
"textMode": "value"
},
"pluginVersion": "7.3.6",
"targets": [
{
"expr": "count(sum by (datasourceId) (count_over_time({instance_type=\"grafana\"} | logfmt | error=\"\" [5m]))) ",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": "5m",
"timeShift": null,
"title": "Datasources in use right now",
"transformations": [],
"type": "stat"
},
{
"datasource": "${DS_LOKI}",
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": null
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "purple",
"value": null
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Requests"
},
"properties": [
{
"id": "custom.width",
"value": 100
}
]
}
]
},
"gridPos": {
"h": 4,
"w": 6,
"x": 12,
"y": 1
},
"id": 28,
"interval": "4.9m",
"options": {
"colorMode": "background",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"max"
],
"fields": "",
"values": false
},
"text": {},
"textMode": "value"
},
"pluginVersion": "7.3.6",
"targets": [
{
"expr": "count(sum by (dashboardId) (count_over_time({instance_type=\"grafana\"} | logfmt | error=\"\" [5m])))",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": "5m",
"timeShift": null,
"title": "Dashboards in use right now",
"transformations": [],
"type": "stat"
},
{
"datasource": "${DS_LOKI}",
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": null
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "purple",
"value": null
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Requests"
},
"properties": [
{
"id": "custom.width",
"value": 100
}
]
}
]
},
"gridPos": {
"h": 4,
"w": 6,
"x": 18,
"y": 1
},
"id": 29,
"interval": "4.9m",
"options": {
"colorMode": "background",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"max"
],
"fields": "",
"values": false
},
"text": {},
"textMode": "value"
},
"pluginVersion": "7.3.6",
"targets": [
{
"expr": "count(sum by (userId) (count_over_time({instance_type=\"grafana\"} | logfmt | error=\"\" [5m])))",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": "5m",
"timeShift": null,
"title": "Users right now",
"transformations": [],
"type": "stat"
},
{
"collapsed": false,
"datasource": "",
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 5
},
"id": 16,
"panels": [],
"title": "Usage Insight Details",
"type": "row"
},
{
"aliasColors": {
"Dashboard views from Jons-MBP": "light-yellow",
"Dashboard views from iMac-Pro-Ward.local": "blue",
"Errors for Jons-MBP": "red",
"Request errors from Jons-MBP": "red",
"Request errors from iMac-Pro-Ward.local": "dark-red",
"Requests from Jons-MBP": "green",
"Requests from iMac-Pro-Ward.local": "dark-green",
"Success for Jons-MBP": "green"
},
"bars": true,
"dashLength": 10,
"dashes": false,
"datasource": "${DS_LOKI}",
"fieldConfig": {
"defaults": {
"custom": {},
"unit": "short"
},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 8,
"w": 24,
"x": 0,
"y": 6
},
"hiddenSeries": false,
"id": 10,
"interval": "5m",
"legend": {
"alignAsTable": true,
"avg": false,
"current": false,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": false
},
"lines": false,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.3.6",
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [
{
"$$hashKey": "object:220",
"alias": "/errors/",
"color": "#E02F44"
},
{
"$$hashKey": "object:221",
"alias": "/Requests from/",
"color": "#3274D9"
},
{
"$$hashKey": "object:736",
"alias": "/Dashboard views from/",
"color": "#56A64B"
}
],
"spaceLength": 10,
"stack": true,
"steppedLine": false,
"targets": [
{
"expr": "sum by(host) (count_over_time({instance_type=\"grafana\"} | logfmt | eventName=\"data-request\" | error = \"\" [$__interval]))",
"legendFormat": "Data Requests from {{host}}",
"refId": "A"
},
{
"expr": "sum by(host) (count_over_time({instance_type=\"grafana\"} | logfmt | eventName=\"data-request\" | error != \"\" [$__interval]))",
"legendFormat": "Data Requests errors from {{host}}",
"refId": "B"
},
{
"expr": "sum by(host) (count_over_time({instance_type=\"grafana\"} | logfmt | eventName=\"dashboard-view\" [$__interval]))",
"legendFormat": "Dashboard views from {{host}}",
"refId": "C"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Usage insights events",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"$$hashKey": "object:234",
"decimals": 0,
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"$$hashKey": "object:235",
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": false
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"datasource": "${DS_LOKI}",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": null,
"filterable": false
},
"links": [],
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Views"
},
"properties": [
{
"id": "custom.displayMode",
"value": "gradient-gauge"
},
{
"id": "color",
"value": {
"mode": "continuous-BlPu"
}
}
]
}
]
},
"gridPos": {
"h": 7,
"w": 9,
"x": 0,
"y": 14
},
"id": 18,
"interval": "",
"options": {
"showHeader": true,
"sortBy": [
{
"desc": true,
"displayName": "Total"
}
]
},
"pluginVersion": "7.3.6",
"targets": [
{
"expr": "topk(10, sum by (dashboardId,dashboardName,folderName) (count_over_time({instance_type=\"grafana\"} | logfmt | eventName=\"data-request\" [$__interval])))",
"legendFormat": "{{dashboardName}} - {{folderName}}",
"refId": "A"
}
],
"timeFrom": "24h",
"timeShift": null,
"title": "Top 10 dashboards",
"transformations": [
{
"id": "reduce",
"options": {
"includeTimeField": false,
"mode": "seriesToRows",
"reducers": [
"sum"
]
}
},
{
"id": "organize",
"options": {
"excludeByName": {},
"indexByName": {},
"renameByName": {
"Field": "Dashboard - Folder",
"Total": "Views"
}
}
}
],
"type": "table"
},
{
"datasource": "${DS_LOKI}",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": null,
"filterable": false
},
"links": [
{
"title": "Go to datasource usage insights",
"url": "/d/AEbrOO2Mz/usage-insights-for-datasource?var-Datasource=${__value.text:percentencode}"
}
],
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Query Count"
},
"properties": [
{
"id": "custom.displayMode",
"value": "gradient-gauge"
},
{
"id": "color",
"value": {
"mode": "continuous-BlPu"
}
}
]
}
]
},
"gridPos": {
"h": 7,
"w": 9,
"x": 9,
"y": 14
},
"id": 20,
"interval": "",
"options": {
"showHeader": true,
"sortBy": [
{
"desc": true,
"displayName": "Total"
}
]
},
"pluginVersion": "7.3.6",
"targets": [
{
"expr": "topk(10, sum by (datasourceName) (count_over_time({instance_type=\"grafana\"} | logfmt | eventName=\"data-request\" [$__interval])))",
"legendFormat": "{{datasourceName}}",
"refId": "A"
}
],
"timeFrom": "24h",
"timeShift": null,
"title": "Top 10 data sources",
"transformations": [
{
"id": "reduce",
"options": {
"reducers": [
"sum"
]
}
},
{
"id": "organize",
"options": {
"excludeByName": {},
"indexByName": {},
"renameByName": {
"Field": "Datasource",
"Total": "Query Count"
}
}
}
],
"type": "table"
},
{
"datasource": "${DS_LOKI}",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": null,
"displayMode": "auto",
"filterable": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Views"
},
"properties": [
{
"id": "custom.displayMode",
"value": "gradient-gauge"
},
{
"id": "color",
"value": {
"mode": "continuous-BlPu"
}
}
]
}
]
},
"gridPos": {
"h": 7,
"w": 6,
"x": 18,
"y": 14
},
"id": 22,
"interval": "",
"options": {
"showHeader": true
},
"pluginVersion": "7.3.6",
"targets": [
{
"expr": "topk(10, sum by (username) (count_over_time({instance_type=\"grafana\"} | logfmt | eventName=\"data-request\" [$__interval])))",
"legendFormat": "{{username}}",
"refId": "A"
}
],
"timeFrom": "24h",
"timeShift": null,
"title": "Top 10 users",
"transformations": [
{
"id": "reduce",
"options": {
"reducers": [
"sum"
]
}
},
{
"id": "organize",
"options": {
"excludeByName": {},
"indexByName": {},
"renameByName": {
"Field": "Username",
"Total": "Views"
}
}
}
],
"type": "table"
},
{
"datasource": "${DS_LOKI}",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": null,
"filterable": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Error Count"
},
"properties": [
{
"id": "custom.displayMode",
"value": "gradient-gauge"
},
{
"id": "color",
"value": {
"mode": "continuous-YlRd"
}
}
]
}
]
},
"gridPos": {
"h": 7,
"w": 9,
"x": 0,
"y": 21
},
"id": 19,
"interval": "",
"options": {
"showHeader": true,
"sortBy": [
{
"desc": true,
"displayName": "Total"
}
]
},
"pluginVersion": "7.3.6",
"targets": [
{
"expr": "topk(10, sum by (dashboardId,dashboardName,folderName) (count_over_time({instance_type=\"grafana\"} | logfmt | eventName=\"data-request\" | error!=\"\" [$__interval])))",
"legendFormat": "{{dashboardName}} - {{folderName}}",
"refId": "A"
}
],
"timeFrom": "24h",
"timeShift": null,
"title": "Top 10 dashboards with errors",
"transformations": [
{
"id": "reduce",
"options": {
"reducers": [
"sum"
]
}
},
{
"id": "organize",
"options": {
"excludeByName": {},
"indexByName": {},
"renameByName": {
"Field": "Dashboard - Folder",
"Total": "Error Count"
}
}
}
],
"type": "table"
},
{
"datasource": "${DS_LOKI}",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": null,
"filterable": false
},
"links": [
{
"title": "Go to datasource insights",
"url": "/d/AEbrOO2Mz/usage-insights-for-datasource?var-Datasource=${__value.text:percentencode}"
}
],
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Error Count"
},
"properties": [
{
"id": "custom.displayMode",
"value": "gradient-gauge"
},
{
"id": "color",
"value": {
"mode": "continuous-YlRd"
}
}
]
}
]
},
"gridPos": {
"h": 7,
"w": 9,
"x": 9,
"y": 21
},
"id": 21,
"interval": "",
"options": {
"showHeader": true,
"sortBy": [
{
"desc": true,
"displayName": "Total"
}
]
},
"pluginVersion": "7.3.6",
"targets": [
{
"expr": "topk(10, sum by (datasourceName) (count_over_time({instance_type=\"grafana\"} | logfmt | eventName=\"data-request\" | error!=\"\" [$__interval])))",
"legendFormat": "{{datasourceName}}",
"refId": "A"
}
],
"timeFrom": "24h",
"timeShift": null,
"title": "Top 10 data sources with errors",
"transformations": [
{
"id": "reduce",
"options": {
"reducers": [
"sum"
]
}
},
{
"id": "organize",
"options": {
"excludeByName": {},
"indexByName": {},
"renameByName": {
"Field": "Datasource",
"Total": "Error Count"
}
}
}
],
"type": "table"
},
{
"datasource": "${DS_LOKI}",
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": null,
"filterable": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Error count"
},
"properties": [
{
"id": "custom.displayMode",
"value": "gradient-gauge"
},
{
"id": "color",
"value": {
"mode": "continuous-YlRd"
}
}
]
}
]
},
"gridPos": {
"h": 7,
"w": 6,
"x": 18,
"y": 21
},
"id": 23,
"interval": "",
"options": {
"showHeader": true
},
"pluginVersion": "7.3.6",
"targets": [
{
"expr": "topk(10, sum by (username) (count_over_time({instance_type=\"grafana\"} | logfmt | eventName=\"data-request\" | error!=\"\" [$__interval])))",
"legendFormat": "{{username}}",
"refId": "A"
}
],
"timeFrom": "24h",
"timeShift": null,
"title": "Top 10 users seeing errors",
"transformations": [
{
"id": "reduce",
"options": {
"reducers": [
"sum"
]
}
},
{
"id": "organize",
"options": {
"excludeByName": {},
"indexByName": {},
"renameByName": {
"Field": "Username",
"Total": "Error count"
}
}
}
],
"type": "table"
}
],
"refresh": "30s",
"schemaVersion": 26,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-7d",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Usage insights",
"uid": "XU8HAD5Gk",
"version": 24
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment