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-31886 LogAccess Trace/Span ID filtering #18680

Merged
Show file tree
Hide file tree
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
14 changes: 10 additions & 4 deletions esp/scm/ws_logaccess.ecm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ ESPenum LogAccessType : int
BySourceInstance(5, "BySourceInstance"),
BySourceNode(6, "BySourceNode"),
ByFieldName(7, "ByFieldName"),
ByPod(8, "ByPod")
ByPod(8, "ByPod"),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asselitx this PR adds a couple of entries in a number of ECM enumerations which I want to annotate w/ the appropriate interface version, but I found no mechanism to do so. Is there a way to declare the new entries to require at least client version 1.06+ ? Thanks.

ByTraceID(9, "ByTraceID"),
BySpanID(10, "BySpanID")
};

ESPenum LogAccessLogFormat : int
Expand Down Expand Up @@ -67,7 +69,9 @@ ESPenum LogColumnType : string
processid("processid"),
threadid("threadid"),
timestamp("timestamp"),
pod("pod")
pod("pod"),
traceid("traceid"),
spanid("spanid")
};

ESPenum LogColumnValueType : string
Expand Down Expand Up @@ -191,7 +195,9 @@ ESPenum SortColumType : int
BySourceInstance(5, "BySourceInstance"),
BySourceNode(6, "BySourceNode"),
ByFieldName(7, "ByFieldName"),
ByPod(8, "ByPod")
ByPod(8, "ByPod"),
ByTraceID(9, "ByTraceID"),
BySpanID(10, "BySpanID")
};

ESPStruct SortCondition
Expand Down Expand Up @@ -222,7 +228,7 @@ ESPResponse GetLogsResponse
[min_ver("1.02")] unsigned int TotalLogLinesAvailable;
};

ESPservice [auth_feature("WsLogAccess:READ"), version("1.05"), default_client_version("1.05"), exceptions_inline("xslt/exceptions.xslt")] ws_logaccess
ESPservice [auth_feature("WsLogAccess:READ"), version("1.06"), default_client_version("1.06"), exceptions_inline("xslt/exceptions.xslt")] ws_logaccess
{
ESPmethod GetLogAccessInfo(GetLogAccessInfoRequest, GetLogAccessInfoResponse);
ESPmethod GetLogs(GetLogsRequest, GetLogsResponse);
Expand Down
15 changes: 14 additions & 1 deletion esp/services/ws_logaccess/WsLogAccessService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,14 @@ ILogAccessFilter * buildLogFilterByFields(CLogAccessType searchByCategory, const
case CLogAccessType_BySourceNode:
{
return getHostLogAccessFilter(searchByValue);
break;
}
case CLogAccessType_ByTraceID:
{
return getTraceIDLogAccessFilter(searchByValue);
}
case CLogAccessType_BySpanID:
{
return getSpanIDLogAccessFilter(searchByValue);
}
case CLogAccessType_ByFieldName:
{
Expand Down Expand Up @@ -343,6 +350,12 @@ bool Cws_logaccessEx::onGetLogs(IEspContext &context, IEspGetLogsRequest &req, I
case CSortColumType_BySourceNode:
mappedField = LOGACCESS_MAPPEDFIELD_host;
break;
case CSortColumType_ByTraceID:
mappedField = LOGACCESS_MAPPEDFIELD_traceid;
break;
case CSortColumType_BySpanID:
mappedField = LOGACCESS_MAPPEDFIELD_spanid;
break;
case CSortColumType_ByFieldName:
if (isEmptyString(condition.getColumnName()))
throw makeStringExceptionV(-1, "WsLogAccess: SortByFieldName option requires ColumnName!");
Expand Down
10 changes: 10 additions & 0 deletions system/jlib/jlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3194,6 +3194,16 @@ ILogAccessFilter * getJobIDLogAccessFilter(const char * jobId)
return new FieldLogAccessFilter(jobId, LOGACCESS_FILTER_jobid);
}

ILogAccessFilter * getTraceIDLogAccessFilter(const char * traceId)
{
return new FieldLogAccessFilter(traceId, LOGACCESS_FILTER_trace);
}

ILogAccessFilter * getSpanIDLogAccessFilter(const char * spanId)
{
return new FieldLogAccessFilter(spanId, LOGACCESS_FILTER_span);
}

ILogAccessFilter * getColumnLogAccessFilter(const char * columnName, const char * value)
{
return new ColumnLogAccessFilter(columnName, value, LOGACCESS_FILTER_column);
Expand Down
14 changes: 14 additions & 0 deletions system/jlib/jlog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,8 @@ typedef enum
LOGACCESS_FILTER_host,
LOGACCESS_FILTER_column,
LOGACCESS_FILTER_pod,
LOGACCESS_FILTER_trace,
LOGACCESS_FILTER_span,
LOGACCESS_FILTER_unknown
} LogAccessFilterType;

Expand All @@ -1403,6 +1405,10 @@ inline const char * logAccessFilterTypeToString(LogAccessFilterType field)
return "instance";
case LOGACCESS_FILTER_host:
return "host";
case LOGACCESS_FILTER_trace:
return "trace";
case LOGACCESS_FILTER_span:
return "span";
case LOGACCESS_FILTER_or:
return "OR";
case LOGACCESS_FILTER_and:
Expand Down Expand Up @@ -1431,6 +1437,10 @@ inline unsigned logAccessFilterTypeFromName(char const * name)
return LOGACCESS_FILTER_pod;
if(strieq(name, "instance"))
return LOGACCESS_FILTER_instance;
if(strieq(name, "trace"))
return LOGACCESS_FILTER_trace;
if(strieq(name, "span"))
return LOGACCESS_FILTER_span;
if(strieq(name, "host"))
return LOGACCESS_FILTER_host;
if(strieq(name, "OR"))
Expand Down Expand Up @@ -1481,6 +1491,8 @@ enum LogAccessMappedField
LOGACCESS_MAPPEDFIELD_instance,
LOGACCESS_MAPPEDFIELD_pod,
LOGACCESS_MAPPEDFIELD_host,
LOGACCESS_MAPPEDFIELD_traceid,
LOGACCESS_MAPPEDFIELD_spanid,
LOGACCESS_MAPPEDFIELD_unmapped
};

Expand Down Expand Up @@ -1680,6 +1692,8 @@ extern jlib_decl ILogAccessFilter * getHostLogAccessFilter(const char * host);
extern jlib_decl ILogAccessFilter * getJobIDLogAccessFilter(const char * jobId);
extern jlib_decl ILogAccessFilter * getComponentLogAccessFilter(const char * component);
extern jlib_decl ILogAccessFilter * getPodLogAccessFilter(const char * podName);
extern jlib_decl ILogAccessFilter * getTraceIDLogAccessFilter(const char * traceId);
extern jlib_decl ILogAccessFilter * getSpanIDLogAccessFilter(const char * spanId);
extern jlib_decl ILogAccessFilter * getAudienceLogAccessFilter(MessageAudience audience);
extern jlib_decl ILogAccessFilter * getClassLogAccessFilter(LogMsgClass logclass);
extern jlib_decl ILogAccessFilter * getBinaryLogAccessFilter(ILogAccessFilter * arg1, ILogAccessFilter * arg2, LogAccessFilterType type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,38 @@ void AzureLogAnalyticsCurlClient::populateKQLQueryString(StringBuffer & queryStr
DBGLOG("%s: Searching log entries by class: '%s'...", COMPONENT_NAME, queryValue.str());
break;
}
case LOGACCESS_FILTER_trace:
{
if (m_traceSearchColName.isEmpty())
throw makeStringExceptionV(-1, "%s: 'Trace' log entry field not configured", COMPONENT_NAME);

queryField = m_traceSearchColName.str();

if (!m_traceIndexSearchPattern.isEmpty())
{
throwIfMultiIndexDetected(queryIndex.str(), m_traceIndexSearchPattern.str());
queryIndex = m_traceIndexSearchPattern.str();
}

DBGLOG("%s: Searching log entries by traceid: '%s'...", COMPONENT_NAME, queryValue.str());
break;
}
case LOGACCESS_FILTER_span:
{
if (m_spanSearchColName.isEmpty())
throw makeStringExceptionV(-1, "%s: 'Span' log entry field not configured", COMPONENT_NAME);

queryField = m_spanSearchColName.str();

if (!m_spanIndexSearchPattern.isEmpty())
{
throwIfMultiIndexDetected(queryIndex.str(), m_spanIndexSearchPattern.str());
queryIndex = m_spanIndexSearchPattern.str();
}

DBGLOG("%s: Searching log entries by spanid: '%s'...", COMPONENT_NAME, queryValue.str());
break;
}
case LOGACCESS_FILTER_audience:
{
if (m_audienceSearchColName.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ class AzureLogAnalyticsCurlClient : public CInterfaceOf<IRemoteLogAccess>

StringBuffer m_componentsLookupKeyColumn;
StringBuffer m_instanceLookupKeyColumn;

StringBuffer m_spanSearchColName;
StringBuffer m_spanIndexSearchPattern;

StringBuffer m_traceSearchColName;
StringBuffer m_traceIndexSearchPattern;

bool targetIsContainerLogV2 = false;

public:
Expand Down
40 changes: 40 additions & 0 deletions system/logaccess/ElasticStack/ElasticStackLogAccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,12 @@ void ElasticStackLogAccess::esSearchMetaData(std::string & search, const LogAcce
case LOGACCESS_MAPPEDFIELD_host:
sortByFieldName = m_hostSearchColName.str();
break;
case LOGACCESS_MAPPEDFIELD_traceid:
sortByFieldName = m_traceSearchColName.str();
break;
case LOGACCESS_MAPPEDFIELD_spanid:
sortByFieldName = m_spanSearchColName.str();
break;
case LOGACCESS_MAPPEDFIELD_unmapped:
default:
sortByFieldName = condition.fieldName.get();
Expand Down Expand Up @@ -630,6 +636,40 @@ void ElasticStackLogAccess::populateESQueryQueryString(std::string & queryString
DBGLOG("%s: Searching log entries by jobid: '%s'...", COMPONENT_NAME, queryValue.str() );
break;
}
case LOGACCESS_FILTER_trace:
{
if (m_traceSearchColName.isEmpty())
throw makeStringExceptionV(-1, "%s: 'traceid' log entry field not configured", COMPONENT_NAME);

queryField = m_traceSearchColName.str();

if (!m_traceIndexSearchPattern.isEmpty())
{
if (!queryIndex.empty() && queryIndex != m_traceIndexSearchPattern.str())
throw makeStringExceptionV(-1, "%s: Multi-index query not supported: '%s' - '%s'", COMPONENT_NAME, queryIndex.c_str(), m_workunitIndexSearchPattern.str());
queryIndex = m_traceIndexSearchPattern;
}

DBGLOG("%s: Searching log entries by traceid: '%s'...", COMPONENT_NAME, queryValue.str() );
break;
}
case LOGACCESS_FILTER_span:
{
if (m_spanSearchColName.isEmpty())
throw makeStringExceptionV(-1, "%s: 'spanid' log entry field not configured", COMPONENT_NAME);

queryField = m_spanSearchColName.str();

if (!m_spanIndexSearchPattern.isEmpty())
{
if (!queryIndex.empty() && queryIndex != m_spanIndexSearchPattern.str())
throw makeStringExceptionV(-1, "%s: Multi-index query not supported: '%s' - '%s'", COMPONENT_NAME, queryIndex.c_str(), m_workunitIndexSearchPattern.str());
queryIndex = m_spanIndexSearchPattern;
}

DBGLOG("%s: Searchingsort log entries by spanid: '%s'...", COMPONENT_NAME, queryValue.str() );
break;
}
case LOGACCESS_FILTER_class:
{
if (m_classSearchColName.isEmpty())
Expand Down
6 changes: 6 additions & 0 deletions system/logaccess/ElasticStack/ElasticStackLogAccess.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ class ElasticStackLogAccess : public CInterfaceOf<IRemoteLogAccess>
StringBuffer m_hostSearchColName;
StringBuffer m_hostIndexSearchPattern;

StringBuffer m_spanSearchColName;
StringBuffer m_spanIndexSearchPattern;

StringBuffer m_traceSearchColName;
StringBuffer m_traceIndexSearchPattern;

StringBuffer m_defaultDocType; //default doc type to query

elasticlient::Client m_esClient;
Expand Down
Loading