Hi
I am building dashboard for UPS monitoring and i would like to convert a specific metric which is battery age.
Which give us some information about last battery changed however i would like to see the result in month , days like below
Expected outcome - 1 month 20 days.
current outcome below image
Spl query -
index="ups" indexed_is_service_aggregate=1 kpi=BatteryAge| lookup service_kpi_lookup _key as itsi_service_id OUTPUT title AS service_name | search service_name="MainUPS" |stats latest(alert_value) AS BatteryAge
Can anyone help me on this
What unit of time is your BatteryAge in, seconds, hours, days?
How long is a month?
If your current day is the 5th of the month and the age equates to 40 days, what result would you expect?
Hi Mus
Thanks for help
However when i run the query i am getting an error message
Error in 'makeresults' command: This command must be the first command of a search.
ah yes, this example needs to run on its own and will create sample events. but see my other reply this needs more logic
Hi there,
try this :
| makeresults | eval alert_value=1060, BatteryAge=strftime(alert_value, "%m months %d days")
this will return:
but not sure you then can use it in a single value panel. Just give it a try.
Hope this helps ...
Cheers, MuS
Update:
This is based on the simple assumption every month has 4 weeks, because I'm not a mathematician nor scientist 😉
| makeresults | eval alert_value=1060, secs=alert_value*86400, months=round(secs/604800), days=round(alert_value - ((secs- (secs/604800)) / 60 /60 /24)) , alert_value = months ." months ". days ." days"
Just noticed that will not work 🙄 will ned some loop hooping to get months and then days ....