Splunk Search

How to evaluate if a value is in Seconds and only then convert to Miliseconds

TotallyJuvenile
Loves-to-Learn

I am trying to parse some data for API latency. I have a value for "elapsedTime" which spits that out. However if a request takes longer than 999ms, then it changes to reporting in seconds. So... the query below could return 999ms or 1.001s. What eval statement do I need here to parse the value of elapsedTime and if it contains "s" and not "ms",  then * 1000 to get a value in ms...

| NEED SOME EVAL HERE I GUESS | stats min(elapsedTime) as Fastest max(elapsedTime) as Slowest avg(elapsedTime) as "Average"

Labels (1)
0 Karma

bowesmana
SplunkTrust
SplunkTrust

Simple way is to first extract the numeric value and the time specifier, then use eval to do the test/calc

| rex field=elapsedTime "(?<timeValue>[\d\.]*)(?<timeSpecifier>(ms|s))"
| eval elapsedTime=if(timeSpecifier="ms", timeValue, timeValue*1000)

 

0 Karma
Get Updates on the Splunk Community!

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...

Cloud Monitoring Console - Unlocking Greater Visibility in SVC Usage Reporting

For Splunk Cloud customers, understanding and optimizing Splunk Virtual Compute (SVC) usage and resource ...

Automatic Discovery Part 3: Practical Use Cases

If you’ve enabled Automatic Discovery in your install of the Splunk Distribution of the OpenTelemetry ...