Splunk Search

Extract values bucketed by time

varsuvius
New Member

Hello,

I have a bucketed chart in this format:

alt text

Is it possible to calculate the geometric mean of the values in each timestamp and add it to another field??

Tags (1)
0 Karma
1 Solution

sundareshr
Legend

Try this

.... | mvexpand solrTime | eval natural_logs=ln(solrTime) | stats values(solrTime) as solrTime mean(natural_logs) as log_mean by _time | eval geometric_mean = exp(log_mean)

Got this from this great post by @aljohnson

View solution in original post

0 Karma

sundareshr
Legend

Try this

.... | mvexpand solrTime | eval natural_logs=ln(solrTime) | stats values(solrTime) as solrTime mean(natural_logs) as log_mean by _time | eval geometric_mean = exp(log_mean)

Got this from this great post by @aljohnson

0 Karma

varsuvius
New Member

Did not work.

I tried this command:

  • | rex field=_raw ".*Solr Time: (?\d+)" | mvexpand solrTime | eval natural_log=ln(solrTime) | bucket span=10m _time | stats values(solrTime) as solrTime mean(natural_logs) as log_mean by _time | eval geometric_mean = exp(log_mean)
0 Karma

sundareshr
Legend

I don't believe you need the rex command. Add this to the query that resulted in the table you have in your screenshot. Make sure the table has two columns _time and solrTime

0 Karma

varsuvius
New Member

The query between --- is the initial one that generates that chart.

--- * | rex field=_raw ".*Solr Time: (?\d+)" | bucket span=10m _time | chart values(solrTime) by _time --- | mvexpand solrTime | eval natural_log=ln(solrTime) | stats values(solrTime) as solrTime mean(natural_logs) as log_mean by _time | eval geometric_mean = exp(log_mean)

After that, the results are returning only the timestamp.

0 Karma

sundareshr
Legend

Try this

---  | rex field=_raw ".*Solr Time: (?\d+)" | bucket span=10m _time | chart values(solrTime) as solrTime by _time | mvexpand solrTime | eval natural_log=ln(solrTime) | stats values(solrTime) as solrTime mean(natural_logs) as log_mean by _time | eval geometric_mean = exp(log_mean)
0 Karma

varsuvius
New Member

Still not working.

0 Karma

sundareshr
Legend

Try this. Fixed typo

---  | rex field=_raw ".*Solr Time: (?\d+)" | bucket span=10m _time | chart values(solrTime) as solrTime by _time | mvexpand solrTime | eval natural_logs=ln(solrTime) | stats values(solrTime) as solrTime mean(natural_logs) as log_mean by _time | eval geometric_mean = exp(log_mean)

If this doesn't work, try taking out one segment at a time to see where it stops working.

0 Karma

varsuvius
New Member

It's working now. Thanks a lot for your help. 😄

0 Karma
Get Updates on the Splunk Community!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...