Hello,
Thank you for reply.
I have my own JSON template and i exported from Grafana GUI dashboard. Now i wanted to import this template via HTTP API to Grafana server .
NOTE,I am using Infinity data source.
Idea is not to create manual dashboard from Grafana GUI.
i am able to get success response from POST man but when i go i grafana dashboard , i can see dashboard is created but empty data and data source.
Template file:
{
“annotations”: {
“list”: [
{
“builtIn”: 1,
“datasource”: {
“type”: “datasource”,
“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”: 287,
“links”: [
{
“asDropdown”: false,
“icon”: “external link”,
“includeVars”: false,
“keepTime”: false,
“tags”: ,
“targetBlank”: false,
“title”: “Poralis dashboard”,
“tooltip”: “Open the poralis dashboard”,
“type”: “link”,
“url”: “https://xxxxxxxxxxx/d/phuoc-test/p-test-infinity?orgId=1&from=1704933710338&to=1704976910338”
}
],
“liveNow”: false,
“panels”: [
{
“collapsed”: false,
“datasource”: {
“type”: “prometheus”,
“uid”: “prometheus”
},
“gridPos”: {
“h”: 1,
“w”: 24,
“x”: 0,
“y”: 0
},
“id”: 5,
“panels”: ,
“targets”: [
{
“datasource”: {
“type”: “prometheus”,
“uid”: “prometheus”
},
“refId”: “A”
}
],
“title”: “Results”,
“type”: “row”
},
{
“datasource”: {
“type”: “yesoreyeram-infinity-datasource”,
“uid”: “dba7e1a1-c9f2-4b29-b423-3e11b204f500”
},
“fieldConfig”: {
“defaults”: {
“color”: {
“mode”: “continuous-GrYlRd”
},
“mappings”: ,
“thresholds”: {
“mode”: “absolute”,
“steps”: [
{
“color”: “green”,
“value”: null
},
{
“color”: “red”,
“value”: 80
}
]
}
},
“overrides”:
},
“gridPos”: {
“h”: 9,
“w”: 12,
“x”: 0,
“y”: 1
},
“id”: 10,
“options”: {
“displayMode”: “gradient”,
“minVizHeight”: 10,
“minVizWidth”: 0,
“orientation”: “horizontal”,
“reduceOptions”: {
“calcs”: [
“lastNotNull”
],
“fields”: “/^Number of type$/”,
“values”: true
},
“showUnfilled”: true,
“valueMode”: “color”
},
“pluginVersion”: “10.1.2”,
“targets”: [
{
“columns”: ,
“datasource”: {
“type”: “yesoreyeram-infinity-datasource”,
“uid”: “dba7e1a1-c9f2-4b29-b423-3e11b204f500”
},
“filters”: [
{
“field”: “Number of namespace”,
“operator”: “equals”,
“value”: [
“”
]
}
],
“format”: “table”,
“global_query_id”: “”,
“json_options”: {
“columnar”: false
},
“parser”: “uql”,
“refId”: “A”,
“root_selector”: “Results”,
“source”: “url”,
“type”: “json”,
“uql”: “parse-json\r\n| project "Results"\r\n| summarize "Number of type"=count() by "Kind"”,
“url”: “http://xxxxxxxxxxxxxxx:30013/example-test.json”,
“url_options”: {
“data”: “”,
“method”: “GET”
}
}
],
“title”: “Number of kind”,
“type”: “bargauge”
},
{
“datasource”: {
“type”: “yesoreyeram-infinity-datasource”,
“uid”: “dba7e1a1-c9f2-4b29-b423-3e11b204f500”
},
“fieldConfig”: {
“defaults”: {
“color”: {
“mode”: “continuous-GrYlRd”
},
“custom”: {
“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”: ,
“thresholds”: {
“mode”: “absolute”,
“steps”: [
{
“color”: “green”,
“value”: null
},
{
“color”: “red”,
“value”: 80
}
]
}
},
“overrides”:
},
“gridPos”: {
“h”: 9,
“w”: 12,
“x”: 12,
“y”: 1
},
“id”: 11,
“options”: {
“barRadius”: 0,
“barWidth”: 0.97,
“colorByField”: “Namespace”,
“fullHighlight”: false,
“groupWidth”: 0.7,
“legend”: {
“calcs”: ,
“displayMode”: “list”,
“placement”: “bottom”,
“showLegend”: true
},
“orientation”: “horizontal”,
“showValue”: “auto”,
“stacking”: “none”,
“tooltip”: {
“mode”: “single”,
“sort”: “none”
},
“xTickLabelRotation”: 0,
“xTickLabelSpacing”: 0
},
“pluginVersion”: “10.1.2”,
“targets”: [
{
“columns”: ,
“datasource”: {
“type”: “yesoreyeram-infinity-datasource”,
“uid”: “dba7e1a1-c9f2-4b29-b423-3e11b204f500”
},
“filters”: [
{
“field”: “Number of namespace”,
“operator”: “equals”,
“value”: [
“”
]
}
],
“format”: “table”,
“global_query_id”: “”,
“json_options”: {
“columnar”: false
},
“parser”: “uql”,
“refId”: “A”,
“root_selector”: “Results”,
“source”: “url”,
“type”: “json”,
“uql”: “parse-json\r\n| project "Results"\r\n| summarize "Recommend by namespace"=count() by "Namespace"”,
“url”: “http://xxxxxxxxxxxxxxxx:30013/example-test.json”,
“url_options”: {
“data”: “”,
“method”: “GET”
}
}
],
“title”: “Recommended by namespace”,
“type”: “barchart”
},
{
“datasource”: {
“type”: “yesoreyeram-infinity-datasource”,
“uid”: “dba7e1a1-c9f2-4b29-b423-3e11b204f500”
},
“fieldConfig”: {
“defaults”: {
“color”: {
“mode”: “thresholds”
},
“custom”: {
“align”: “left”,
“cellOptions”: {
“type”: “color-text”
},
“filterable”: true,
“inspect”: false
},
“mappings”: [
{
“options”: {
“danger”: {
“color”: “red”,
“index”: 0,
“text”: “danger”
},
“warning”: {
“color”: “orange”,
“index”: 1,
“text”: “warning”
}
},
“type”: “value”
}
],
“thresholds”: {
“mode”: “absolute”,
“steps”: [
{
“color”: “text”,
“value”: null
}
]
},
“unit”: “string”
},
“overrides”: [
{
“matcher”: {
“id”: “byName”,
“options”: “kind”
},
“properties”: [
{
“id”: “custom.width”,
“value”: 284
}
]
},
{
“matcher”: {
“id”: “byName”,
“options”: “Kind”
},
“properties”: [
{
“id”: “custom.width”,
“value”: 183
}
]
},
{
“matcher”: {
“id”: “byName”,
“options”: “Name”
},
“properties”: [
{
“id”: “custom.width”,
“value”: 231
}
]
}
]
},
“gridPos”: {
“h”: 18,
“w”: 24,
“x”: 0,
“y”: 10
},
“id”: 3,
“options”: {
“cellHeight”: “sm”,
“footer”: {
“countRows”: false,
“fields”: “”,
“reducer”: [
“sum”
],
“show”: false
},
“showHeader”: true,
“sortBy”: [
{
“desc”: true,
“displayName”: “Severity”
}
]
},
“pluginVersion”: “10.1.2”,
“targets”: [
{
“columns”: [
{
“selector”: “Kind”,
“text”: “Kind of pod”,
“type”: “string”
},
{
“selector”: “Name”,
“text”: “Name”,
“type”: “string”
},
{
“selector”: “Namespace”,
“text”: “Namespace”,
“type”: “string”
},
{
“selector”: “Results”,
“text”: “Results”,
“type”: “string”
}
],
“csv_options”: {
“columns”: “”,
“comment”: “”,
“delimiter”: “,”,
“relax_column_count”: false,
“skip_empty_lines”: false,
“skip_lines_with_error”: false
},
“data”: “”,
“datasource”: {
“type”: “yesoreyeram-infinity-datasource”,
“uid”: “dba7e1a1-c9f2-4b29-b423-3e11b204f500”
},
“filters”: ,
“format”: “table”,
“global_query_id”: “”,
“groq”: “*”,
“json_options”: {
“root_is_not_array”: true
},
“parser”: “uql”,
“refId”: “A”,
“root_selector”: “Results”,
“source”: “url”,
“type”: “json”,
“uql”: “parse-json\r\n| project "Results"\r\n| project-away "CreatedTime"\r\n| extend "Kind", "Name","Namespace", "ID"=strcat("Results.pdbDisruptionsIsZero.ID","Results.sensitiveConfigmapContent.ID","Results.rolebindingClusterAdminClusterRole.ID","Results.rolebindingClusterAdminRole.ID","Results.rolebindingClusterRolePodExecAttach.ID","Results.rolebindingRolePodExecAttach.ID","Results.rolePodExecAttach.ID"),"Message"=strcat("Results.pdbDisruptionsIsZero.Message","Results.sensitiveConfigmapContent.Message","Results.rolebindingClusterAdminClusterRole.Message","Results.rolebindingClusterAdminRole.Message","Results.rolebindingClusterRolePodExecAttach.Message","Results.rolebindingRolePodExecAttach.Message","Results.rolePodExecAttach.Message"), "Severity"=strcat("Results.pdbDisruptionsIsZero.Severity","Results.sensitiveConfigmapContent.Severity", "Results.rolePodExecAttach.Severity"),"Category"=strcat("Results.pdbDisruptionsIsZero.Category","Results.sensitiveConfigmapContent.Category","Results.rolebindingClusterAdminClusterRole.Category","Results.rolebindingClusterAdminRole.Category","Results.rolebindingClusterRolePodExecAttach.Category","Results.rolebindingRolePodExecAttach.Category","Results.rolePodExecAttach.Category"), "Success"=strcat("Results.pdbDisruptionsIsZero.Success","Results.sensitiveConfigmapContent.Success","Results.rolebindingClusterAdminClusterRole.Success","Results.rolebindingClusterAdminRole.Success","Results.rolebindingClusterRolePodExecAttach.Success","Results.rolebindingRolePodExecAttach.Success","Results.rolePodExecAttach.Success")\r\n| project-away "PodResult", "Results"”,
“url”: “http://xxxx:30013/example-test.json”,
“url_options”: {
“data”: “”,
“method”: “GET”
}
}
],
“title”: “Recommendations Details”,
“type”: “table”
}
],
“refresh”: “”,
“schemaVersion”: 38,
“style”: “dark”,
“tags”: ,
“templating”: {
“list”:
},
“time”: {
“from”: “now-5m”,
“to”: “now”
},
“timepicker”: {},
“timezone”: “”,
“title”: “Polaris test”,
“uid”: “c69a76b5-a006-4c27-95de-3dcdb5d69dad”,
“version”: 5,
“weekStart”: “”
}
API: /api/dashboards/import
changes done in POSTMAN :
“dashboard”: {
“title”: “Polaris123”,
“message”: “Made changes to xyz”
},
“timepicker”: {},
“timezone”: “”,
“title”: “Polaris123”,
“uid”: “Polaris123_ID”,
“version”: 2,
“weekStart”: “”,
“overwrite”: true