mcpField
P
performance-analytics

performance-analytics

github.com/serac-labs数据与数据库7759 次安装9 周前更新
代码仓库

关于 performance-analytics

面向 ServiceNow Performance Analytics 的技能,涵盖指标、细分、阈值、组件和仪表板的配置。还介绍用于创建分析对象、查找指标、获取分数及收集数据的 MCP 工具。

主要功能

  1. 01配置 KPI 指标与聚合方式
  2. 02定义细分维度和阈值
  3. 03构建组件与仪表板
  4. 04收集并获取指标分数

适用场景

  1. 01跟踪事件数量和解决时长
  2. 02按优先级或团队分析指标
  3. 03展示趋势与 KPI 阈值

MCP 相关

介绍用于创建指标、细分、阈值和组件,查找指标、获取分数及触发数据收集的 MCP 工具。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/serac-labs/serac --skill performance-analytics

安装后在 Claude Code 中输入/performance-analytics确认已加载。

详细介绍

ServiceNow 性能分析

性能分析(PA)提供高级报告和 KPI 跟踪功能,用于衡量和改进业务流程。

PA 架构

组件层级
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
关键表
表用途
pa_indicatorsKPI 定义
pa_indicator_breakdowns指标与细分项的关联
pa_breakdowns细分项定义
pa_thresholds阈值规则
pa_widgets仪表板小组件
pa_dashboards仪表板容器

指标

指标类型
类型聚合方式示例
计数COUNT(*)事件数量
求和SUM(field)总成本
平均值AVG(field)平均解决时间
百分比(A/B)*100SLA 合规率 %
持续时间时间计算平均解决时间
创建计数指标(ES5)
// Create "Open Incidents" indicator
var indicator = new GlideRecord("pa_indicators")
indicator.initialize()
indicator.setValue("name", "Open Incidents")
indicator.setValue("description", "Number of currently open incidents")

// Source configuration
indicator.setValue("cube", "pa_cubes_incident") // or table-based
indicator.setValue("facts_table", "incident")
indicator.setValue("conditions", "active=true")

// Aggregation
indicator.setValue("aggregate", "COUNT") // COUNT, SUM, AVG

// Display settings
indicator.setValue("direction", 2) // 1=Up is good, 2=Down is good
indicator.setValue("unit", "Incidents")
indicator.setValue("precision", 0) // Decimal places

// Scoring
indicator.setValue("frequency", "daily")

indicator.insert()
创建平均值指标(ES5)
// Create "Average Resolution Time" indicator
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") // Resolved

// Aggregation on duration
indicator.setValue("aggregate", "AVG")
indicator.setValue("field", "calendar_duration") // Duration field

// Time unit
indicator.setValue("unit", "Hours")
indicator.setValue("unit_conversion", 3600) // Seconds to hours

indicator.setValue("direction", 2) // Lower is better
indicator.setValue("frequency", "daily")

indicator.insert()
创建百分比指标(ES5)
// Create "SLA Compliance" percentage indicator
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")

// Formula-based percentage
indicator.setValue("aggregate", "FORMULA")
indicator.setValue("formula", "(COUNT(has_breached=false) / COUNT(*)) * 100")

indicator.setValue("unit", "%")
indicator.setValue("direction", 1) // Higher is better
indicator.setValue("precision", 1)

indicator.insert()

细分项

常见细分项
细分项字段使用场景
优先级priority按 P1/P2/P3 统计事件
类别category按类型统计事件
群组assignment_group团队绩效
位置location地理分析
时间opened_at趋势分析
创建细分项(ES5)
// Create "Priority" breakdown
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")

// Sorting
breakdown.setValue("sort_field", "priority")
breakdown.setValue("sort_order", "ASC")

// Element mapping (optional)
breakdown.setValue("use_element_mapping", true)

breakdown.insert()
将细分项关联到指标(ES5)
// Link breakdown to indicator
var link = new GlideRecord("pa_indicator_breakdowns")
link.initialize()
link.setValue("indicator", indicatorSysId)
link.setValue("breakdown", breakdownSysId)
link.setValue("active", true)
link.insert()

阈值

创建阈值(ES5)
// Create threshold for Open Incidents
var threshold = new GlideRecord("pa_thresholds")
threshold.initialize()
threshold.setValue("indicator", indicatorSysId)
threshold.setValue("name", "Critical Level")

// Threshold conditions
threshold.setValue("operator", ">=") // >=, <=, =, >, <
threshold.setValue("value", 100)

// Visual styling
threshold.setValue("color", "red")
threshold.setValue("icon", "exclamation-circle")

// Notification
threshold.setValue("notification_user", adminSysId)
threshold.setValue("notification_script", thresholdScript)

threshold.insert()

// Add warning threshold
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()

小组件

小组件类型
类型使用场景显示内容
单一分数当前值“127 个未解决事件”
记分卡数值 + 趋势当前值 + 迷你趋势图
时间序列随时间变化的趋势折线图/柱状图
细分按维度查看饼图/柱状图
比较多个指标并排显示
创建小组件(ES5)
// Create scorecard widget
var widget = new GlideRecord("pa_widgets")
widget.initialize()
widget.setValue("name", "Open Incidents Scorecard")
widget.setValue("type", "scorecard")

// Indicator
widget.setValue("indicator", indicatorSysId)

// Time range
widget.setValue("time_range", "last_30_days")
widget.setValue("show_trend", true)
widget.setValue("compare_to", "previous_period")

// Display
widget.setValue("show_breakdown", true)
widget.setValue("breakdown", priorityBreakdownSysId)
widget.setValue("chart_type", "bar")

widget.insert()

仪表板

创建仪表板(ES5)
// Create PA Dashboard
var dashboard = new GlideRecord("pa_dashboards")
dashboard.initialize()
dashboard.setValue("name", "Incident Management Dashboard")
dashboard.setValue("description", "Key metrics for incident management")

// Layout
dashboard.setValue("layout", "2-column")

// Access control
dashboard.setValue("public", true)
dashboard.setValue("owner", gs.getUserID())

var dashboardSysId = dashboard.insert()

// Add widgets to dashboard
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)

数据收集

手动收集分数(ES5)
// Collect scores for an indicator
var job = new PAScoreCollector()
job.collectIndicatorScores(indicatorSysId)
计划收集
// PA uses scheduled jobs for data collection
// Default: Daily at midnight
// Configure via: Performance Analytics > Data Collection > Jobs

MCP 工具集成

可用的 PA 工具
工具用途
snow_pa_create (action='indicator')创建指标
snow_pa_create (action='breakdown')创建细分项
snow_pa_create (action='threshold')创建阈值
snow_pa_create (action='widget')创建小组件
snow_pa_operate (action='get_scores')获取分数
snow_pa_operate (action='collect_data')触发收集
snow_pa_discover (action='indicators')查找指标
示例工作流
// 1. Create indicator
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

// 2. Create breakdown
var breakdownResult = await snow_pa_create({
  action: "breakdown",
  name: "By Assignment Group",
  table: "incident",
  field: "assignment_group",
})
var breakdownId = breakdownResult.sys_id

// 3. Attach the breakdown to the indicator
//    (add_breakdown creates the breakdown + the indicator link in one step)
await snow_pa_indicator_manage({
  action: "add_breakdown",
  sys_id: indicatorId,
  breakdown_name: "By Assignment Group",
  breakdown_table: "incident",
  breakdown_field: "assignment_group",
})

// 4. Create threshold
await snow_pa_create({
  action: "threshold",
  indicator: indicatorId,
  type: "critical",
  operator: ">=",
  value: 10,
})

// 5. Create widget
await snow_pa_create({
  action: "widget",
  name: "P1 Incidents Scorecard",
  type: "scorecard",
  indicator: indicatorId,
  breakdown: breakdownId,
})

// 6. Get current scores
var scores = await snow_pa_operate({
  action: "get_scores",
  indicator_sys_id: indicatorId,
  time_range: "last_30_days",
})

最佳实践

  1. 方向很重要 - 正确设置(上升/下降代表良好)
  2. 设置有意义的阈值 - 根据业务需求确定
  3. 保持频率一致 - 与数据波动性相匹配
  4. 使用细分项 - 支持下钻分析
  5. 明确仪表板用途 - 每个仪表板聚焦一个主题
  6. 趋势分析 - 始终显示对比
  7. 性能 - 限制启用的指标数量
  8. 文档 - 清晰描述指标

评论

支持 Markdown