Splunk Search

Add fonction AVG, STDEV and eval command to contingency command

yoan
Explorer

Hello,

I have an excel file like this :

yoan_0-1622099373288.png

And I wanna do this on splunk, but I can't / don't know how to do it

My request :

 

index=centreon host="xxxxxx"
| bucket _time span=1d
| convert ctime(_time) AS date timeformat="%Y/%m/%d"
| contingency host date usetotal=false
| appendcols
    [search index=centreon host="xxxx"
| bucket _time span=1d
| convert ctime(_time) AS date timeformat="%Y/%m/%d"
| stats avg(_raw) AS AVG by host
| stats stdev(_raw) AS STDEV by host
| eval ratio=(stdev/avg)
    | fields avg,stdev,ratio]

 

yoan_1-1622105085153.png

I'm sure my research is bad, someone could help me ?

Thank's

Labels (3)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Use caution with the appendcols command.  It matches events without regard for field values so if the two searches do not return similar lists of events then the results of appendcols will be unexpected.  I suggest using append and then regrouping the results using stats.

Also, consecutive stats commands often will return unexpected results if they work at all.  That's because stats is a transforming command so the second stats doesn't see the same data the first one saw.

Finally, make sure the _raw field contains a single numeric field before trying to use the avg or stdev function on it.

See if this helps.

index=centreon host="xxxxxx"
| bucket _time span=1d
| convert ctime(_time) AS date timeformat="%Y/%m/%d"
| contingency host date usetotal=false
| append
  [search index=centreon host="xxxx"
  | bucket _time span=1d
  | convert ctime(_time) AS date timeformat="%Y/%m/%d"
  | stats avg(_raw) AS AVG, stdev(_raw) AS STDEV by host
  | eval ratio=(stdev/avg)
  | fields host,date,avg,stdev,ratio]
| stats values(*) as * by host,date

 

---
If this reply helps you, Karma would be appreciated.
0 Karma

yoan
Explorer

Hello,

 

Thank's for your proposal, but she didn't work.

 

I have no retun resut, but if i delete the last command "

stats values(*) as * by host,date

 

I have the contingency command result

Tags (1)
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...