Dashboards & Visualizations

How to present three different search stats in one single dashboard?

pavanae
Builder

Hi, The following is my Scenario

I have the following 3 different searches as follows

search 1 :- index="htc" sessionId="*cap" host="*" | stats values(host) as hosts, dc(host) as hostcount, values(source) as sources by sessionId | where hostcount > 1 | stats count as sessionId

search 2 :- index="htc" sessionId="*com" host="*" | stats values(host) as hosts, dc(host) as hostcount, values(source) as sources by sessionId | where hostcount > 1 | stats count as sessionId

search 3 :- index="htc" sessionId="*mob" host="*" | stats values(host) as hosts, dc(host) as hostcount, values(source) as sources by sessionId | where hostcount > 1 | stats count as sessionId

Now I want to display all the stats count in a Dashboard with different columns like count of search 1 as "cap" , search 2 as "com" and search 3 as "mob"

If you can observe all the searches are same except for the sessionid ending string.

I had already written the following search but it was taking too much time and also not working for hourly time chart view. Could anyone modify the search?

index="htc" sessionId="*cap" host="*" | stats values(host) as hosts, dc(host) as hostcount, values(source) as sources by sessionId | where hostcount > 1 | stats count as Cap | appendcols [search index="htc" sessionId="*com" host="*" | stats values(host) as hosts, dc(host) as hostcount, values(source) as sources by sessionId | where hostcount > 1 | stats count as Commerce ] | appendcols [search index="htc" sessionId="*mob" host="*" | stats values(host) as hosts, dc(host) as hostcount, values(source) as sources by sessionId | where hostcount > 1 | stats count as Mobile ]

Thanks in Advance

0 Karma
1 Solution

alacercogitatus
SplunkTrust
SplunkTrust

This looks a good use of the case operator.

index=htc sessionId=*cap OR sessionId=*com OR sessionId=*mob | eval report_key = case(match(sessionId,"cap"),"Cap",match(sessionId,"com"),"Commerce",match(sessionId,"mob"),"Mobile",1=1,"Unknown") | stats values(host) as hosts dc(host) as hostcount values(source) as sources by report_key | where hostcount > 1

Note that the final expression in the case statement is 1=1: this is a generic "catch all" for anything that doesn't match the other three conditions.

View solution in original post

alacercogitatus
SplunkTrust
SplunkTrust

This looks a good use of the case operator.

index=htc sessionId=*cap OR sessionId=*com OR sessionId=*mob | eval report_key = case(match(sessionId,"cap"),"Cap",match(sessionId,"com"),"Commerce",match(sessionId,"mob"),"Mobile",1=1,"Unknown") | stats values(host) as hosts dc(host) as hostcount values(source) as sources by report_key | where hostcount > 1

Note that the final expression in the case statement is 1=1: this is a generic "catch all" for anything that doesn't match the other three conditions.

Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...