Metrics on non-Task tables - ServiceNow Community
Mark Roethof
Tera Patron
Tera Patron

Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Hi there,

 

Where it comes down to advanced reporting, quickly Performance Analytics jumps in mind. Though ServiceNow out-of-the-box also comes with this nice - free - functionality called Metrics. You might even have heard of it or are working with it, nice! Though, why isn't it working for all tables on your instance? For example Approvals [sysapproval_approver]?


Metrics

A short recap on Metrics can be found on the Docs:
"A metric measures and evaluates the effectiveness of IT service management processes.

For example, a metric could measure the effectiveness of the incident resolution process by calculating how long it takes to resolve an incident."

 

The Docs page does specifically mention IT. Though actually, who cares 🙂 We can use it for any process!


Task extended

Out-of-the-box, the working of Metrics is limited to Task extended tables. Out-of-the-box also several Metric Instances are active and collect Metric Definitions. You might not even be aware of this! Navigate to "Metrics > Definitions" to see what already has been captured on your instance out-of-the-box.

 

While configuring and testing new Metric Instances, you will eventually notice that you can select (almost) every table. Though, on for example Approvals it actually doesn't work [sysapproval_approver]?

Again from the Docs:
"Note: In the base system, metrics are configured to work on the task table only."

Applying Metrics on non-Task extended tables

So how can we use Metrics on non-Task extended tables? Like the Approvals [sysapproval_approver] table for example?

 

An important artifact behind the Metrics functionality is a Business Rule called "metrics events". This Business Rule runs on table Task [task]. If you are after applying Metrics on a non-Task extended table, you can actually simply duplicate this Business Rule!

 

find_real_file.png

 

For our example of the Approvals table, simply duplicate the "metrics events" Business Rule and set the table to Approval [sysapproval_approver].


If you are after having metics on for example the Server [cmdb_ci_server] table, you could again duplicate the "metrics events" Business Rule and set the table to Server [cmdb_ci_server] or even Configuration item [cmdb_ci] so all Configuration item extended tables can make use of Metrics as well.


Result

You could already setup Metric Instances to (almost) every table. Though while testing, Metric Definitions would not be captured for non-Task extended tables. After duplicating the "metrics events" Business Rule, Metric Definitions now will automatically be captured for the table (and extended tables) you selected.

---

And that's it actually. Hope you like it. If any questions or remarks, let me know!

 

C

If this content helped you, I would appreciate it if you hit bookmark or mark it as helpful.

 

Interested in more Articles, Blogs, Videos, Podcasts, Share projects I shared/participated in?
- Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

 

Kind regards,


Mark Roethof

ServiceNow Technical Consultant @ Quint Technology
1x ServiceNow Developer MVP

1x ServiceNow Community MVP

---

LinkedIn

Comments
Deepansh Jain
Kilo Contributor

Hello Mark ,

I am trying to apply conditions on the Scripted Metric but it soesn't seem to work, Can you please help me on this ?

https://community.servicenow.com/community?id=community_question&sys_id=92bd9c38db5b18903daa1ea66896191d

Stan B_
Tera Contributor

Very helpfull, thank You. I was creating metrics on my custom table and I was curios  why it is not working. Thanks to this article i made my business rule copy  in relation to my table and metrics started to work with new records in my table.

anna238
Tera Contributor

Hey @Mark Roethof, et al,

Thanks for sharing this. I followed exactly the steps but no metrics created under my metrics definition. Can you please let me know where did I missed?

Overview: Need to keep the history of Description field value changes in Control (sn_compliance_control) form

 

1. Metric Definition:

anna238_0-1674749382341.png

2. Business Rules:

2.a When to run:

anna238_1-1674749466797.png

2.b Advanced:

anna238_2-1674749570025.png

2.c Note that I created global GlideScriptRecordUtil to solve the 'GlideScriptRecordUtil is not allowed in scoped applications' problem (Ref)

anna238_3-1674749682623.png

3. I also have set sn_grc_item table collection to be audit = true

4. I also checked the scheduled job next run: 'metric update events process' to test (KB0963918 )

 

But there is still no metric created when I changed the Controls Description field.

 

Appreciate any help here. Been hitting walls for hours now.

Advanced thanks!

Anna.

JHufford
Mega Guru

I have done exactly this for the awa_agent_presence_history table. It captures the time when an agent presence starts, but i cannot get it to capture (and therefore calculate) when an agent presence ends. I've tried using scripts from other definitions that are known to work, but getting nowhere. 

Christophe_E
Tera Contributor

FYI: For metrics in scoped app, this article may also be helpfull: Metrics in Scoped Apps - ServiceNow Community

Version history
Last update:
‎08-18-2024 06:18 AM
Updated by:
Contributors