Advanced query support for AWS and Azure
Summarize
Summary of Advanced query support for AWS and Azure
This feature enables ServiceNow customers to create advanced, JSON-formatted queries for Service Observability dashboard charts that integrate with AWS and Azure data sources. Advanced queries support most vendor-specific query languages, allowing you to copy queries directly from your cloud provider's UI or dashboards and paste them into Service Observability for customized metric visualization.
Show less
Key Features
- AWS Advanced Queries: Utilize JSON queries based on the AWS GetMetricData API or CloudWatch dashboard widgets to retrieve metrics like CPU utilization or load balancer health. Queries can include template variables such as
${ENTITIESELB}to dynamically represent multiple resource instances. - Template Variables for AWS: These enable flexible filtering by resource identifiers (e.g., ELB, RDS, Lambda) and time ranges (
${START}and${END}) matching user selections in the Service Observability UI. - Azure Advanced Queries: Import JSON chart definitions exported from the Azure dashboard UI. The JSON must specify metrics with resource metadata, including resource IDs or template variables, to ensure correct data retrieval.
- Direct Import: As of version 1.10, you can import charts directly from AWS and Azure, simplifying dashboard setup.
Practical Application and Benefits
By leveraging advanced query support, you can:
- Customize Service Observability charts with precise, vendor-specific metrics.
- Use dynamic template variables to scale queries across multiple resources without manual updates.
- Integrate cloud-native monitoring data into ServiceNow dashboards for a consolidated view of service health.
- Save time by importing existing AWS CloudWatch and Azure dashboard charts directly into ServiceNow.
This capability enhances your ability to monitor cloud resources effectively within ServiceNow, enabling proactive service management based on detailed, customizable metrics.
Understand how to create advanced queries for Service Observability dashboard charts.
Advanced queries in Service Observability support most vendor-specific query languages. Simply copy a query from the observability chart and paste it into the Advanced query field in Service Observability. However, queries to AWS and Azure must be JSON-formatted and follow the guidelines outlined in this topic.
AWS advanced queries
Data from AWS is accessed using the GetMetricData API. Queries can be either a direct request in JSON format to that API or they can be in the form of a DashboardBody metric widget. For example,
you can use the widget representation for a chart that exists on an AWS CloudWatch dashboard.
Direct GetMetricData request
The following example shows a GetMetricData JSON query for a chart that displays the average CPU Utilization for an ELB instance.
{
"StartTime": 1637061900, // can be replaced with “${START}”
"EndTime": 1637074500, // can be replaced with “${END}”
"MetricDataQueries": [
{
"Expression": "SELECT AVG(CPUUtilization) FROM SCHEMA(\"AWS/EC2\", InstanceId)",
"Id": "q1",
"Period": 300,
"Label": "Cluster CpuUtilization"
},
{
"Id": "m1",
"Label": "Unhealthy Behind Load Balancer",
"MetricStat": {
"Metric": {
"Namespace": "AWS/ApplicationELB",
"MetricName": "UnHealthyHostCount",
"Dimensions": [
{
"Name": "LoadBalancer",
"Value": "app/EC2Co-EcsEl-EXAMPLE69Q/fdd2210e799e4376" // can be replaced with “${ENTITIES}” or “${ENTITIES_ELB}”
}
]
},
"Period": 300,
"Stat": "Average"
}
}
]
}
Copied source for a single object in an AWS CloudWatch dashboard
This example shows the JSON copied directly from a single object in the widgets list of the Source view for a CloudWatch dashboard.
{
"type": "metric",
"x": 9,
"y": 0,
"width": 15,
"height": 5,
"properties": {
"view": "timeseries",
"metrics": [
[ "AWS/ApplicationELB", "RequestCountPerTarget", "TargetGroup", "targetgroup/api-tg/1e3dc9z72fe21ca2", "AvailabilityZone", "us-west-1a" ],
["...", "targetgroup/api-tg-cs/82a1db5f950073e1", ".", "." ]
],
"region": "us-west-1"
}
}
Value field for the LoadBalancer dimension with ${ENTITY_ELB}. The query is run against each ELB instance associated with the selected service in the Service Observability UI. The chart displays a time series for each one.| AWS field | Template variable |
|---|---|
Dimensions[n].Value |
The |
StartTime |
START |
EndTime |
END |
Azure advanced queries
You run an advanced query for an Azure-based chart by copying the source from the Azure UI and pasting it in the Advanced query field.
- In the Azure UI, export and download the dashboard.
- Copy the JSON for a single chart. Charts are located at
properties.lenses[i].parts[j].metadata.settings.content.options.chart. - Paste the JSON into the query field. The JSON must include at least the following:
The``` { “metrics”: [ “name”: string, “resourceMetadata”: { “id”: string } ] } ```idfield must be either an Azure resource ID or a template variable.