Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-32208 Properly report Grafana LogAccess Config problem #18853

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions system/logaccess/Grafana/CurlClient/GrafanaCurlClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"))
Expand Down
Loading