diff --git a/system/logaccess/Grafana/CurlClient/GrafanaCurlClient.cpp b/system/logaccess/Grafana/CurlClient/GrafanaCurlClient.cpp index 5ada0237838..4cbd356f096 100644 --- a/system/logaccess/Grafana/CurlClient/GrafanaCurlClient.cpp +++ b/system/logaccess/Grafana/CurlClient/GrafanaCurlClient.cpp @@ -547,6 +547,9 @@ const char * sortByDirection(SortByDirection direction) */ bool GrafanaLogAccessCurlClient::fetchLog(LogQueryResultDetails & resultDetails, const LogAccessConditions & options, StringBuffer & returnbuf, LogAccessLogFormat format) { + if (m_dataSourcesAPIURI.isEmpty()) + throw makeStringExceptionV(-1, "%s: Cannot query because Grafana datasource was not established, check logaccess configuration!", COMPONENT_NAME); + try { resultDetails.totalReceived = 0; @@ -729,12 +732,30 @@ GrafanaLogAccessCurlClient::GrafanaLogAccessCurlClient(IPropertyTree & logAccess m_grafanaPassword.set(logAccessPluginConfig.queryProp("connection/@password")); } - //this is very important, without this, we can't target the correct datasource - fetchDatasourceByName(m_targetDataSource.name.get()); + try + { + //this is very important, without this, we can't target the correct datasource + fetchDatasourceByName(m_targetDataSource.name.get()); + } + catch(IException * e) + { + StringBuffer description; + OERRLOG("%s: Exception fetching Loki/Grafana datasource!!: (%d) - %s", COMPONENT_NAME, e->errorCode(), e->errorMessage(description).str()); + e->Release(); + } - std::string availableLabels; - fetchLabels(availableLabels); - DBGLOG("%s: Available labels on target loki/grafana: %s", COMPONENT_NAME, availableLabels.c_str()); + try + { + std::string availableLabels; + fetchLabels(availableLabels); + DBGLOG("%s: Available labels on target loki/grafana: %s", COMPONENT_NAME, availableLabels.c_str()); + } + catch(IException * e) + { + StringBuffer description; + OERRLOG("%s: Exception fetching available labels: (%d) - %s", COMPONENT_NAME, e->errorCode(), e->errorMessage(description).str()); + e->Release(); + } m_expectedLogFormat = defaultExpectedLogFormat; if (logAccessPluginConfig.hasProp("logFormat/@type"))