Skip to content

Commit

Permalink
Data Source API: Add support for Amazon Redshift and Clickhouse (#166)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Pfannschmidt <[email protected]>
  • Loading branch information
amotl and lpfann authored Mar 29, 2024
1 parent 1410eb1 commit f091384
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
endpoints, and by adding missing ``move_folder``. Thanks, @grafuls.
* Service Accounts: Unlock endpoint to update service account by id.
Thanks, @einar-lanfranco.
* Data Source API: Add support for Amazon Redshift and Clickhouse.
Thanks, @lpfann and @mysuperai.

[Niquests]: https://niquests.readthedocs.io/
[Riquests]: https://requests.readthedocs.io/
Expand Down
61 changes: 61 additions & 0 deletions grafana_client/knowledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,68 @@ def query_factory(datasource, model: Optional[dict] = None, expression: Optional
"default": None,
},
]
elif datasource_type == "grafana-redshift-datasource":
query = {
"datasource": {
"type": datasource["type"],
"uid": datasource.get("uid"),
},
"datasourceId": datasource.get("id"),
"rawSQL": expression,
}

attrs = [
{
"name": "format",
"default": 0,
"choices": [0, 1],
},
{
"name": "intervalMs",
"default": 30000,
},
{
"name": "maxDataPoints",
"default": 1441,
},
{
"name": "refId",
"default": None,
},
]
elif datasource_type == "grafana-clickhouse-datasource":
query = {
"datasource": {
"type": datasource["type"],
"uid": datasource.get("uid"),
},
"datasourceId": datasource.get("id"),
"rawSql": expression,
}

attrs = [
{
"name": "format",
"default": "0",
"choices": [0, 1],
},
{
"name": "intervalMs",
"default": 30000,
},
{
"name": "maxDataPoints",
"default": 1441,
},
{
"name": "refId",
"default": None,
},
{
"name": "builderOptions",
"default": None
}
]
elif datasource_type == "prometheus":
query = {
"datasource": {
Expand Down

0 comments on commit f091384

Please sign in to comment.