Skip to content

Commit f091384

Browse files
amotlLukas Pfannschmidt
andauthored
Data Source API: Add support for Amazon Redshift and Clickhouse (#166)
Co-authored-by: Lukas Pfannschmidt <lukas@super.ai>
1 parent 1410eb1 commit f091384

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
endpoints, and by adding missing ``move_folder``. Thanks, @grafuls.
1414
* Service Accounts: Unlock endpoint to update service account by id.
1515
Thanks, @einar-lanfranco.
16+
* Data Source API: Add support for Amazon Redshift and Clickhouse.
17+
Thanks, @lpfann and @mysuperai.
1618

1719
[Niquests]: https://niquests.readthedocs.io/
1820
[Riquests]: https://requests.readthedocs.io/

grafana_client/knowledge.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,68 @@ def query_factory(datasource, model: Optional[dict] = None, expression: Optional
288288
"default": None,
289289
},
290290
]
291+
elif datasource_type == "grafana-redshift-datasource":
292+
query = {
293+
"datasource": {
294+
"type": datasource["type"],
295+
"uid": datasource.get("uid"),
296+
},
297+
"datasourceId": datasource.get("id"),
298+
"rawSQL": expression,
299+
}
291300

301+
attrs = [
302+
{
303+
"name": "format",
304+
"default": 0,
305+
"choices": [0, 1],
306+
},
307+
{
308+
"name": "intervalMs",
309+
"default": 30000,
310+
},
311+
{
312+
"name": "maxDataPoints",
313+
"default": 1441,
314+
},
315+
{
316+
"name": "refId",
317+
"default": None,
318+
},
319+
]
320+
elif datasource_type == "grafana-clickhouse-datasource":
321+
query = {
322+
"datasource": {
323+
"type": datasource["type"],
324+
"uid": datasource.get("uid"),
325+
},
326+
"datasourceId": datasource.get("id"),
327+
"rawSql": expression,
328+
}
329+
330+
attrs = [
331+
{
332+
"name": "format",
333+
"default": "0",
334+
"choices": [0, 1],
335+
},
336+
{
337+
"name": "intervalMs",
338+
"default": 30000,
339+
},
340+
{
341+
"name": "maxDataPoints",
342+
"default": 1441,
343+
},
344+
{
345+
"name": "refId",
346+
"default": None,
347+
},
348+
{
349+
"name": "builderOptions",
350+
"default": None
351+
}
352+
]
292353
elif datasource_type == "prometheus":
293354
query = {
294355
"datasource": {

0 commit comments

Comments
 (0)