diff --git a/CHANGELOG.md b/CHANGELOG.md index 4db735b..4479749 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ * Improve data source API by adding a data source health-check probe. * Support data source health check endpoint introduced with Grafana 9. Thanks, @jangaraj! +* Add gracefulness when using the new data source health check endpoint. + Apparently, this is not implemented thoroughly for all data source types yet. ## 2.3.0 (2022-05-26) diff --git a/examples/datasource-health.py b/examples/datasource-health.py index 81b4203..dd7daa3 100644 --- a/examples/datasource-health.py +++ b/examples/datasource-health.py @@ -73,13 +73,16 @@ def health_inquiry(grafana: GrafanaApi, datasource: DatasourceModel, grafana_ver datasource = grafana.datasource.get(datasource_id=datasource_id) # Check data source health. + health = None if True or grafana_version and grafana_version >= VERSION_9: try: health = grafana.datasource.health(datasource_uid=datasource_uid) except GrafanaClientError as ex: - logger.error(f"Data source health check for uid={datasource_uid} failed: {ex}. Response: {ex.response}") - raise - else: + logger.warning(f"Native data source health check for uid={datasource_uid} failed: {ex}. Response: {ex.response}") + if ex.status_code != 404: + raise + + if health is None: health = grafana.datasource.health_check(datasource=datasource) # Delete data source again.