Last active
September 19, 2025 14:52
-
-
Save kylebrandt/16b044a84601316eece70f1d6e9ccc95 to your computer and use it in GitHub Desktop.
sqlSchema endpoint example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HTTP/1.1 200 OK | |
| Audit-Id: 5b82aaf1-4ba7-48bc-bb7b-94a7b89c6c5e | |
| Cache-Control: no-store | |
| Content-Type: application/json | |
| X-Content-Type-Options: nosniff | |
| X-Frame-Options: deny | |
| X-Xss-Protection: 1; mode=block | |
| Date: Fri, 19 Sep 2025 14:51:41 GMT | |
| Content-Length: 902 | |
| Connection: close | |
| { | |
| "kind": "SQLSchemas", | |
| "apiVersion": "query.grafana.app/v0alpha1", | |
| "sqlSchemas": { | |
| "cat": { | |
| "columns": [ | |
| { | |
| "name": "__metric_name__", | |
| "mysqlType": "text", | |
| "nullable": false, | |
| "dataFrameFieldType": "string" | |
| }, | |
| { | |
| "name": "__value__", | |
| "mysqlType": "double", | |
| "nullable": true, | |
| "dataFrameFieldType": "*float64" | |
| }, | |
| { | |
| "name": "host", | |
| "mysqlType": "text", | |
| "nullable": true, | |
| "dataFrameFieldType": "*string" | |
| } | |
| ], | |
| "sampleRows": [ | |
| [ | |
| "cpu", | |
| 3.14, | |
| "a" | |
| ], | |
| [ | |
| "cpu", | |
| 93.14, | |
| "b" | |
| ], | |
| [ | |
| "cpu", | |
| 3, | |
| "x" | |
| ] | |
| ] | |
| }, | |
| "dog": { | |
| "columns": null, | |
| "sampleRows": null, | |
| "error": "[sse.dataQueryError] failed to execute query [dog]: invalid query type. aframes_builder" | |
| }, | |
| "fox": { | |
| "columns": [ | |
| { | |
| "name": "__metric_name__", | |
| "mysqlType": "text", | |
| "nullable": false, | |
| "dataFrameFieldType": "string" | |
| }, | |
| { | |
| "name": "__value__", | |
| "mysqlType": "double", | |
| "nullable": true, | |
| "dataFrameFieldType": "*float64" | |
| }, | |
| { | |
| "name": "host", | |
| "mysqlType": "text", | |
| "nullable": true, | |
| "dataFrameFieldType": "*string" | |
| } | |
| ], | |
| "sampleRows": [ | |
| [ | |
| "cpu", | |
| 3.14, | |
| "a" | |
| ], | |
| [ | |
| "cpu", | |
| 93.14, | |
| "c" | |
| ] | |
| ] | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### Req | |
| POST http://admin:admin@localhost:3000/apis/query.grafana.app/v0alpha1/namespaces/default/sqlschemas?ds_type=__expr__&expression=true | |
| content-type: application/json | |
| { | |
| "queries": [ | |
| { | |
| "datasource": { | |
| "uid": "9c3MNrV4k", | |
| "type": "grafana-mock-datasource" | |
| }, | |
| "frames": [ | |
| { | |
| "count": 1, | |
| "disabled": false, | |
| "fields": [ | |
| { | |
| "disabled": false, | |
| "labels": "host=a", | |
| "name": "cpu", | |
| "type": "nullable-float64", | |
| "value": "3.14" | |
| }, | |
| { | |
| "disabled": false, | |
| "labels": "host=b", | |
| "name": "cpu", | |
| "type": "nullable-float64", | |
| "value": "93.14" | |
| }, | |
| { | |
| "name": "cpu", | |
| "type": "float64", | |
| "disabled": false, | |
| "value": "3", | |
| "labels": "host=x" | |
| }, | |
| { | |
| "name": "cpu", | |
| "type": "float64", | |
| "disabled": false, | |
| "value": "2", | |
| "labels": "host=y" | |
| }, | |
| { | |
| "name": "cpu", | |
| "type": "float64", | |
| "disabled": false, | |
| "value": "4", | |
| "labels": "host=z" | |
| }, | |
| { | |
| "name": "cpu", | |
| "type": "float64", | |
| "disabled": false, | |
| "value": "1", | |
| "labels": "host=u" | |
| }, | |
| { | |
| "name": "cpu", | |
| "type": "float64", | |
| "disabled": false, | |
| "value": "2", | |
| "labels": "host=v" | |
| }, | |
| { | |
| "name": "cpu", | |
| "type": "float64", | |
| "disabled": false, | |
| "value": "3", | |
| "labels": "host=w" | |
| } | |
| ], | |
| "frameInputType": "numeric-wide", | |
| "meta": { | |
| "type": "numeric-wide", | |
| "typeVersion": [ | |
| 0, | |
| 1 | |
| ] | |
| }, | |
| "name": "New Frame", | |
| "source": "count" | |
| } | |
| ], | |
| "generatorSource": "frontend", | |
| "hide": true, | |
| "queryType": "frames_builder", | |
| "rawFrameSource": "staticScenario", | |
| "refId": "cat", | |
| "resultState": "success", | |
| "scenario": "no-data", | |
| "datasourceId": 49, | |
| "intervalMs": 20000, | |
| "maxDataPoints": 1003 | |
| }, | |
| { | |
| "datasource": { | |
| "uid": "9c3MNrV4k", | |
| "type": "grafana-mock-datasource" | |
| }, | |
| "frames": [ | |
| { | |
| "count": 1, | |
| "disabled": false, | |
| "fields": [ | |
| { | |
| "disabled": false, | |
| "labels": "host=a", | |
| "name": "cpu", | |
| "type": "nullable-float64", | |
| "value": "3.14" | |
| }, | |
| { | |
| "disabled": false, | |
| "labels": "host=c", | |
| "name": "cpu", | |
| "type": "float64", | |
| "value": "93.14" | |
| } | |
| ], | |
| "frameInputType": "numeric-wide", | |
| "meta": { | |
| "type": "numeric-wide", | |
| "typeVersion": [ | |
| 0, | |
| 1 | |
| ] | |
| }, | |
| "name": "New Frame", | |
| "source": "count" | |
| } | |
| ], | |
| "generatorSource": "frontend", | |
| "hide": true, | |
| "queryType": "frames_builder", | |
| "rawFrameSource": "staticScenario", | |
| "refId": "fox", | |
| "resultState": "success", | |
| "scenario": "no-data", | |
| "datasourceId": 49, | |
| "intervalMs": 20000, | |
| "maxDataPoints": 1003 | |
| }, | |
| { | |
| "datasource": { | |
| "uid": "9c3MNrV4k", | |
| "type": "grafana-mock-datasource" | |
| }, | |
| "frames": [ | |
| { | |
| "count": 1, | |
| "disabled": false, | |
| "fields": [ | |
| { | |
| "disabled": false, | |
| "labels": "host=a", | |
| "name": "cpu", | |
| "type": "nullable-float64", | |
| "value": "3.14" | |
| }, | |
| { | |
| "disabled": false, | |
| "labels": "host=e", | |
| "name": "cpu", | |
| "type": "nullable-float64", | |
| "value": "93.14" | |
| } | |
| ], | |
| "frameInputType": "numeric-wide", | |
| "meta": { | |
| "type": "numeric-wide", | |
| "typeVersion": [ | |
| 0, | |
| 1 | |
| ] | |
| }, | |
| "name": "New Frame", | |
| "source": "count" | |
| } | |
| ], | |
| "generatorSource": "frontend", | |
| "hide": true, | |
| "queryType": "aframes_builder", | |
| "rawFrameSource": "staticScenario", | |
| "refId": "dog", | |
| "resultState": "success", | |
| "scenario": "no-data", | |
| "datasourceId": 49, | |
| "intervalMs": 20000, | |
| "maxDataPoints": 1003 | |
| }, | |
| { | |
| "datasource": { | |
| "type": "__expr__", | |
| "uid": "__expr__", | |
| "name": "Expression" | |
| }, | |
| "expression": "$cat + $fox + $dog", | |
| "hide": false, | |
| "refId": "C", | |
| "type": "math", | |
| "window": "" | |
| } | |
| ], | |
| "from": "1690967121711", | |
| "to": "1690988721711" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment