Am trying to use the grafana api endpoint “api/dashboards/db” to upload my dashboard using a valid json, i checked the json and even tried the endpoint as api/dashboards/import but its still not working am not able to figure out what might be the reason why this is occuring.
i am using prometheus as the data source and have configured it properly
i checked out these forum links too while were around the same discussion but couldnt find a way to resolve my issue Error creating dashboard via http api
he is facing a similar issue i tried to use his method of resolution but it didnt seem to work
{
“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”: “Dashboard for API response time visualisations\n”,
“editable”: true,
“fiscalYearStartMonth”: 0,
“graphTooltip”: 0,
“id”: 5,
“links”: ,
“liveNow”: false,
“panels”: [
{
“collapsed”: true,
“gridPos”: {
“h”: 1,
“w”: 24,
“x”: 0,
“y”: 0
},
“id”: 27,
“panels”: [
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“fieldConfig”: {
“defaults”: {
“color”: {
“mode”: “thresholds”
},
“mappings”: ,
“thresholds”: {
“mode”: “absolute”,
“steps”: [
{
“color”: “green”,
“value”: null
},
{
“color”: “red”,
“value”: 80
}
]
}
},
“overrides”:
},
“gridPos”: {
“h”: 8,
“w”: 12,
“x”: 0,
“y”: 1
},
“id”: 25,
“options”: {
“minVizHeight”: 75,
“minVizWidth”: 75,
“orientation”: “auto”,
“reduceOptions”: {
“calcs”: [
“lastNotNull”
],
“fields”: “”,
“values”: false
},
“showThresholdLabels”: false,
“showThresholdMarkers”: true
},
“pluginVersion”: “10.2.0”,
“targets”: [
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“editorMode”: “code”,
“expr”: “sum (test_global_interceptor_response_time_count) by (endpoint)”,
“instant”: false,
“legendFormat”: “__auto”,
“range”: true,
“refId”: “A”
}
],
“title”: “Total Requests by endpoint”,
“type”: “gauge”
},
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“fieldConfig”: {
“defaults”: {
“custom”: {
“hideFrom”: {
“legend”: false,
“tooltip”: false,
“viz”: false
},
“scaleDistribution”: {
“type”: “linear”
}
}
},
“overrides”:
},
“gridPos”: {
“h”: 8,
“w”: 12,
“x”: 12,
“y”: 1
},
“id”: 21,
“options”: {
“calculate”: false,
“cellGap”: 1,
“color”: {
“exponent”: 0.5,
“fill”: “dark-orange”,
“mode”: “scheme”,
“reverse”: false,
“scale”: “exponential”,
“scheme”: “Spectral”,
“steps”: 64
},
“exemplars”: {
“color”: “rgba(255,0,255,0.7)”
},
“filterValues”: {
“le”: 1e-9
},
“legend”: {
“show”: true
},
“rowsFrame”: {
“layout”: “auto”
},
“tooltip”: {
“show”: true,
“yHistogram”: false
},
“yAxis”: {
“axisPlacement”: “left”,
“reverse”: false,
“unit”: “s”
}
},
“pluginVersion”: “10.2.0”,
“targets”: [
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“editorMode”: “code”,
“expr”: “sum by (le) (rate(test_global_interceptor_response_time_bucket[30s]))”,
“format”: “heatmap”,
“instant”: false,
“legendFormat”: “{{le}}”,
“range”: true,
“refId”: “A”
}
],
“title”: “Response Time Heatmap”,
“type”: “heatmap”
},
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“fieldConfig”: {
“defaults”: {
“color”: {
“mode”: “palette-classic”
},
“custom”: {
“axisBorderShow”: false,
“axisCenteredZero”: false,
“axisColorMode”: “text”,
“axisLabel”: “”,
“axisPlacement”: “auto”,
“barAlignment”: 0,
“drawStyle”: “line”,
“fillOpacity”: 0,
“gradientMode”: “none”,
“hideFrom”: {
“legend”: false,
“tooltip”: false,
“viz”: false
},
“insertNulls”: 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”: 9
},
“id”: 24,
“options”: {
“legend”: {
“calcs”: ,
“displayMode”: “list”,
“placement”: “bottom”,
“showLegend”: true
},
“tooltip”: {
“mode”: “single”,
“sort”: “none”
}
},
“targets”: [
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“editorMode”: “code”,
“expr”: “sum by (statusCode) (rate(test_global_interceptor_response_time_count{statusCode=~"2…"}[1h]))\n”,
“instant”: false,
“legendFormat”: “Successful”,
“range”: true,
“refId”: “A”
},
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“editorMode”: “code”,
“exemplar”: false,
“expr”: “sum by (statusCode) (\n rate(test_global_interceptor_response_time_count{statusCode=~"4…"}[1h])\n) + ignoring(statusCode) group_left sum by (statusCode) (\n rate(test_global_interceptor_response_time_count{statusCode=~"5…"}[1h])\n)”,
“hide”: false,
“instant”: false,
“legendFormat”: “Unsuccessful”,
“range”: true,
“refId”: “B”
}
],
“title”: “# Unsuccessful and Successful requests”,
“type”: “timeseries”
},
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“fieldConfig”: {
“defaults”: {
“color”: {
“mode”: “palette-classic”
},
“custom”: {
“axisBorderShow”: false,
“axisCenteredZero”: false,
“axisColorMode”: “text”,
“axisLabel”: “”,
“axisPlacement”: “auto”,
“barAlignment”: 0,
“drawStyle”: “line”,
“fillOpacity”: 0,
“gradientMode”: “none”,
“hideFrom”: {
“legend”: false,
“tooltip”: false,
“viz”: false
},
“insertNulls”: 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”: 12,
“y”: 10
},
“id”: 22,
“unit”: “s”,
“options”: {
“legend”: {
“calcs”: ,
“displayMode”: “list”,
“placement”: “bottom”,
“showLegend”: true
},
“tooltip”: {
“mode”: “single”,
“sort”: “none”
}
},
“targets”: [
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“editorMode”: “code”,
“expr”: “sum by (statusCode)(test_global_interceptor_response_time_count)”,
“format”: “time_series”,
“hide”: false,
“instant”: false,
“legendFormat”: “{{statusCode}}”,
“range”: true,
“refId”: “B”
}
],
“title”: “# requests by status codes”,
“type”: “timeseries”
},
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“fieldConfig”: {
“defaults”: {
“color”: {
“mode”: “palette-classic”
},
“custom”: {
“axisBorderShow”: false,
“axisCenteredZero”: false,
“axisColorMode”: “text”,
“axisLabel”: “”,
“axisPlacement”: “auto”,
“barAlignment”: 0,
“drawStyle”: “line”,
“fillOpacity”: 0,
“gradientMode”: “none”,
“hideFrom”: {
“legend”: false,
“tooltip”: false,
“viz”: false
},
“insertNulls”: 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
}
]
},
“unit”: “s”
},
“overrides”:
},
“gridPos”: {
“h”: 8,
“w”: 12,
“x”: 0,
“y”: 18
},
“id”: 23,
“options”: {
“legend”: {
“calcs”: ,
“displayMode”: “list”,
“placement”: “bottom”,
“showLegend”: true
},
“tooltip”: {
“mode”: “single”,
“sort”: “none”
}
},
“pluginVersion”: “10.2.0”,
“targets”: [
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“editorMode”: “code”,
“expr”: “sum(rate(test_global_interceptor_response_time_sum[30s]))/sum(rate(test_global_interceptor_response_time_count[30s]))”,
“instant”: false,
“legendFormat”: “average response time”,
“range”: true,
“refId”: “A”
}
],
“title”: “Average request response time”,
“type”: “timeseries”
}
],
“title”: “Test Global Interceptor Response Time”,
“type”: “row”
}
],
“refresh”: “”,
“schemaVersion”: 38,
“tags”: ,
“templating”: {
“list”:
},
“time”: {
“from”: “now-6h”,
“to”: “now”
},
“timepicker”: {},
“timezone”: “”,
“title”: “Response Times”,
“uid”: “ec1b884b-753e-405f-8f4b-e0a5d97cf167”,
“version”: 6,
“weekStart”: “”
}
this is the json am using
Did you get this JSON by export via HTTP API?
No i did not get this using the HTTP API
I dont actually have clarity on what you asked could you explain this more
Formats of dashboards exported via UI and via HTTP API are different.
could u mention the structure for grafana http json
could you correct me with the json and provide me with a format for json http with which i can test on
See example under Get dashboard by uid
Or export any your existing dashboard via HTTP API
how do i export?
but when i use the json which is generated by the export the panels arent being made?
Example of dashboard exported via UI:
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 181,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "yesoreyeram-infinity-datasource",
"uid": "infinity-uid"
},
"gridPos": {
"h": 7,
"w": 8,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"code": {
"language": "plaintext",
"showLineNumbers": false,
"showMiniMap": false
},
"content": "# Grafana Community\n\nThe best place to share experience on Grafana usage",
"mode": "markdown"
},
"pluginVersion": "10.2.6",
"targets": [
{
"columns": [],
"datasource": {
"type": "yesoreyeram-infinity-datasource",
"uid": "infinity-uid"
},
"filters": [],
"format": "table",
"global_query_id": "",
"refId": "A",
"root_selector": "",
"source": "url",
"type": "json",
"url": "https://github.com/grafana/grafana-infinity-datasource/blob/main/testdata/users.json",
"url_options": {
"data": "",
"method": "GET"
}
}
],
"type": "text"
},
{
"datasource": {
"type": "yesoreyeram-infinity-datasource",
"uid": "infinity-uid"
},
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 7,
"w": 8,
"x": 8,
"y": 0
},
"id": 2,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "/.*/",
"values": false
},
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "10.2.6",
"targets": [
{
"columns": [],
"data": "Status\nOnline",
"datasource": {
"type": "yesoreyeram-infinity-datasource",
"uid": "infinity-uid"
},
"filters": [],
"format": "table",
"global_query_id": "",
"refId": "A",
"root_selector": "",
"source": "inline",
"type": "csv",
"url": "https://github.com/grafana/grafana-infinity-datasource/blob/main/testdata/users.json",
"url_options": {
"data": "",
"method": "GET"
}
}
],
"type": "stat"
}
],
"refresh": "",
"schemaVersion": 39,
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Simple Dashboard",
"uid": "my-dashboard-uid",
"version": 2,
"weekStart": ""
}
The same dashboard exported via HTTP API /api/dashboards/uid/
{
"meta":{
"type":"db",
"canSave":true,
"canEdit":true,
"canAdmin":true,
"canStar":true,
"canDelete":true,
"slug":"simple-dashboard",
"url":"/d/my-dashboard-uid/simple-dashboard",
"expires":"0001-01-01T00:00:00Z",
"created":"2024-07-03T00:00:00+07:00",
"updated":"2024-07-03T00:00:00+07:00",
"updatedBy":"ebabeshko",
"createdBy":"ebabeshko",
"version":2,
"hasAcl":false,
"isFolder":false,
"provisioned":false,
"provisionedExternalId":"",
"annotationsPermissions":{
"dashboard":{
"canAdd":true,
"canEdit":true,
"canDelete":true
},
"organization":{
"canAdd":true,
"canEdit":true,
"canDelete":true
}
}
},
"dashboard":{
"annotations":{
"list":[
{
"builtIn":1,
"datasource":{
"type":"grafana",
"uid":"-- Grafana --"
},
"enable":true,
"hide":true,
"iconColor":"rgba(0, 211, 255, 1)",
"name":"Annotations \u0026 Alerts",
"type":"dashboard"
}
]
},
"editable":true,
"fiscalYearStartMonth":0,
"graphTooltip":0,
"id":181,
"links":[
],
"liveNow":false,
"panels":[
{
"datasource":{
"type":"yesoreyeram-infinity-datasource",
"uid":"infinity-uid"
},
"gridPos":{
"h":7,
"w":8,
"x":0,
"y":0
},
"id":1,
"options":{
"code":{
"language":"plaintext",
"showLineNumbers":false,
"showMiniMap":false
},
"content":"# Grafana Community\n\nThe best place to share experience on Grafana usage",
"mode":"markdown"
},
"pluginVersion":"10.2.6",
"targets":[
{
"columns":[
],
"datasource":{
"type":"yesoreyeram-infinity-datasource",
"uid":"infinity-uid"
},
"filters":[
],
"format":"table",
"global_query_id":"",
"refId":"A",
"root_selector":"",
"source":"url",
"type":"json",
"url":"https://github.com/grafana/grafana-infinity-datasource/blob/main/testdata/users.json",
"url_options":{
"data":"",
"method":"GET"
}
}
],
"type":"text"
},
{
"datasource":{
"type":"yesoreyeram-infinity-datasource",
"uid":"infinity-uid"
},
"description":"",
"fieldConfig":{
"defaults":{
"color":{
"mode":"thresholds"
},
"mappings":[
],
"thresholds":{
"mode":"absolute",
"steps":[
{
"color":"green",
"value":null
},
{
"color":"red",
"value":80
}
]
}
},
"overrides":[
]
},
"gridPos":{
"h":7,
"w":8,
"x":8,
"y":0
},
"id":2,
"options":{
"colorMode":"value",
"graphMode":"area",
"justifyMode":"auto",
"orientation":"auto",
"reduceOptions":{
"calcs":[
"lastNotNull"
],
"fields":"/.*/",
"values":false
},
"textMode":"auto",
"wideLayout":true
},
"pluginVersion":"10.2.6",
"targets":[
{
"columns":[
],
"data":"Status\nOnline",
"datasource":{
"type":"yesoreyeram-infinity-datasource",
"uid":"infinity-uid"
},
"filters":[
],
"format":"table",
"global_query_id":"",
"refId":"A",
"root_selector":"",
"source":"inline",
"type":"csv",
"url":"https://github.com/grafana/grafana-infinity-datasource/blob/main/testdata/users.json",
"url_options":{
"data":"",
"method":"GET"
}
}
],
"type":"stat"
}
],
"refresh":"",
"schemaVersion":39,
"tags":[
],
"templating":{
"list":[
]
},
"time":{
"from":"now-6h",
"to":"now"
},
"timepicker":{
},
"timezone":"",
"title":"Simple Dashboard",
"uid":"my-dashboard-uid",
"version":2,
"weekStart":""
}
}
As you can see, these JSON representations of the same dashboard are similar, but still different. So use proper JSON format of dashboard so as to create or modify it via HTTP API.
{
“meta”: {
“type”: “db”,
“canSave”: true,
“canEdit”: true,
“canAdmin”: true,
“canStar”: true,
“canDelete”: true,
“slug”: “response-times”,
“url”: “/d/ec1b884b/response-times”,
“expires”: “0001-01-01T00:00:00Z”,
“created”: “2024-07-03T04:01:29Z”,
“updated”: “2024-07-03T04:01:29Z”,
“updatedBy”: “admin”,
“createdBy”: “admin”,
“version”: 1,
“hasAcl”: false,
“isFolder”: false,
“folderId”: 0,
“folderUid”: “”,
“folderTitle”: “General”,
“folderUrl”: “”,
“provisioned”: false,
“provisionedExternalId”: “”,
“annotationsPermissions”: {
“dashboard”: {
“canAdd”: true,
“canEdit”: true,
“canDelete”: true
},
“organization”: {
“canAdd”: true,
“canEdit”: true,
“canDelete”: true
}
}
},
“dashboard”: {
“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”: “Dashboard for API response time visualisations\n”,
“editable”: true,
“fiscalYearStartMonth”: 0,
“graphTooltip”: 0,
“id”: 45,
“links”: ,
“liveNow”: false,
“panels”: [
{
“collapsed”: true,
“gridPos”: {
“h”: 1,
“w”: 24,
“x”: 0,
“y”: 0
},
“id”: 27,
“panels”: [
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“fieldConfig”: {
“defaults”: {
“color”: {
“mode”: “thresholds”
},
“mappings”: ,
“thresholds”: {
“mode”: “absolute”,
“steps”: [
{
“color”: “green”,
“value”: null
},
{
“color”: “red”,
“value”: 80
}
]
}
},
“overrides”:
},
“gridPos”: {
“h”: 8,
“w”: 12,
“x”: 0,
“y”: 1
},
“id”: 25,
“options”: {
“minVizHeight”: 75,
“minVizWidth”: 75,
“orientation”: “auto”,
“reduceOptions”: {
“calcs”: [
“lastNotNull”
],
“fields”: “”,
“values”: false
},
“showThresholdLabels”: false,
“showThresholdMarkers”: true
},
“pluginVersion”: “10.2.0”,
“targets”: [
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“editorMode”: “code”,
“expr”: “sum (test_global_interceptor_response_time_count) by (endpoint)”,
“instant”: false,
“legendFormat”: “__auto”,
“range”: true,
“refId”: “A”
}
],
“title”: “Total Requests by endpoint”,
“type”: “gauge”
},
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“fieldConfig”: {
“defaults”: {
“custom”: {
“hideFrom”: {
“legend”: false,
“tooltip”: false,
“viz”: false
},
“scaleDistribution”: {
“type”: “linear”
}
}
},
“overrides”:
},
“gridPos”: {
“h”: 8,
“w”: 12,
“x”: 12,
“y”: 1
},
“id”: 21,
“options”: {
“calculate”: false,
“cellGap”: 1,
“color”: {
“exponent”: 0.5,
“fill”: “dark-orange”,
“mode”: “scheme”,
“reverse”: false,
“scale”: “exponential”,
“scheme”: “Spectral”,
“steps”: 64
},
“exemplars”: {
“color”: “rgba(255,0,255,0.7)”
},
“filterValues”: {
“le”: 1e-9
},
“legend”: {
“show”: true
},
“rowsFrame”: {
“layout”: “auto”
},
“tooltip”: {
“show”: true,
“yHistogram”: false
},
“yAxis”: {
“axisPlacement”: “left”,
“reverse”: false,
“unit”: “s”
}
},
“pluginVersion”: “10.2.0”,
“targets”: [
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“editorMode”: “code”,
“expr”: “sum by (le) (rate(test_global_interceptor_response_time_bucket[30s]))”,
“format”: “heatmap”,
“instant”: false,
“legendFormat”: “{{le}}”,
“range”: true,
“refId”: “A”
}
],
“title”: “Response Time Heatmap”,
“type”: “heatmap”
},
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“fieldConfig”: {
“defaults”: {
“color”: {
“mode”: “palette-classic”
},
“custom”: {
“axisBorderShow”: false,
“axisCenteredZero”: false,
“axisColorMode”: “text”,
“axisLabel”: “”,
“axisPlacement”: “auto”,
“barAlignment”: 0,
“drawStyle”: “line”,
“fillOpacity”: 0,
“gradientMode”: “none”,
“hideFrom”: {
“legend”: false,
“tooltip”: false,
“viz”: false
},
“insertNulls”: 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”: 9
},
“id”: 24,
“options”: {
“legend”: {
“calcs”: ,
“displayMode”: “list”,
“placement”: “bottom”,
“showLegend”: true
},
“tooltip”: {
“mode”: “single”,
“sort”: “none”
}
},
“targets”: [
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“editorMode”: “code”,
“expr”: “sum by (statusCode) (rate(test_global_interceptor_response_time_count{statusCode=~"2…"}[1h]))\n”,
“instant”: false,
“legendFormat”: “Successful”,
“range”: true,
“refId”: “A”
},
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“editorMode”: “code”,
“exemplar”: false,
“expr”: “sum by (statusCode) (\n rate(test_global_interceptor_response_time_count{statusCode=~"4…"}[1h])\n) + ignoring(statusCode) group_left sum by (statusCode) (\n rate(test_global_interceptor_response_time_count{statusCode=~"5…"}[1h])\n)”,
“hide”: false,
“instant”: false,
“legendFormat”: “Unsuccessful”,
“range”: true,
“refId”: “B”
}
],
“title”: “# Unsuccessful and Successful requests”,
“type”: “timeseries”
},
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“fieldConfig”: {
“defaults”: {
“color”: {
“mode”: “palette-classic”
},
“custom”: {
“axisBorderShow”: false,
“axisCenteredZero”: false,
“axisColorMode”: “text”,
“axisLabel”: “”,
“axisPlacement”: “auto”,
“barAlignment”: 0,
“drawStyle”: “line”,
“fillOpacity”: 0,
“gradientMode”: “none”,
“hideFrom”: {
“legend”: false,
“tooltip”: false,
“viz”: false
},
“insertNulls”: 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”: 12,
“y”: 10
},
“id”: 22,
“options”: {
“legend”: {
“calcs”: ,
“displayMode”: “list”,
“placement”: “bottom”,
“showLegend”: true
},
“tooltip”: {
“mode”: “single”,
“sort”: “none”
}
},
“targets”: [
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“editorMode”: “code”,
“expr”: “sum by (statusCode)(test_global_interceptor_response_time_count)”,
“format”: “time_series”,
“hide”: false,
“instant”: false,
“legendFormat”: “{{statusCode}}”,
“range”: true,
“refId”: “B”
}
],
“title”: “# requests by status codes”,
“type”: “timeseries”,
“unit”: “s”
},
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“fieldConfig”: {
“defaults”: {
“color”: {
“mode”: “palette-classic”
},
“custom”: {
“axisBorderShow”: false,
“axisCenteredZero”: false,
“axisColorMode”: “text”,
“axisLabel”: “”,
“axisPlacement”: “auto”,
“barAlignment”: 0,
“drawStyle”: “line”,
“fillOpacity”: 0,
“gradientMode”: “none”,
“hideFrom”: {
“legend”: false,
“tooltip”: false,
“viz”: false
},
“insertNulls”: 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
}
]
},
“unit”: “s”
},
“overrides”:
},
“gridPos”: {
“h”: 8,
“w”: 12,
“x”: 0,
“y”: 18
},
“id”: 23,
“options”: {
“legend”: {
“calcs”: ,
“displayMode”: “list”,
“placement”: “bottom”,
“showLegend”: true
},
“tooltip”: {
“mode”: “single”,
“sort”: “none”
}
},
“pluginVersion”: “10.2.0”,
“targets”: [
{
“datasource”: {
“type”: “prometheus”,
“uid”: “PBFA97CFB590B2093”
},
“editorMode”: “code”,
“expr”: “sum(rate(test_global_interceptor_response_time_sum[30s]))/sum(rate(test_global_interceptor_response_time_count[30s]))”,
“instant”: false,
“legendFormat”: “average response time”,
“range”: true,
“refId”: “A”
}
],
“title”: “Average request response time”,
“type”: “timeseries”
}
],
“title”: “Test Global Interceptor Response Time”,
“type”: “row”
}
],
“refresh”: “”,
“schemaVersion”: 38,
“tags”: ,
“templating”: {
“list”:
},
“time”: {
“from”: “now-6h”,
“to”: “now”
},
“timepicker”: {},
“timezone”: “”,
“title”: “Response Times”,
“uid”: “ec1b884b”,
“version”: 1,
“weekStart”: “”
}
}
i followed along the way you addressed but this json isnt able to create panels
Is it accepted by POST request to /api/dashboards/db ?
yes the request is getting accepted but inside the dashboard its not having panels
any errors in the panels? in browser console or network?
is the datasource working?
yes the datasource is working
how can i rectify if there are any errors in the panels as for now i tried going through the panels manually and rectified each section of it
Adding to this i am able to update a pre created dashboard but am not able to create a new dashboard
we cant see these errors remotely. please post errors you are seeing
Thank you so much with few tweaks i was able to create the json via the api
if you already have a json template which can be imported to create your Grafana dashboard using the Grafana API here’s some steps on how you can alter that json such that the json can be accepted by the Grafana API
-
Create a dashboard from the Grafana UI by importing your JSON file (always better to have panels alongside a datasource).
-
After your dashboard has been successfully created, you can use the @Get(api/search).
what this endpoint will do is it will fetch the the uid of your dashboard. -
Once you have your uid use the endpoint (@Get api/dashboards/uid/your_uid) the response of this request will give you the json.
-
Now you can send a (@Post api/dashboards/db) to create your dashboard via Grafana API.