Splunk Search

How to combine data from same field?

ag_yeck
Explorer

I am looking to chart a field that contains a request path but want to display and get a total count of all events that contain the root request path(a) and events that contain the root + <some guid>/contents.(b) The path is a field I manually extracted called "request_path_in_request"
Example of the path I want to combine in the cart:
(a)path=/v4/layers/asPlanted

(b)path=/v4/layers/asPlanted<some guid>/contents

Here is my Splunk query so far:
source="partners-api-ol" request_path_in_request="/v*" | timechart count by request_path_in_request useother=f limit=10

And here is how that field is getting charted:
graph.png

Is there a way to show only category of "/v4/layers/asPlanted" , but have the count be the total of all the events with that root path?

Labels (2)
0 Karma
1 Solution

yeahnah
Motivator

Hi @ag_yeck 

If I understand what you are trying to do correctly, you just need to define a new field (using a regex command for this is good) to group your results by in the timechart statement.

source="partners-api-ol" request_path_in_request="/v*" 
| rex field=request_path_in_request "(?<request_root_path>^(?:\/\w+){1,3})"
| timechart count BY request_root_path useother=f limit=10


The regex is pulling out the first / delimited segments, up to levels 3 deep, and assigning this the field name request_root_path.  This can then be used to group summarise the counts in timechart.

Hope this helps  

 

View solution in original post

yuanliu
SplunkTrust
SplunkTrust

This is a less expensive and more semantic method using split and mvindex.

source="partners-api-ol" request_path_in_request="/v*" | timechart count by request_path_in_request useother=f limit=10
| eval request_path_in_request = split(request_path_in_request, "/")
| eval rootpath = mvjoin(mvindex(request_path_in_request, 0,3), "/")

 

Tags (3)

ag_yeck
Explorer

@yuanliu  I like the idea of just using semantics to solve, but this did not change the visualization. Maybe I need to use "rootpath" on the "timechart" line?

0 Karma

yuanliu
SplunkTrust
SplunkTrust

Yes, that's the idea.  If you want to use request_path_in_request as you orginally do, you can do

| eval request_path_in_request = mvjoin(mvindex(request_path_in_request, 0,3), "/")

But doing so would be less semantic.  Personally, I often assign modified values back to original field name.  But that's only when the modification do not considerably alter the semantic meaning of the original field name. (I did use | eval request_path_in_request = split(request_path_in_request, "/") in my illustration.)

yeahnah
Motivator

Hi @ag_yeck 

If I understand what you are trying to do correctly, you just need to define a new field (using a regex command for this is good) to group your results by in the timechart statement.

source="partners-api-ol" request_path_in_request="/v*" 
| rex field=request_path_in_request "(?<request_root_path>^(?:\/\w+){1,3})"
| timechart count BY request_root_path useother=f limit=10


The regex is pulling out the first / delimited segments, up to levels 3 deep, and assigning this the field name request_root_path.  This can then be used to group summarise the counts in timechart.

Hope this helps  

 

ag_yeck
Explorer

Thank you @yeahnah , that worked! I am a Splunk noob so having the explanation after the solution is very helpful.

0 Karma
Get Updates on the Splunk Community!

Cloud Platform & Enterprise: Classic Dashboard Export Feature Deprecation

As of Splunk Cloud Platform 9.3.2408 and Splunk Enterprise 9.4, classic dashboard export features are now ...

Explore the Latest Educational Offerings from Splunk (November Releases)

At Splunk Education, we are committed to providing a robust learning experience for all users, regardless of ...

New This Month in Splunk Observability Cloud - Metrics Usage Analytics, Enhanced K8s ...

The latest enhancements across the Splunk Observability portfolio deliver greater flexibility, better data and ...