Skip to content

Commit f151635

Browse files
peekjef72amotl
authored andcommitted
dsquery: loki results depend on grafana version
1 parent ecc1114 commit f151635

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

grafana_client/elements/datasource.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
logger = logging.getLogger(__name__)
1717

1818
VERSION_9 = LooseVersion("9")
19+
VERSION_7 = LooseVersion("7")
1920
VERBOSE = False
2021

2122

@@ -533,9 +534,14 @@ def health_check(self, datasource: Union[DatasourceIdentifier, Dict]) -> Datasou
533534
message = f"Invalid response. {reason}"
534535

535536
elif datasource_type == "loki":
536-
if "status" in response and response["status"] == "success":
537-
message = "Success"
538-
success = True
537+
if self.api.version:
538+
if LooseVersion(self.api.version) == VERSION_7:
539+
if "status" in response and response["status"] == "success":
540+
message = "Success"
541+
success = True
542+
elif "results" in response and "test" in response["results"]:
543+
message = "Success"
544+
success = True
539545
else:
540546
message = response["message"]
541547

0 commit comments

Comments
 (0)