| name | performance-analytics |
| description | Build ServiceNow Performance Analytics — pa_indicators (count/sum/avg/percentage), pa_breakdowns, pa_thresholds with severity colors, pa_widgets, and pa_dashboards for KPI tracking. |
| license | Apache-2.0 |
| compatibility | Designed for Snow-Code and ServiceNow development |
| metadata | {"author":"serac","version":"1.0.0","category":"servicenow"} |
| tools | ["snow_pa_indicator_manage","snow_pa_create","snow_query_table","snow_artifact_manage"] |
Performance Analytics for ServiceNow
Performance Analytics (PA) provides advanced reporting and KPI tracking capabilities for measuring and improving business processes.
PA Architecture
Component Hierarchy
PA Dashboard
├── Widgets
│ ├── Scorecard Widget
│ ├── Time Series Chart
│ ├── Breakdown Pie Chart
│ └── Single Score
├── Indicators
│ ├── Number of Open Incidents
│ ├── Average Resolution Time
│ └── SLA Compliance Rate
├── Breakdowns
│ ├── By Priority
│ ├── By Assignment Group
│ └── By Category
└── Thresholds
├── Critical: > 100
└── Warning: > 50
Key Tables
| Table | Purpose |
|---|
pa_indicators | KPI definitions |
pa_indicator_breakdowns | Indicator-breakdown links |
pa_breakdowns | Breakdown definitions |
pa_thresholds | Threshold rules |
pa_widgets | Dashboard widgets |
pa_dashboards | Dashboard containers |
Indicators
Indicator Types
| Type | Aggregation | Example |
|---|
| Count | COUNT(*) | Number of incidents |
| Sum | SUM(field) | Total cost |
| Average | AVG(field) | Avg resolution time |
| Percentage | (A/B)*100 | SLA compliance % |
| Duration | Time calculation | Avg time to resolve |
Creating Count Indicator (ES5)
var indicator = new GlideRecord("pa_indicators")
indicator.initialize()
indicator.setValue("name", "Open Incidents")
indicator.setValue("description", "Number of currently open incidents")
indicator.setValue("cube", "pa_cubes_incident")
indicator.setValue("facts_table", "incident")
indicator.setValue("conditions", "active=true")
indicator.setValue("aggregate", "COUNT")
indicator.setValue("direction", 2)
indicator.setValue("unit", "Incidents")
indicator.setValue("precision", 0)
indicator.setValue("frequency", "daily")
indicator.insert()
Creating Average Indicator (ES5)
var indicator = new GlideRecord("pa_indicators")
indicator.initialize()
indicator.setValue("name", "Avg Resolution Time")
indicator.setValue("description", "Average time to resolve incidents")
indicator.setValue("facts_table", "incident")
indicator.setValue("conditions", "state=6")
indicator.setValue("aggregate", "AVG")
indicator.setValue("field", "calendar_duration")
indicator.setValue("unit", "Hours")
indicator.setValue("unit_conversion", 3600)
indicator.setValue("direction", 2)
indicator.setValue("frequency", "daily")
indicator.insert()
Creating Percentage Indicator (ES5)
var indicator = new GlideRecord("pa_indicators")
indicator.initialize()
indicator.setValue("name", "SLA Compliance Rate")
indicator.setValue("description", "Percentage of incidents meeting SLA")
indicator.setValue("facts_table", "task_sla")
indicator.setValue("conditions", "task.sys_class_name=incident")
indicator.setValue("aggregate", "FORMULA")
indicator.setValue("formula", "(COUNT(has_breached=false) / COUNT(*)) * 100")
indicator.setValue("unit", "%")
indicator.setValue("direction", 1)
indicator.setValue("precision", 1)
indicator.insert()
Breakdowns
Common Breakdowns
| Breakdown | Field | Use Case |
|---|
| Priority | priority | Incidents by P1/P2/P3 |
| Category | category | Incidents by type |
| Group | assignment_group | Team performance |
| Location | location | Geographic analysis |
| Time | opened_at | Trend analysis |
Creating Breakdown (ES5)
var breakdown = new GlideRecord("pa_breakdowns")
breakdown.initialize()
breakdown.setValue("name", "Priority")
breakdown.setValue("description", "Breakdown by incident priority")
breakdown.setValue("facts_table", "incident")
breakdown.setValue("dimension_field", "priority")
breakdown.setValue("sort_field", "priority")
breakdown.setValue("sort_order", "ASC")
breakdown.setValue("use_element_mapping", true)
breakdown.insert()
Linking Breakdown to Indicator (ES5)
var link = new GlideRecord("pa_indicator_breakdowns")
link.initialize()
link.setValue("indicator", indicatorSysId)
link.setValue("breakdown", breakdownSysId)
link.setValue("active", true)
link.insert()
Thresholds
Creating Thresholds (ES5)
var threshold = new GlideRecord("pa_thresholds")
threshold.initialize()
threshold.setValue("indicator", indicatorSysId)
threshold.setValue("name", "Critical Level")
threshold.setValue("operator", ">=")
threshold.setValue("value", 100)
threshold.setValue("color", "red")
threshold.setValue("icon", "exclamation-circle")
threshold.setValue("notification_user", adminSysId)
threshold.setValue("notification_script", thresholdScript)
threshold.insert()
var warning = new GlideRecord("pa_thresholds")
warning.initialize()
warning.setValue("indicator", indicatorSysId)
warning.setValue("name", "Warning Level")
warning.setValue("operator", ">=")
warning.setValue("value", 50)
warning.setValue("color", "orange")
warning.insert()
Widgets
Widget Types
| Type | Use Case | Shows |
|---|
| Single Score | Current value | "127 Open Incidents" |
| Scorecard | Value + trend | Current + sparkline |
| Time Series | Trend over time | Line/bar chart |
| Breakdown | By dimension | Pie/bar chart |
| Comparison | Multiple indicators | Side-by-side |
Creating Widget (ES5)
var widget = new GlideRecord("pa_widgets")
widget.initialize()
widget.setValue("name", "Open Incidents Scorecard")
widget.setValue("type", "scorecard")
widget.setValue("indicator", indicatorSysId)
widget.setValue("time_range", "last_30_days")
widget.setValue("show_trend", true)
widget.setValue("compare_to", "previous_period")
widget.setValue("show_breakdown", true)
widget.setValue("breakdown", priorityBreakdownSysId)
widget.setValue("chart_type", "bar")
widget.insert()
Dashboards
Creating Dashboard (ES5)
var dashboard = new GlideRecord("pa_dashboards")
dashboard.initialize()
dashboard.setValue("name", "Incident Management Dashboard")
dashboard.setValue("description", "Key metrics for incident management")
dashboard.setValue("layout", "2-column")
dashboard.setValue("public", true)
dashboard.setValue("owner", gs.getUserID())
var dashboardSysId = dashboard.insert()
function addWidgetToDashboard(dashboardId, widgetId, row, column) {
var placement = new GlideRecord("pa_dashboard_widgets")
placement.initialize()
placement.setValue("dashboard", dashboardId)
placement.setValue("widget", widgetId)
placement.setValue("row", row)
placement.setValue("column", column)
placement.insert()
}
addWidgetToDashboard(dashboardSysId, openIncWidget, 0, 0)
addWidgetToDashboard(dashboardSysId, avgTimeWidget, 0, 1)
addWidgetToDashboard(dashboardSysId, slaWidget, 1, 0)
Data Collection
Manual Score Collection (ES5)
var job = new PAScoreCollector()
job.collectIndicatorScores(indicatorSysId)
Scheduled Collection
MCP Tool Integration
Available PA Tools
| Tool | Purpose |
|---|
snow_pa_create (action='indicator') | Create indicator |
snow_pa_create (action='breakdown') | Create breakdown |
snow_pa_create (action='threshold') | Create threshold |
snow_pa_create (action='widget') | Create widget |
snow_pa_operate (action='get_scores') | Retrieve scores |
snow_pa_operate (action='collect_data') | Trigger collection |
snow_pa_discover (action='indicators') | Find indicators |
Example Workflow
var indicatorResult = await snow_pa_create({
action: "indicator",
name: "Open P1 Incidents",
table: "incident",
conditions: "active=true^priority=1",
aggregate: "COUNT",
})
var indicatorId = indicatorResult.sys_id
var breakdownResult = await snow_pa_create({
action: "breakdown",
name: "By Assignment Group",
table: "incident",
field: "assignment_group",
})
var breakdownId = breakdownResult.sys_id
await snow_pa_indicator_manage({
action: "add_breakdown",
sys_id: indicatorId,
breakdown_name: "By Assignment Group",
breakdown_table: "incident",
breakdown_field: "assignment_group",
})
await snow_pa_create({
action: "threshold",
indicator: indicatorId,
type: "critical",
operator: ">=",
value: 10,
})
await snow_pa_create({
action: "widget",
name: "P1 Incidents Scorecard",
type: "scorecard",
indicator: indicatorId,
breakdown: breakdownId,
})
var scores = await snow_pa_operate({
action: "get_scores",
indicator_sys_id: indicatorId,
time_range: "last_30_days",
})
Best Practices
- Direction Matters - Set correctly (up/down is good)
- Meaningful Thresholds - Based on business requirements
- Consistent Frequency - Match data volatility
- Use Breakdowns - Enable drill-down analysis
- Dashboard Purpose - One focus per dashboard
- Trend Analysis - Always show comparison
- Performance - Limit active indicators
- Documentation - Clear indicator descriptions