Integrations

ServiceNow Google Cloud Integration Guide

advancedOAuth 2.0 Service Account with JSON Web Token (JWT)Google Cloud Platform

ServiceNow Google Cloud Platform integration enables organizations to automatically discover, track, and manage GCP resources within the ServiceNow CMDB while establishing bi-directional communication for incident management and operational workflows. This integration is primarily used by cloud operations teams, infrastructure engineers, and ServiceNow administrators managing hybrid cloud environments where visibility into GCP compute instances, storage buckets, databases, and networking components is critical for ITSM processes. The integration supports both uni-directional data flows for CMDB population and bi-directional flows for incident management, primarily triggered through scheduled discovery jobs and real-time Pub/Sub messaging. The integration leverages ServiceNow's Integration Hub with the official Google Cloud Platform spoke, operating within the Configuration Management and IT Operations Management modules to provide comprehensive cloud infrastructure visibility and automated incident response capabilities.

Prerequisites

  • ServiceNow Quebec or later with Integration Hub Professional license
  • Google Cloud Platform project with Compute Engine, Cloud Asset, and Pub/Sub APIs enabled
  • GCP IAM service account with roles/compute.viewer, roles/cloudasset.viewer, and roles/pubsub.editor permissions
  • ServiceNow MID Server deployed in GCP or with network connectivity to GCP APIs
  • Discovery application plugin (com.snc.discovery) activated in ServiceNow
  • ITOM Visibility application (com.snc.itom.visibility) installed and configured
  • Google Cloud Platform spoke installed from ServiceNow Store

Architecture Overview

The ServiceNow Google Cloud Platform integration utilizes the official GCP spoke in Integration Hub, which provides pre-built Actions for compute instance management, Pub/Sub messaging, and cloud asset inventory. Authentication is established using OAuth 2.0 service account credentials stored in ServiceNow Connection & Credential Aliases, with the service account JSON key securely stored in a Basic Auth Credential record. Data flows bi-directionally with Discovery jobs pulling GCP resource metadata into CMDB CI records, while Pub/Sub subscriptions push real-time events to ServiceNow for incident creation and state management. A MID Server is required for Discovery operations and acts as the secure communication bridge between ServiceNow and GCP APIs, handling authentication token refresh and API rate limiting. The integration respects GCP API quotas with default limits of 2000 requests per 100 seconds for Compute Engine API and implements exponential backoff retry logic within the spoke Actions to handle rate limiting gracefully.

Sourdough
Chrome Extension

Sourdough: ServiceNow Monitoring and Analytics

A Chrome extension for ServiceNow Admins and Developers with essential tools, analytics, graphs and monitoring features.

Instance HealthGraphs & ChartsAPI HealthDeveloper ToolsQuick SearchInstance Switcher
Add to Chrome

Free to install. Pro $5/month after a 14-day no-card trial.
Pro requires the ServiceNow admin role. Upgrade inside the extension.

Overview
Tasks
CMDB
API
Metrics
Monitor
Internals
Instance:sourdoughdev·Version:Yokohama
Instance StateONLINE
System StatusFully Operational
Session Timeout90 minutes
Logged-In Sessions2 (20 active)
Build Nameyokohama-12-18-2024_p1
IP Address10.159.128.43
Instance HealthHealth Score: 90%
🔥 5dSourdough (Chrome Plugin)Dark Mode

Implementation Steps

1

Create GCP service account and download JSON credentials

Navigate to the Google Cloud Console IAM & Admin > Service Accounts section and create a new service account with a descriptive name like 'servicenow-integration'. Assign the following IAM roles: roles/compute.viewer for VM discovery, roles/cloudasset.viewer for comprehensive asset inventory, and roles/pubsub.editor for event-driven integration capabilities. Generate and download the JSON key file for this service account, ensuring you store it securely as it contains the private key needed for authentication. Verify the service account has the necessary permissions by testing API calls using the gcloud CLI or Cloud Shell with the downloaded key file.

2

Install and configure Google Cloud Platform spoke in ServiceNow

Navigate to System Applications > All Available Applications > All and search for 'Google Cloud Platform' spoke, then click Install. After installation completes, go to Integration Hub > Connections & Credentials > Connection & Credential Aliases and create a new alias named 'GCP_Production_Connection'. Set the connection type to 'Custom' and configure the connection URL as 'https://compute.googleapis.com' for the primary Compute Engine API endpoint. Create a corresponding credential alias that will reference the service account credentials you'll configure in the next step, ensuring both aliases use consistent naming conventions for easy identification.

3

Configure OAuth 2.0 credentials with GCP service account JSON

Navigate to Integration Hub > Connections & Credentials > Credentials and create a new OAuth 2.0 credential record. Set the Grant Type to 'JWT Bearer Token' and paste the entire contents of the downloaded GCP service account JSON file into the Private Key field. Configure the Token URL as 'https://oauth2.googleapis.com/token' and set the scope to 'https://www.googleapis.com/auth/cloud-platform' for comprehensive GCP API access. Test the credential by clicking the 'Get Token' button to verify successful authentication, and note the credential sys_id for reference in connection aliases.

ServiceNow Script
// Test credential configuration with a simple API call
var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://compute.googleapis.com/compute/v1/projects/' + project_id + '/zones');
request.setHttpMethod('GET');
request.setRequestHeader('Authorization', 'Bearer ' + token);
var response = request.execute();
gs.info('GCP API Response: ' + response.getBody());
4

Configure Discovery for GCP compute instances and resources

Navigate to Discovery > Discovery Definition and create a new discovery definition for GCP infrastructure with schedule type 'Recurring' and appropriate MID Server selection. Configure the discovery to use the Google Cloud Platform - Compute pattern and specify your GCP project ID in the discovery range configuration. Set up credential mapping by associating your GCP OAuth credential with the discovery definition and configure discovery schedules to run during maintenance windows to minimize performance impact. Test the discovery definition with a quick discovery run to verify successful authentication and resource enumeration before enabling full scheduled discovery.

ServiceNow Script
// Custom discovery script for additional GCP resource types
var gcpDiscovery = new GlideRecord('discovery_definition');
gcpDiscovery.newRecord();
gcpDiscovery.name = 'GCP Production Resources';
gcpDiscovery.type = 'google_cloud_platform';
gcpDiscovery.schedule = '0 2 * * *'; // Daily at 2 AM
gcpDiscovery.credentials = credential_sys_id;
gcpDiscovery.insert();
5

Set up Pub/Sub topic and subscription for event-driven incidents

In the Google Cloud Console, navigate to Pub/Sub > Topics and create a new topic named 'servicenow-incidents' for receiving GCP monitoring alerts and operational events. Create a push subscription pointing to your ServiceNow instance's inbound webhook endpoint at 'https://your-instance.service-now.com/api/now/webhook/gcp-events'. Configure the subscription with appropriate acknowledgment deadline (600 seconds recommended) and retry policy settings to handle temporary ServiceNow unavailability. Set up Cloud Monitoring alert policies to publish messages to this topic when critical infrastructure events occur, such as VM instance failures or high CPU utilization thresholds.

6

Create ServiceNow webhook and incident automation flow

Navigate to System Web Services > Scripted REST APIs and create a new API named 'GCP Event Handler' with resource path '/gcp-events' and HTTP method POST. Implement the scripted REST API to parse incoming Pub/Sub messages, extract relevant alert metadata, and create incident records with appropriate priority and assignment group mapping. Configure the API to validate Pub/Sub JWT tokens for security and handle message deduplication using the Pub/Sub message ID as a correlation identifier. Set up error handling to return appropriate HTTP status codes for successful processing (200) or temporary failures (500) to leverage Pub/Sub retry mechanisms.

ServiceNow Script
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
    var requestBody = request.body.data;
    var pubsubMessage = JSON.parse(requestBody);
    var messageData = JSON.parse(gs.base64Decode(pubsubMessage.message.data));
    
    var incident = new GlideRecord('incident');
    incident.newRecord();
    incident.short_description = 'GCP Alert: ' + messageData.incident.incident_id;
    incident.description = messageData.incident.summary;
    incident.priority = messageData.incident.severity == 'CRITICAL' ? 1 : 3;
    incident.assignment_group = 'Cloud Operations';
    incident.u_gcp_project = messageData.incident.resource.project_id;
    var incidentId = incident.insert();
    
    response.setStatus(200);
    return { 'incident_number': incident.number.toString() };
})(request, response);
7

Configure Integration Hub flow for GCP resource management

Navigate to Integration Hub > Flow Designer and create a new flow triggered by incident creation with condition checking for GCP-sourced incidents. Add GCP spoke actions such as 'Get Compute Instance Details' to enrich incident records with current resource state and configuration information from GCP APIs. Configure the flow to automatically assign incidents based on GCP resource labels, update CMDB relationships, and send notifications to appropriate teams using the instance metadata retrieved from GCP. Include error handling subflows to manage API rate limiting and temporary connectivity issues, ensuring robust operation during peak incident volumes.

ServiceNow Script
// Integration Hub Flow Action Script for GCP enrichment
var gcpAction = new sn_ih_gcp.GCPComputeActions();
var instanceDetails = gcpAction.getInstanceDetails({
    project: incident.u_gcp_project.toString(),
    zone: incident.u_gcp_zone.toString(),
    instance: incident.u_gcp_instance_name.toString(),
    connection: 'GCP_Production_Connection'
});

if (instanceDetails.success) {
    incident.work_notes = 'GCP Instance Status: ' + instanceDetails.result.status + '\n';
    incident.work_notes += 'Machine Type: ' + instanceDetails.result.machineType + '\n';
    incident.update();
}
8

Test integration and validate CMDB population

Execute a test discovery run to verify GCP compute instances, storage buckets, and networking components are properly populated in the ServiceNow CMDB with accurate relationships and attributes. Trigger a test Pub/Sub message to validate the incident creation workflow and verify that incidents contain proper GCP context and assignment routing. Review Discovery logs in Discovery > Discovery Logs to identify any authentication failures or resource enumeration issues, and verify CMDB data quality by checking CI relationships and attribute accuracy. Perform end-to-end testing by simulating a real GCP alert scenario and confirming the complete flow from event detection through incident resolution and CMDB updates.

ServiceNow Script
// Validation script for CMDB GCP data quality
var gcpInstances = new GlideRecord('cmdb_ci_gcp_compute_instance');
gcpInstances.query();
gs.info('Total GCP instances discovered: ' + gcpInstances.getRowCount());

var testPubsub = {
    message: {
        data: gs.base64Encode(JSON.stringify({
            incident: {
                incident_id: 'test-123',
                summary: 'Test GCP integration incident',
                severity: 'CRITICAL'
            }
        }))
    }
};
// Send test message to webhook endpoint for validation

Common Use Cases

Automated GCP compute instance discovery and CMDB population

Discovery jobs automatically scan GCP projects to identify compute instances, persistent disks, and networking components, creating corresponding CI records in ServiceNow CMDB. The integration maps GCP resource labels to ServiceNow CI attributes and establishes relationships between VMs, storage, and network components. This provides infrastructure teams with comprehensive visibility into cloud resources for change management, incident response, and capacity planning workflows.

Real-time incident creation from GCP monitoring alerts

Cloud Monitoring alert policies publish messages to Pub/Sub topics when critical thresholds are breached, such as high CPU utilization, disk space exhaustion, or service availability issues. ServiceNow webhook endpoints consume these messages and automatically create incident records with appropriate priority, assignment groups, and technical details extracted from GCP monitoring data. This enables rapid response to infrastructure issues and maintains audit trails for compliance requirements.

Automated VM lifecycle management through ServiceNow requests

Service catalog requests for GCP compute resources trigger Integration Hub flows that provision new VM instances using the GCP spoke's compute actions. The workflow creates CMDB CI records for new resources, applies consistent labeling and security policies, and updates request fulfillment status with provisioning details. This standardizes cloud resource provisioning while maintaining ServiceNow governance and approval processes for infrastructure changes.

Change management integration for GCP resource modifications

Scheduled maintenance activities and infrastructure changes in ServiceNow trigger automated workflows that modify GCP resources such as instance startup/shutdown, disk attachment, or firewall rule updates. Integration Hub flows validate change approval status before executing GCP API calls and update change records with execution results and resource state changes. This ensures all cloud infrastructure modifications follow ITIL change management processes and maintain compliance audit trails.

Cost optimization through unused resource identification

Discovery data combined with GCP billing API integration identifies underutilized or orphaned cloud resources such as unattached persistent disks, unused static IP addresses, or stopped instances with ongoing storage costs. ServiceNow workflows automatically create tasks for infrastructure teams to review and remediate cost optimization opportunities, tracking potential savings and actual resource cleanup actions. This integration supports FinOps initiatives by providing actionable insights into cloud spending optimization.

Troubleshooting

Discovery fails with 'Invalid credentials' error despite successful token test

Check that the GCP service account has the correct IAM roles assigned and that the roles have been propagated across all regions where resources exist. Navigate to Discovery > Discovery Logs and examine the detailed error messages, which often reveal specific API permission failures. Verify the service account JSON key hasn't expired and test direct API calls using the credentials outside of ServiceNow to isolate authentication issues from Discovery configuration problems.

Pub/Sub messages received but incidents not created in ServiceNow

Review the webhook endpoint logs in System Logs > System Log > All to identify parsing errors or script execution failures in the Scripted REST API. Check that the Pub/Sub message format matches the expected JSON structure in your webhook handler and verify that required fields for incident creation are properly mapped. Test the webhook directly with sample Pub/Sub payloads using REST clients to isolate message processing issues from Pub/Sub delivery problems.

Integration Hub GCP actions timeout or return rate limit errors

Configure retry logic in Integration Hub flows with exponential backoff delays between 1-60 seconds to handle GCP API rate limiting gracefully. Check your GCP project's API quotas in the Cloud Console under IAM & Admin > Quotas and request increases for frequently used APIs like Compute Engine. Implement flow logic to batch API calls and avoid rapid sequential requests that trigger rate limiting, particularly during bulk operations or scheduled maintenance windows.

CMDB CI relationships missing or incorrect for GCP resources

Verify that Discovery patterns for GCP include relationship mapping rules and that the CI Identification Rules are properly configured to match GCP resource naming conventions. Check Discovery > CI Identification Rules for conflicts with existing patterns that might prevent proper CI creation or updates. Review the Discovery > Discovery Logs for relationship creation errors and ensure that parent resources like VPC networks and subnets are discovered before dependent resources like compute instances.

GCP spoke actions fail with SSL certificate verification errors

Ensure the ServiceNow instance can reach Google APIs over HTTPS and that any corporate firewalls or proxies have proper SSL inspection bypass rules for Google Cloud endpoints. Check MID Server configuration if using on-premises deployment and verify that the MID Server can resolve DNS for googleapis.com domains. Update the MID Server's Java certificate store with current root CA certificates if SSL handshake failures persist, and test connectivity using the MID Server test probe functionality.

Duplicate incident creation from repeated Pub/Sub message delivery

Implement idempotency checking in the webhook handler using Pub/Sub message IDs as correlation identifiers and store processed message IDs in a custom table or incident correlation ID field. Configure Pub/Sub subscriptions with appropriate acknowledgment timeouts to prevent message redelivery when ServiceNow processing takes longer than expected. Add deduplication logic to check for existing incidents with the same GCP alert ID before creating new records, and ensure proper HTTP response codes are returned to Pub/Sub for successful message processing.

Pro Tips

  • Implement custom CMDB CI classes that extend the base GCP CI types to capture organization-specific attributes like cost center, environment tags, and compliance metadata from GCP resource labels. This provides richer context for incident assignment and change approval workflows while maintaining upgrade compatibility with the base GCP spoke functionality.
  • Configure Integration Hub flows with parallel processing branches for different GCP resource types to improve discovery performance and reduce overall synchronization time. Use flow logic to prioritize critical infrastructure components like load balancers and databases over less critical resources like storage buckets during discovery operations.
  • Set up custom business rules to automatically populate assignment groups and priority levels based on GCP resource labels and project metadata, enabling dynamic incident routing without manual configuration. This approach scales effectively across multiple GCP projects and environments while maintaining consistent ITSM processes.
  • Leverage ServiceNow's Event Management capabilities alongside GCP integration to correlate multiple related alerts into single incidents, reducing noise and improving operational efficiency. Configure event rules to group related GCP monitoring alerts by resource hierarchy and time windows for more effective incident management.
  • Implement custom reporting and dashboards that combine GCP billing data with ServiceNow CMDB information to provide cost visibility at the service and application level. This enables better FinOps decision-making and helps identify optimization opportunities across cloud infrastructure portfolios.
  • Use ServiceNow's orchestration capabilities to automate common GCP operational tasks like snapshot creation, instance scaling, and security group updates directly from incident and change workflows. This reduces manual effort and ensures consistent execution of standard operating procedures.

Known Limitations

  • The GCP spoke has API rate limits that align with Google Cloud quotas, typically 2000 requests per 100 seconds for Compute Engine API, which may impact large-scale discovery operations or bulk resource management tasks. Consider implementing discovery schedules during off-peak hours and using batched API calls to stay within quota limits while maintaining data freshness requirements.
  • Real-time synchronization is limited to Pub/Sub-enabled services, and some GCP resources like Cloud Storage bucket configurations or IAM policy changes may require scheduled discovery to detect modifications. Not all GCP services support comprehensive event publishing, so critical configuration changes might have delayed visibility in ServiceNow CMDB records.
  • Integration Hub Professional license is required for the GCP spoke functionality, and the number of spoke executions per month may be limited based on your ServiceNow licensing tier. Monitor spoke usage through Integration Hub analytics to avoid unexpected limitations during peak operational periods or large-scale automation scenarios.
  • Cross-region resource discovery can be complex and may require multiple discovery definitions with region-specific configurations, potentially leading to longer discovery times and increased API quota consumption. GCP global resources may not always map cleanly to ServiceNow's location-based CMDB structure without custom configuration.
  • The integration relies on service account permissions, and overly restrictive GCP IAM policies may prevent complete resource enumeration or management capabilities. Balancing security requirements with integration functionality often requires careful IAM role design and may limit some automated operational capabilities.

Frequently Asked Questions

Can the GCP integration discover resources across multiple GCP projects and organizations?

Yes, but each GCP project requires separate discovery definitions and credential configurations in ServiceNow. You'll need to create individual service accounts with appropriate permissions for each project or use organization-level service accounts with cross-project access. The GCP spoke supports multiple connection aliases, allowing you to manage credentials for different projects while maintaining separate discovery schedules and resource grouping in the CMDB.

How does the integration handle GCP resource tagging and custom metadata in ServiceNow?

GCP resource labels are automatically mapped to ServiceNow CI attributes during discovery, and you can create custom CI attribute mappings for organization-specific metadata. The integration supports both standard GCP labels and custom labels, allowing you to maintain consistent tagging strategies across cloud and on-premises resources. Custom attributes can be defined in CI classes to capture additional metadata like cost centers, compliance tags, or operational metadata from GCP resources.

What happens if the ServiceNow MID Server loses connectivity to GCP during discovery?

The MID Server will retry failed discovery operations based on the retry configuration, and Discovery will log connection failures for troubleshooting. Incomplete discovery runs can be restarted manually or will resume automatically on the next scheduled discovery cycle. The integration maintains the last successful discovery state, so temporary connectivity issues won't result in data loss, though resource changes during outages may not be reflected until connectivity is restored and discovery completes successfully.

Can I customize the incident creation logic for different types of GCP alerts?

Absolutely - the webhook handler in the Scripted REST API can be customized to parse different alert types and apply specific business logic for incident categorization, priority assignment, and routing. You can implement conditional logic based on alert severity, resource type, or project metadata to create different incident types or route to specialized assignment groups. Integration Hub flows can also be configured to post-process incidents with additional enrichment or approval workflows based on GCP alert characteristics.

Does the integration support automated remediation actions back to GCP from ServiceNow?

Yes, the GCP spoke includes actions for common remediation tasks like starting/stopping instances, creating snapshots, and modifying firewall rules that can be triggered from ServiceNow workflows. Integration Hub flows can be configured to execute these actions based on incident resolution, change request approval, or scheduled maintenance activities. However, production environments should implement proper approval gates and testing procedures before enabling automated remediation to prevent unintended service disruptions.

How do I monitor the performance and success rate of the GCP integration?

ServiceNow provides several monitoring capabilities including Discovery Dashboard for tracking discovery success rates, Integration Hub Analytics for spoke execution metrics, and Event Log monitoring for webhook processing statistics. You can create custom reports combining discovery logs, integration execution records, and incident creation patterns to track integration health. Set up operational dashboards that monitor key metrics like discovery completion times, API error rates, and incident creation volumes to proactively identify integration issues.

What's the recommended approach for handling GCP billing and cost data in ServiceNow?

While the standard GCP spoke focuses on infrastructure resources, you can extend the integration using custom REST messages to pull GCP billing data through the Cloud Billing API and populate cost-related attributes in CMDB CIs. Create scheduled jobs to retrieve daily or monthly cost data and associate it with discovered resources using project and resource identifiers. This enables cost visibility in ServiceNow dashboards and supports FinOps processes like cost allocation, budget tracking, and resource optimization workflows integrated with your ITSM processes.

Test Your Knowledge

Quick 3-question quiz — see how your ServiceNow skills stack up.

Question 1 of 3Performance

A list view on a table with millions of records is slow. Best fix?

Select an answer to continue