Splunk Search

How do I convert milliseconds to seconds on stats output?

raindrop18
Communicator

I have this query and I'm trying to convert the response time from milliseconds to seconds but it's not working. What did I miss?

sourcetype="imetrics" name=http*://*  | regex name!="http*://.*\d+$" |  stats count by name,data.avg_response_time_ms,data.avg_error_rate  | eval "data.avg_response_time_ms(ms)"='data.avg_response_time_ms(ms)'/1000 |sort -data.avg_response_time_ms

Note = the milliseconds written like this on the logs "1660.9425"

thanks.

Tags (1)
0 Karma
1 Solution

Vijeta
Influencer

Try renaming the response time field,

sourcetype="imetrics" name=http*://*  | regex name!="http*://.*\d+$" |  rename "data.avg_response_time_ms" as avg_response_time , "data.avg_error_rate" as avg_error_rate |stats count by name,avg_response_time ,avg_error_rate  | eval avg_response_time_sec=avg_response_time/1000 |sort -avg_response_time_sec

View solution in original post

Vijeta
Influencer

Try renaming the response time field,

sourcetype="imetrics" name=http*://*  | regex name!="http*://.*\d+$" |  rename "data.avg_response_time_ms" as avg_response_time , "data.avg_error_rate" as avg_error_rate |stats count by name,avg_response_time ,avg_error_rate  | eval avg_response_time_sec=avg_response_time/1000 |sort -avg_response_time_sec
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...