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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Monitoring AI Agents with Splunk Observability Cloud

Let’s say I’m running a travel planning AI app in production. A user asks for three concise hotel options in ...

[Puzzles] Solve, Learn, Repeat: Tiling

This puzzle (first published here) is based on finding groups of tessellated tiles (inspired by floor tiles I ...

SOK it to Me: Top 3 Benefits of Using Splunk Operator on Kubernetes that’ll Make ...

    Thursday, July 9, 2026  |  11:00AM–12:00PM PDT Duration: 1 hour (includes Q&A) Managing can feel like a ...