Splunk Search

Show max ,minimum and average values from a pool of host machines on a chart

jbassi1
New Member

I have the follow search which shows the call count being made to a number of hosts every 15mins

"cs_dataowner_id="ICTO-18172" cs_stage="PROD" |search source="dqs"| search "FetchTradesHistoric invoked"|timechart count as calls by host span=15m"

I want to show on a chart for each 15 min span the host which has had the max count, the minimum count and the overall average count

The purpose being it gives the user an idea of what host is being over and under utilized and allows it compare it against the average

Any ideas how I can incorporate that in a chart ?

0 Karma

jbassi1
New Member

Thanks for the response

I'm not sure whether it down to the version of Splunk I am using , which is Splunk Version ...6.6.6.1, but the below line does not return any results

cs_dataowner_id="ICTO-18172" cs_stage="PROD" source="dqs" "FetchTradesHistoric invoked" | timechart span=15m count as calls by host

I have to use my original format below to get a resultset which it does for each host
cs_dataowner_id="ICTO-18172" cs_stage="PROD" |search source="dqs"| search "FetchTradesHistoric invoked"|timechart span=15m count as calls by host| eventstats max(calls) as max_calls min(calls) as min_calls avg(calls) as average_calls

To the above search if I then try to append the below again get no results is this a version or format issue ?
"| stats values(max_calls) as max_calls, values(min_calls) as min_calls, values(average_calls) as average_calls"

If I do the full search with the eval function included I get the syntax error below
"⚠ Error in 'stats' command: The eval expression for dynamic field 'eval(if(calls==max_calls), host, NULL)' is invalid. Error='The operator at ', host, NULL' is invalid.' "

0 Karma

to4kawa
Ultra Champion
cs_dataowner_id="ICTO-18172" cs_stage="PROD" source="dqs" "FetchTradesHistoric invoked"
| timechart span=15m count as calls by host
| eventstats max(calls) as max_calls min(calls) as min_calls avg(calls) as average_calls
| stats values(max_calls) as max_calls, values(min_calls) as min_calls, values(average_calls) as average_calls
 ,values(eval(if(calls==max_calls), host, NULL)) as max_calls_host
 ,values(eval(if(calls==min_calls), host, NULL)) as min_calls_host
 ,values(eval(if(calls > average_calls), host, NULL)) as over_avg_host
 ,values(eval(if(calls < average_calls), host, NULL)) as under_avg_host

Hi,
After timechart, calculate the maximum value etc. with eventstats and display it with stats.

How about this?

Sorry, The query was wrong.

| makeresults count=10
| streamstats count
| eval host="host_".count
| eval calls=random() % 100
`comment("This is dummy data")`
| eventstats max(calls) as max_calls min(calls) as min_calls avg(calls) as average_calls
`comment("Change stats query")`
| stats values(max_calls) as max_calls, values(min_calls) as min_calls, values(average_calls) as average_calls
  ,values(eval(if(calls==max_calls, host, NULL))) as max_calls_host
  ,values(eval(if(calls==min_calls, host, NULL))) as min_calls_host
  ,values(eval(if(calls > average_calls, host, NULL))) as over_avg_host
  ,values(eval(if(calls < average_calls, host, NULL))) as under_avg_host

I think this is all right.

0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In January, the Splunk Threat Research Team had one release of new security content via the Splunk ES Content ...

Expert Tips from Splunk Professional Services, Ensuring Compliance, and More New ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Observability Release Update: AI Assistant, AppD + Observability Cloud Integrations & ...

This month’s releases across the Splunk Observability portfolio deliver earlier detection and faster ...