reporting-dashboards について
ServiceNow の管理者や開発者向けに、レポートとダッシュボードの作成方法をまとめたスキルです。複数のグラフ形式、定期配信、データエクスポートに加え、MCP ツールの利用例も扱います。
主な機能
- 01リスト、棒グラフ、トレンドレポートの作成
- 02ピボットテーブルと KPI 表示の作成
- 03レポートウィジェットによるダッシュボード構成
- 04レポートのメール定期配信
- 05データのエクスポートと REST クエリ
活用シーン
- 01優先度別のインシデント確認
- 02サービスデスク指標の集計
- 03インシデントレポートの定期送信
- 04レポートデータの抽出とエクスポート
MCP 対応
レポート用テーブルやフィールドの検索、レポートとダッシュボードの作成、配信予約、データ出力に使う ServiceNow MCP ツールを説明します。
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ serac-labs/ serac --skill reporting-dashboardsインストール後、Claude Code で/reporting-dashboardsを入力して読み込まれたか確認します。
詳細
ServiceNow のレポートとダッシュボード
ServiceNow は、データの可視化とビジネスインテリジェンスのための包括的なレポート機能を提供します。
レポートの種類
| 種類 | 用途 | 例 |
|---|---|---|
| リスト | 表形式のデータ | インシデントリスト |
| 棒グラフ | カテゴリの比較 | 優先度別インシデント |
| 円グラフ/ドーナツグラフ | 分布 | カテゴリ別チケット |
| 折れ線グラフ/面グラフ | 時系列の傾向 | 週ごとのチケット件数 |
| ピボットテーブル | 多次元データ | 優先度 × カテゴリ |
| 単一スコア | KPI 値 | オープン中の P1 件数 |
| ゲージ | 進捗/しきい値 | SLA 達成率 |
レポートの作成
リストレポート(ES5)
// Create list report
var report = new GlideRecord("sys_report")
report.initialize()
report.setValue("title", "Open High Priority Incidents")
report.setValue("table", "incident")
report.setValue("type", "list")
// Filter condition
report.setValue("filter", "active=true^priority<=2")
// Columns
report.setValue("field", "number,short_description,priority,state,assigned_to,opened_at")
// Sorting
report.setValue("orderby", "priority")
report.setValue("order", "ASC")
// Grouping (optional)
report.setValue("group", "assignment_group")
// Access control
report.setValue("user", gs.getUserID())
report.setValue("roles", "itil")
report.insert()
棒グラフレポート(ES5)
// Create bar chart
var barReport = new GlideRecord("sys_report")
barReport.initialize()
barReport.setValue("title", "Incidents by Priority")
barReport.setValue("table", "incident")
barReport.setValue("type", "bar")
// Aggregation
barReport.setValue("aggregate", "COUNT")
barReport.setValue("group", "priority")
// Filter
barReport.setValue("filter", "active=true")
// Chart options
barReport.setValue("show_data_label", true)
barReport.setValue("show_legend", true)
barReport.setValue("chart_color", "blue")
barReport.insert()
傾向レポート(ES5)
// Create trend line chart
var trendReport = new GlideRecord("sys_report")
trendReport.initialize()
trendReport.setValue("title", "Incident Volume - Last 30 Days")
trendReport.setValue("table", "incident")
trendReport.setValue("type", "line")
// Time-based grouping
trendReport.setValue("trend", "opened_at")
trendReport.setValue("trend_interval", "day")
// Aggregation
trendReport.setValue("aggregate", "COUNT")
// Time filter
var thirtyDaysAgo = new GlideDateTime()
thirtyDaysAgo.addDaysLocalTime(-30)
trendReport.setValue("filter", "opened_at>=" + thirtyDaysAgo.getValue())
// Stacked by category
trendReport.setValue("stack", "priority")
trendReport.insert()
ピボットテーブル(ES5)
// Create pivot table
var pivotReport = new GlideRecord("sys_report")
pivotReport.initialize()
pivotReport.setValue("title", "Incidents: Priority vs Category")
pivotReport.setValue("table", "incident")
pivotReport.setValue("type", "pivot")
// Dimensions
pivotReport.setValue("group", "priority") // Rows
pivotReport.setValue("stack", "category") // Columns
// Aggregation
pivotReport.setValue("aggregate", "COUNT")
// Filter
pivotReport.setValue("filter", "active=true")
// Show totals
pivotReport.setValue("show_row_total", true)
pivotReport.setValue("show_column_total", true)
pivotReport.insert()
ダッシュボード
ダッシュボードの作成(ES5)
// Create dashboard
var dashboard = new GlideRecord("sys_dashboard")
dashboard.initialize()
dashboard.setValue("name", "IT Service Desk Dashboard")
dashboard.setValue("description", "Key metrics for service desk operations")
// Layout
dashboard.setValue("layout", "3") // 1, 2, 3, or 4 columns
// Access
dashboard.setValue("view_as", "desktop")
dashboard.setValue("roles", "itil")
var dashboardSysId = dashboard.insert()
ダッシュボードへのウィジェットの追加(ES5)
// Add report widget
function addReportToDashboard(dashboardId, reportId, row, column, width, height) {
var widget = new GlideRecord("sys_dashboard_widget")
widget.initialize()
widget.setValue("dashboard", dashboardId)
widget.setValue("report", reportId)
widget.setValue("row", row)
widget.setValue("column", column)
widget.setValue("width", width || 1) // columns wide
widget.setValue("height", height || 1) // rows tall
return widget.insert()
}
// Layout example (3-column dashboard)
// Row 0: Three single-score cards
addReportToDashboard(dashboardSysId, openIncidentsReport, 0, 0, 1, 1)
addReportToDashboard(dashboardSysId, avgResolutionReport, 0, 1, 1, 1)
addReportToDashboard(dashboardSysId, slaComplianceReport, 0, 2, 1, 1)
// Row 1: Full-width trend chart
addReportToDashboard(dashboardSysId, trendReport, 1, 0, 3, 2)
// Row 2: Two charts side by side
addReportToDashboard(dashboardSysId, priorityPieChart, 3, 0, 1, 2)
addReportToDashboard(dashboardSysId, categoryBarChart, 3, 1, 2, 2)
スケジュールされたレポート
スケジュールされたレポートの作成(ES5)
// Schedule report for email delivery
var schedule = new GlideRecord("sys_report_schedule")
schedule.initialize()
schedule.setValue("report", reportSysId)
schedule.setValue("name", "Weekly Incident Summary")
// Recipients
schedule.setValue("recipients", "[email protected]")
schedule.setValue("recipient_users", managersSysIds) // comma-separated
schedule.setValue("recipient_groups", itManagersGroup)
// Schedule (cron)
schedule.setValue("run", "weekly")
schedule.setValue("day", "monday")
schedule.setValue("time", "08:00:00")
// Format
schedule.setValue("format", "pdf") // pdf, xlsx, csv
// Email settings
schedule.setValue("subject", "Weekly IT Incident Summary")
schedule.setValue("message", "Please find attached the weekly incident summary report.")
schedule.setValue("active", true)
schedule.insert()
高度なレポート
数式フィールドを含むレポート(ES5)
// Report with calculated field
var report = new GlideRecord("sys_report")
report.initialize()
report.setValue("title", "SLA Breach Analysis")
report.setValue("table", "task_sla")
report.setValue("type", "bar")
// Custom formula aggregation
report.setValue("aggregate", "SUM")
report.setValue("field", "has_breached") // Boolean to count
// Percentage calculation
report.setValue("formula", "CASE WHEN {has_breached} = 1 THEN 1 ELSE 0 END")
report.setValue("group", "sla.name")
report.insert()
ドリルダウンレポート(ES5)
// Create report with drill-down capability
var summaryReport = new GlideRecord("sys_report")
summaryReport.initialize()
summaryReport.setValue("title", "Incidents by Assignment Group")
summaryReport.setValue("table", "incident")
summaryReport.setValue("type", "bar")
summaryReport.setValue("aggregate", "COUNT")
summaryReport.setValue("group", "assignment_group")
// Enable drill-down
summaryReport.setValue("is_drillable", true)
summaryReport.setValue("drill_down_report", detailReportSysId)
summaryReport.insert()
エクスポートと統合
レポートデータのエクスポート(ES5)
// Export report to CSV
function exportReportToCSV(reportSysId) {
var report = new GlideRecord("sys_report")
if (!report.get(reportSysId)) return null
var ga = new GlideAggregate(report.getValue("table"))
// Apply filter
var filter = report.getValue("filter")
if (filter) {
ga.addEncodedQuery(filter)
}
// Apply grouping
var groupField = report.getValue("group")
if (groupField) {
ga.addAggregate("COUNT")
ga.groupBy(groupField)
}
ga.query()
var results = []
while (ga.next()) {
results.push({
group: ga.getValue(groupField),
count: ga.getAggregate("COUNT"),
})
}
return results
}
レポート用 REST API
// Get report data via REST
// GET /api/now/stats/{table}?sysparm_query={filter}&sysparm_count=true&sysparm_group_by={field}
// Example: Incidents by priority
// GET /api/now/stats/incident?sysparm_query=active=true&sysparm_count=true&sysparm_group_by=priority
MCP ツールとの統合
利用可能なレポートツール
| ツール | 目的 |
|---|---|
snow_create_report | レポートを作成 |
snow_create_dashboard | ダッシュボードを作成 |
snow_pa_create (action='scheduled_report') | 配信をスケジュール |
snow_pa_discover (action='reporting_tables') | 利用可能なテーブルを検索 |
snow_pa_discover (action='report_fields') | フィールドの選択肢を取得 |
snow_pa_operate (action='export_report') | データをエクスポート |
snow_pa_create (action='visualization') | グラフを作成 |
ワークフローの例
// 1. Discover available tables
var tables = await snow_pa_discover({
action: "reporting_tables",
category: "itsm",
})
// 2. Get fields for table
var fields = await snow_pa_discover({
action: "report_fields",
table: "incident",
})
// 3. Create report
var reportId = await snow_create_report({
title: "Incident Overview",
table: "incident",
type: "bar",
group: "priority",
aggregate: "COUNT",
filter: "active=true",
})
// 4. Create dashboard
var dashboardId = await snow_create_dashboard({
name: "Service Desk Overview",
layout: "3-column",
})
// 5. Add report to dashboard
await snow_add_dashboard_widget({
dashboard: dashboardId,
report: reportId,
row: 0,
column: 0,
})
// 6. Schedule report (looked up by name, recipients as array)
await snow_pa_create({
action: "scheduled_report",
reportName: "Incident Overview",
schedule: "weekly",
recipients: ["[email protected]"],
format: "PDF",
})
ベストプラクティス
- 明確なタイトル - 説明的で、アクションを示す名前を付けます
- 適切な種類 - データに合ったグラフの種類を選びます
- 適切なフィルター - 関連するデータに絞り込む設定を既定にします
- 色の意味 - 一貫した色のルールを使用します
- モバイル対応 - 小さい画面でテストします
- パフォーマンス - 行数を制限し、集計を使用します
- アクセス制御 - ロールベースの表示制御を設定します
- 定期的な更新 - データを最新の状態に保ちます
コメント
Markdown 対応