Can not send influx query via grafana API while creating the dashboard

I am creating the grafana dashboards with panels using Grafana API’s. (Influx as datasource)

This is what I tried. (My code to create dashboard )

import requests
url = “http://admin:admin@localhost:3000/api/dashboards/db”
payload =’’’{
“datasource”: null,
“dashboard”: {
“id”: null,
“editable”: true,
“panels”: [
{
“aliasColors”: {},
“bars”: false,
“dashLength”: 10,
“dashes”: false,
“datasource”: “Influx_DataSource”,
“fill”: 1,
“gridPos”: {
“h”: 9,
“w”: 12,
“x”: 0,
“y”: 0
},
“id”: 2,
“legend”: {
“avg”: false,
“current”: false,
“max”: false,
“min”: false,
“show”: true,
“total”: false,
“values”: false
},
“lines”: true,
“linewidth”: 1,
“links”: ,
“nullPointMode”: “null”,
“percentage”: false,
“pointradius”: 5,
“points”: false,
“renderer”: “flot”,
“seriesOverrides”: ,
“spaceLength”: 10,
“stack”: false,
“steppedLine”: false,
“targets”: [
{
“groupBy”: [
{
“params”: [
“$__interval”
],
“type”: “time”
},
{
“params”: [
“null”
],
“type”: “fill”
}
],
“orderByTime”: “ASC”,
“policy”: “default”,
“query”: " ",
“rawQuery”: true,
“refId”: “A”,
“resultFormat”: “time_series”,
“select”: [
[
{
“params”: [
“value”
],
“type”: “field”
},
{
“params”: ,
“type”: “mean”
}
]
],
“tags”:
}
],
“thresholds”: ,
“timeFrom”: null,
“timeShift”: null,
“title”: “ResponseTime”,
“tooltip”: {
“shared”: true,
“sort”: 0,
“value_type”: “individual”
},
“type”: “graph”,
“xaxis”: {
“buckets”: null,
“mode”: “time”,
“name”: null,
“show”: true,
“values”:
},
“yaxes”: [
{
“format”: “ms”,
“label”: null,
“logBase”: 1,
“max”: null,
“min”: null,
“show”: true
},
{
“format”: “short”,
“label”: null,
“logBase”: 1,
“max”: null,
“min”: null,
“show”: true
}
],
“yaxis”: {
“align”: false,
“alignLevel”: null
}
}
],
“title”: “d1”,
“originalTitle”: “New dashboard”,
“timezone”: “browser”,
“schemaVersion”: 6,
“style”: “dark”,
“version”: 0,
“templating”: {
“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”
]
},
“timezone”: “browser”,
“title”: “D1”,
“uid”: “dash1”,
“version”: 1,
“overwrite”: false
},
“folderId”: 80,
“overwrite”: false
}’’’
headers={“Content-Type”: ‘application/json’}
response = requests.post(url, data=payload,headers=headers)
print (response.text)


In Above code


“targets”: [
“query”: " ",
],
Output: Creates the dashboard.

“targets”: [
query

Output:

<Response [400]>
400
[{“classification”:“DeserializationError”,“message”:“invalid character ‘r’ after object key:value pair”},{“fieldNames”:[“Dashboard”],“classification”:“RequiredError”,“message”:“Required”}]

Can anyone help me out

Thanks This issue got solved by adding query like this

“query”: “SELECT responseTime FROM requestsRaw WHERE requestName =~ /^request/ AND testName =~/^testName/ AND $timeFilter”,

And I am able to create the dashboard .

Thanks.