Splunk Search

Improve search reducing appendcols

internet_team
Explorer

Hello,

is there any way to improve this search by reducing appendcols number ? Source is the same, only download_time average should be calculate according url string regex.

Current search :

sourcetype="my_source_type" source="frt" url="/F-" | timechart avg(download_time) as "Family" | appendcols [search

sourcetype="my_source_type" source="*frt
" url="/P-" | timechart avg(download_time) as "Product"] | appendcols [search

sourcetype="my_source_type" source="*frt
" url="/C-" | timechart avg(download_time) as "Category"] | appendcols [search

sourcetype="my_source_type" source="*frt
" url="/main" | timechart avg(download_time) as "Homepage"]

Thanks,

Tags (2)
0 Karma

wpreston
Motivator

Sure, I think you can eliminate appendcols altogether in this search. Try something like this:

sourcetype="my_source_type" source="frt" (url="/F-" OR url="/P-" OR url="/C-*" OR url="/main") | eval Identifier=case(url == "/F-", "Family",url == "/P-", "Product",url == "/C-*", "Category", url == "/main", "Homepage") | timechart avg(download_time) by Identifier
0 Karma

gfuente
Motivator

Hello

It would be nice to have some sample events, but with the information you had provided try this:

sourcetype="my_source_type" source="frt" (url="/F-" OR  url="/P-" OR url="/C-*" OR url="/main"  ) | rex field="url" "\/(?<group>main|(C|P|F))" | timechart avg(download_time) by group

You could rename the outfput fields if needed.

Regards

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...