Splunk Search

How do I extract the string which contains time from my data, convert it to milliseconds, and display in a chart?

janibhasha
New Member

I have data like below which contains time taken for service call in regular string format.

Sample Data :

Time Taken[0.122381]
Time Taken[0.122381]
Time Taken[0.122381]

How can i extract

  1. String in between [ ]
  2. Convert this to Milliseconds
  3. Present it in a chart

Thanks in advance

0 Karma

gokadroid
Motivator

you can try this assuming this data is in seconds.

your query to return events
| rex "(?<pre>[^\[]+)\[(?<number>[^\]]+)\]"
| eval millis=tonumber(number)*1000
| timechart avg(millis)

Use avg(millis), max(millis) or min(millis) depending on what you want to chart. If you just want to tabulate it use |table millis

0 Karma

Richfez
SplunkTrust
SplunkTrust

Or even all of the above:

... | timechart max(millis), avg(millis), min(millis)

Then your visualization should have all three.

And if you'd like to rename them use AS:

... | timechart max(millis) AS Max, avg(millis) AS Average, min(millis) AS Min

Happy Splunking!
-Rich

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 ...