Hello,
I'm struggling to convert two status codes (200 and 400) from ms to secs and display the values in a line chart.
tmdEvntMs is the API response time in ms, and httpStatus is my status codes.
I tried using foreach, and it just converts the response time back to ms.
timechart span=6h avg(tmdEvntMs) AS avg_response by httpStatus
| foreach * [eval avg_response=round(avg_response/1000, 2)]
Any suggestions would be greatly appreciated.
Thank you
Why don't you convert the milliseconds to seconds before running the timechart?
For example:
| eval tmdEvntSec=ROUND(tmdEvntMs/1000, 4)
| timechart span=6h avg(tmdEvntSec) AS avg_response by httpStatus
The string is not converting the response time (tmdEvntMs) from milliseconds to seconds.
I used the foreach command because, I couldn't get the response time(tmdEvntMs) to convert from ms to secs. It would return the 6 hour average for both httpstatus codes (200 and 400) but it was showing ms.
| timechart span=6h avg(tmdEvntMs) AS avg_response by httpStatus
| eval avg_response=round(avg_response/1000, 2)
When I remove by httpStatus, it converts the response from ms to secs.
| timechart span=6h avg(tmdEvntMs) AS avg_response
| eval avg_response=round(avg_response/1000, 2)
I'm apologize if I was not clear, I would like to show the 6 hour average for both status codes (200 and 400).
Why don't you convert the milliseconds to seconds before running the timechart?
For example:
| eval tmdEvntSec=ROUND(tmdEvntMs/1000, 4)
| timechart span=6h avg(tmdEvntSec) AS avg_response by httpStatus
This worked.. Thank you!!
If your problem is resolved, then please click the "Accept as Solution" button to help future readers.
Since there's only one avg_response field there's no need for the foreach command. Just use an eval to make the desired conversion.
timechart span=6h avg(tmdEvntMs) AS avg_response by httpStatus
| eval avg_response=round(avg_response/1000, 2)