Rounding/abbreviating indicator display to a predefined length?

Travis Rogers
ServiceNow Employee
ServiceNow Employee

Hey folks - I'm working on a special project for a blog post I was hoping to post here, but I ran into a speed bump. I'm making an indicator that trends a database size. The source data's size value comes in as MB and is typically 6-7 digits, tho it can be more or less. So for example if the source value is 123,456 it represents 123,456 MB (aka 123 GB or 0.12 TB)

 

In the indicator, I want to always display the result as abbreviated/rounded to the nearest TB - For example, 55,123,456 would display as 55.12TB. Thus, I need to somehow force rounding/abbreviation logic so that any value of 6 figures is 0.XX TB, any value of 7 figures is X.XX TB, and any value of 8 figures is XX.XX TB, etc. I've already created the custom TB unit, which you'll applied below.

 

Issue: The default abbreviation doesn't play nice for this use case. For example, here is the indicator with no abbreviation applied:

TravisRogers_0-1705780929540.pngTravisRogers_1-1705780952422.png

Despite the shown unit of TB, this is clearly showing as MB still. This is to be expected because we haven't abbreviated yet. 

 

Here's that same indicator with the abbreviation toggle turned on: 

TravisRogers_2-1705781035710.png

As you can see, the value drops to 3 whole numbers from 6, and it adds a "K" at the end which I obviously wouldn't want in my situation. Its essentially showing us "498.01 GB", which wasn't my goal. 

 

So - How can I round the value to the nearest TB and remove the abbreviation letter (K/M/G) from its display value? 

My best guess is either somehow scripting the indicator's display behavior itself (probably ideal?) or running some kind of logic to convert the MB value to a shortened TB value when the PA collector jobs - which would ultimately store a truncated value in the score's collection history.  In a perfect world the indicator would display the truncated/abbreviated value on a dashboard, but we could still store the full 6-8 digit value in the indicator's score history for precision sake. Or, maybe we can overwrite the OOB abbreviation behavior for this use case? This is my first time making an indicator, and these approaches are both way above my head in terms of execution. 

 

The other issue is that if using the abbreviation feature the indicator would display a value of 55.12 TB on the dashboard view, but if we drill into that indicator for the full PA experience, I believe we'd see it displayed as 55,123,456 TB, which isn't correct as the unit would need to change to MB when viewed in its entirety..

 

The ultimate goal of the blog post is to help customers trend their ServiceNow instance size, not just see a one time snapshot of it in the form of a typical report widget. This project was inspired by a customer's question to me this week and is an extension of @tiagomacul's post here, which was super helpful in pointing me to the source table for this data. 

 

Thanks in advance!

Travis

1 REPLY 1

Tricia Cornish
ServiceNow Employee
ServiceNow Employee

@Travis Rogers 

One option is to create a formula indicator for the calculation. I added my units to pa_units.LIST (so I could identify MB, TB, whatever) - that's just the identifier. Your automated indicator unit size is MB and that will have a k (based on the number format, but that will be behind the scenese)
In the formula indicator, the unit is TB.
Call the original automatic indicator and multiply it by .000001:

TriciaCornish_0-1706545477367.png