ServiceNow Integration Guide
Complete guide to integrating ServiceNow with DevGrid for DORA metrics (MTTR and Change Failure Rate).
Overview
ServiceNow integration enables DevGrid to:
- Calculate Mean Time to Restore (MTTR) from incident data
- Calculate Change Failure Rate (CFR) by linking incidents to deployments
- Filter metrics by incident priority (P1, P2, P3, P4)
- Track incident trends over time
Prerequisites
Before starting, ensure you have:
-
ServiceNow Instance
- Admin or integration user account
- API access enabled
- Custom field creation permissions (for deployment linkage)
-
DevGrid Account
- Admin access to configure integrations
- Applications/entities already created in DevGrid
-
Technical Requirements
- ServiceNow REST API enabled
- Network connectivity between DevGrid and your ServiceNow instance
- API credentials (username/password or OAuth)
Integration Setup
Step 1: Create ServiceNow Integration User (Recommended)
Create a dedicated integration user rather than using a personal account.
-
In ServiceNow:
- Go to User Administration → Users
- Click New
- Fill in details:
- User ID:
devgrid_integration - First name:
DevGrid - Last name:
Integration - Email:
[email protected]
- User ID:
-
Assign Required Roles:
rest_service- REST API accessitil- Access to incident tables- Custom role with read access to:
incidenttablechange_requesttable- Custom deployment linkage field
-
Set Password:
- Generate a strong password
- Store securely in password manager
Step 2: Configure Custom Field for Deployment Linkage
This is critical for Change Failure Rate calculation.
DevGrid needs to know which deployment caused each incident. Add a custom field to the Incident table:
-
In ServiceNow:
- Go to System Definition → Tables
- Search for and open:
incident - Click New under "Columns" tab
-
Create Custom Field:
- Column label:
Caused By Deployment - Column name:
u_caused_by_deployment - Type: String
- Max length: 100
- Default value: (leave empty)
- Column label:
-
Add to Incident Form:
- Go to Incident → Open an existing incident
- Right-click form header → Configure → Form Layout
- Drag "Caused By Deployment" field to appropriate section
- Click Save
-
Document the Field:
- Create internal documentation explaining:
- This field links incidents to deployments
- Populate with
change_idfrom deployment events - Example:
CHG0012345
- Create internal documentation explaining:
Step 3: Connect ServiceNow to DevGrid
-
In DevGrid:
- Navigate to Settings → Integrations
- Click Add Integration
- Select ServiceNow
-
Enter Connection Details:
- Instance URL:
https://your-instance.service-now.com - Username:
devgrid_integration - Password:
[your integration user password] - Deployment Link Field:
u_caused_by_deployment(or whatever you named your custom field)
- Instance URL:
-
Configure Sync Settings:
- Sync Frequency: Every 1 hour (recommended)
- Incident Filters:
- Include States: Resolved, Closed
- Include Priorities: P1, P2, P3, P4 (or customize)
- Date Range: Last 90 days (recommended for initial sync)
-
Map Incident Priorities: DevGrid needs to understand your ServiceNow priority levels.
Default mapping:
ServiceNow Priority DevGrid Priority 1 - Critical P1 2 - High P2 3 - Moderate P3 4 - Low P4 5 - Planning P5 Customize if your organization uses different priority schemes.
-
Test Connection:
- Click Test Connection
- Verify success message
- Review any warnings or errors
-
Save Integration:
- Click Save
- Initial sync will start automatically
Step 4: Verify Initial Sync
-
Check Sync Status:
- Go to Settings → Integrations → ServiceNow
- View Last Sync timestamp
- Check Sync Status (should show "Success")
-
Review Synced Incidents:
- In DevGrid, navigate to Incidents or Metrics
- Filter by date range
- Verify incidents appear with correct:
- Priority
- Created/Resolved timestamps
- Status
-
Troubleshoot if Issues:
- Check ServiceNow API credentials
- Verify network connectivity
- Review DevGrid integration logs
- See Troubleshooting section below
Linking Incidents to Deployments
Why This Matters
Change Failure Rate cannot be calculated without incident-to-deployment links.
Without this linkage, DevGrid doesn't know:
- Which deployment caused which incident
- How many deployments resulted in incidents
- The failure rate of your deployments
How to Link Incidents
Option 1: During Incident Creation (Recommended)
When creating a new incident:
-
Identify the Deployment:
- Check deployment logs for recent deployments
- Look for change management tickets (CHG numbers)
- Example:
CHG0012345
-
Link in ServiceNow:
- Open the incident
- Find the Caused By Deployment field
- Enter the change ID:
CHG0012345 - Save incident
Option 2: During Incident Investigation
After investigating root cause:
-
Determine Root Cause:
- Was this incident caused by a recent deployment?
- Which change ticket represents that deployment?
-
Update Incident:
- Open the incident in ServiceNow
- Populate Caused By Deployment field with change ID
- Add notes explaining the linkage
- Save
Option 3: Bulk Update (Historical Data)
For historical incidents that need linkage:
// ServiceNow Background Script
var gr = new GlideRecord('incident');
gr.addQuery('opened_at', '>', '2025-09-01'); // Last 2 months
gr.addQuery('u_caused_by_deployment', ''); // No deployment linked
gr.addQuery('state', 'Resolved');
gr.query();
while (gr.next()) {
// Logic to determine deployment
// This is custom to your organization
// Example: link to deployment within 24 hours before incident
var deploymentId = findRelatedDeployment(gr.opened_at);
if (deploymentId) {
gr.u_caused_by_deployment = deploymentId;
gr.update();
}
}Note: Customize the above logic for your organization.
Best Practices for Linking
-
Link During Triage:
- Add to incident creation workflow
- Make it part of incident investigation checklist
-
Only Link Definite Causes:
- Don't link every incident to nearest deployment
- Only link when deployment definitively caused the incident
- If uncertain, investigate before linking
-
Update if Root Cause Changes:
- If initial assessment was wrong, update the link
- Remove link if deployment wasn't the actual cause
-
Document Linkage Decisions:
- Add comments explaining why incident was linked
- Include evidence (logs, error messages, timing)
Sending Deployment Events with change_id
For CFR calculation to work, deployment events must include the change_id that matches ServiceNow.
Example Deployment Event
curl -X POST https://prod.api.devgrid.io/events \
-H "x-api-key: $DEVGRID_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"events": [{
"type": "event-deploy",
"entityId": "my-application-id",
"timestamp": "2025-10-29T18:30:00Z",
"attributes": {
"env": "production",
"status": "success",
"build_commit_sha": "a1b2c3d4e5f6789",
"change_id": "CHG0012345",
"change_url": "https://yourcompany.service-now.com/change.do?sys_id=abc123",
"change_title": "Deploy v2.3.1 to production",
"change_author": "[email protected]",
"change_approver": "[email protected]"
}
}]
}'Critical field:
{
"change_id": "CHG0012345" // Must match ServiceNow change request number
}Where to Get change_id
The change_id should come from your change management process:
Automated Change Management
If you use ServiceNow change requests for deployments:
- Create change request in ServiceNow (manually or via API)
- Get change number from ServiceNow (e.g.,
CHG0012345) - Pass to CI/CD pipeline as environment variable
- Include in deployment event
Example GitHub Actions:
env:
CHANGE_ID: CHG0012345 # From ServiceNow change request
steps:
- name: Send deployment event
run: |
curl -X POST https://prod.api.devgrid.io/events \
-H "x-api-key: ${{ secrets.DEVGRID_API_KEY }}" \
-d '{
"events": [{
"type": "event-deploy",
"entityId": "${{ vars.DEVGRID_ENTITY_ID }}",
"attributes": {
"change_id": "${{ env.CHANGE_ID }}"
}
}]
}'Manual Change Management
If change requests are created manually:
- Create change in ServiceNow before deployment
- Document change number in deployment runbook
- Include in deployment event when triggered
Generated Change IDs
If you generate your own change IDs:
- Use consistent format (e.g.,
CHG-YYYY-MM-DD-NNNN) - Ensure IDs are unique
- Populate same ID in both:
- Deployment events to DevGrid
- Incident linkage field in ServiceNow
Incident State Mapping
DevGrid needs to understand which ServiceNow states mean "resolved."
Default State Mapping
| ServiceNow State | DevGrid Status | Included in MTTR? |
|---|---|---|
| New | Open | No |
| In Progress | Open | No |
| On Hold | Open | No |
| Resolved | Resolved | Yes |
| Closed | Resolved | Yes |
| Canceled | Excluded | No |
Custom State Mapping
If your ServiceNow instance uses custom states:
-
In DevGrid:
- Go to Settings → Integrations → ServiceNow
- Click Configure State Mapping
-
Map Each Custom State:
- Select ServiceNow state
- Map to: Open, Resolved, or Excluded
- Save
Example custom states:
Pending Vendor→ OpenAwaiting Approval→ OpenResolution Verified→ Resolved
Calculating MTTR
Once ServiceNow is integrated, DevGrid automatically calculates MTTR.
MTTR Calculation
MTTR = Average(Resolved Timestamp - Created Timestamp)
For all resolved incidents in the selected time period.
Viewing MTTR
-
In DevGrid:
- Go to Metrics → DORA Metrics
- Select your application
- View Mean Time to Restore
-
Filter by Priority:
- All Priorities (combined)
- P1 (critical incidents only)
- P2 (high priority)
- P3 (moderate)
- P4 (low)
-
Select Time Period:
- Last 7 days
- Last 30 days
- Last 90 days
- Custom date range
MTTR Best Practices
-
Resolve Incidents Promptly:
- Close incidents when actually resolved
- Don't leave in "Resolved" state indefinitely
-
Accurate Timestamps:
- Created timestamp should be when issue was detected
- Resolved timestamp should be when service was restored
-
Filter by Priority:
- Track P1 MTTR separately from P3/P4
- Different SLAs for different priorities
-
Track Trends:
- Monitor MTTR over time
- Investigate spikes or degradations
Calculating Change Failure Rate
CFR is calculated once both deployment events and incident linkages are in place.
CFR Calculation
CFR = (Number of deployments causing incidents / Total deployments) × 100
Viewing CFR
-
In DevGrid:
- Go to Metrics → DORA Metrics
- Select your application
- View Change Failure Rate
-
Breakdown:
- Percentage: 25% (example)
- Failed deployments: 5
- Total deployments: 20
- Time period: Last 30 days
CFR Requirements Checklist
- ✅ Deployment events sent to DevGrid with
change_id - ✅ ServiceNow integration connected
- ✅ Custom field created for deployment linkage
- ✅ Incidents linked to deployments in ServiceNow
- ✅ Incidents resolved (not still open)
CFR Best Practices
-
Only Link Actual Failures:
- Don't link incidents unrelated to deployments
- Be accurate - this affects important metrics
-
Review Linkages Periodically:
- Audit incident-deployment links monthly
- Remove incorrect linkages
- Add missing linkages
-
Track by Environment:
- Production CFR (most important)
- Staging CFR (leading indicator)
-
Set Improvement Goals:
- DORA Elite: < 15% CFR
- DORA High: 16-30% CFR
Troubleshooting
No Incidents Appearing in DevGrid
Check:
- ✅ ServiceNow integration status is "Connected"
- ✅ Last sync timestamp is recent
- ✅ Sync filters include your incidents (date range, state, priority)
- ✅ API credentials are valid
- ✅ DevGrid has network access to your ServiceNow instance
Solution:
- Go to Settings → Integrations → ServiceNow
- Click Test Connection
- Review error messages
- Check ServiceNow API logs
MTTR Shows N/A
Check:
- ✅ Incidents are in "Resolved" or "Closed" state
- ✅ Incidents have both Created and Resolved timestamps
- ✅ Date range includes resolved incidents
- ✅ Incidents are associated with your application
Solution:
- Verify incidents are syncing (check DevGrid Incidents page)
- Ensure incidents are actually resolved in ServiceNow
- Wait for next sync (hourly)
CFR Shows N/A
Check:
- ✅ Deployment events include
change_id - ✅ Incidents are linked to deployments in ServiceNow
- ✅ Custom field name matches DevGrid configuration
- ✅ Change IDs in events match Change IDs in incidents
Solution:
- Review deployment events: Do they include
change_id? - Check ServiceNow: Are incidents populated with deployment links?
- Verify field name:
u_caused_by_deploymentor custom name - See Troubleshooting Guide
Sync Failing
Common Errors:
Authentication Error
Error: 401 Unauthorized
Solution:
- Verify ServiceNow username/password
- Check integration user still exists and is active
- Regenerate password and update in DevGrid
Missing Field Error
Error: Field u_caused_by_deployment does not exist
Solution:
- Verify custom field was created in ServiceNow
- Check field name matches DevGrid configuration
- Ensure integration user has read access to custom field
Network Error
Error: Unable to connect to ServiceNow instance
Solution:
- Verify instance URL is correct
- Check network connectivity
- Ensure ServiceNow instance is accessible from DevGrid
- Check firewall rules
Incidents Not Linking to Deployments
Check:
- ✅
change_idin deployment event exactly matches value in ServiceNow incident - ✅ No typos or extra spaces
- ✅ Case-sensitive match (if applicable)
- ✅ Custom field populated in ServiceNow
Example of mismatch:
❌ Deployment Event:
{
"change_id": "CHG0012345"
}❌ ServiceNow Incident:
Caused By Deployment: chg0012345 (lowercase - doesn't match!)
✅ ServiceNow Incident:
Caused By Deployment: CHG0012345 (exact match!)
Data Privacy & Security
Data Collected from ServiceNow
DevGrid collects the following incident data:
- Incident number
- Created timestamp
- Resolved timestamp
- Priority/severity
- State
- Deployment linkage field value
- Assignment group (optional)
DevGrid does not collect:
- Incident descriptions (may contain sensitive info)
- Comments or work notes
- Attachments
- Caller information (unless explicitly configured)
Security Best Practices
-
Use Dedicated Integration User:
- Don't use personal ServiceNow account
- Limit permissions to read-only on incident table
-
Secure API Credentials:
- Store password in DevGrid (encrypted at rest)
- Don't share credentials
- Rotate password periodically
-
Network Security:
- Use HTTPS for all API calls
- Consider IP whitelisting if supported
-
Audit Logging:
- Monitor ServiceNow API access logs
- Review DevGrid integration logs periodically
Advanced Configuration
Filtering Incidents by Assignment Group
Only sync incidents for specific teams:
-
In DevGrid:
- Go to Settings → Integrations → ServiceNow
- Advanced Settings → Assignment Group Filter
-
Add Assignment Groups:
- Platform Team
- Infrastructure Team
- Application Support Team
-
Save:
- Only incidents assigned to these groups will sync
Multiple ServiceNow Instances
If your organization has multiple ServiceNow instances:
- Configure separate integration per instance
- Map instances to specific DevGrid applications
- Use different API credentials for each
Custom Incident Fields
To sync additional incident fields:
- Contact DevGrid Support
- Provide field names and data types
- DevGrid will configure custom field sync
Updated 3 months ago
