Skip to content

Commit 78f9844

Browse files
peekjef72amotl
authored andcommitted
dsquery: fix influxdb flux smartquery model
1 parent 648e957 commit 78f9844

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

grafana_client/knowledge.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,22 @@ def query_factory(datasource, model: Optional[dict]) -> Union[Dict, str]:
183183
request["data"] = query
184184

185185
elif dialect == "Flux":
186-
query.update(
187-
{
188-
# "intervalMs": 60000,
189-
"maxDataPoints": 1,
190-
"query": expression,
191-
}
192-
)
193-
request["data"] = query
186+
187+
query = {
188+
"datasource": {
189+
"type": datasource["type"],
190+
"uid": datasource.get("uid"),
191+
},
192+
"datasourceId": datasource.get("id"),
193+
# "exemplar": False,
194+
"query": expression,
195+
}
196+
197+
attrs = [
198+
{ "name": "intervalMs", "default": 15000, },
199+
{ "name": "maxDataPoints", "default": None, },
200+
{ "name": "refId", "default": "test", },
201+
]
194202
else:
195203
raise KeyError(f"InfluxDB dialect '{dialect}' unknown")
196204

@@ -283,7 +291,7 @@ def query_factory(datasource, model: Optional[dict]) -> Union[Dict, str]:
283291
else:
284292
raise NotImplementedError(f"Unknown data source type: {datasource_type}")
285293

286-
if attrs is not None:
294+
if attrs is not None and query is not None and isinstance(query, dict):
287295
for attr in attrs:
288296
value = attr["default"]
289297
if attr["name"] in model:

0 commit comments

Comments
 (0)