With the New Relic dashboards API you can use NerdGraph to build your dashboards. This document explains the different types of widgets you can add to your dashboards, and how to create and get them using the API.
ヒント
If you're using the deprecated Insights Dashboard API, we have a migration guide that helps you transition to using the new API.
Widget schema and types
The widget GraphQL schema for query and mutation outputs looks like this:
type Widget {
id
visualization
layout
title
linkedEntities
configuration
rawConfiguration
}
Where:
id: The id of the widget.
visualization: The widget’s visualization type, as a string. For example: viz.line, viz.area. See the examples below.
layout: The widget's position and size in the dashboard. The maximum amount of columns is 12.
title: The title of the widget.
linkedEntities: Dashboard Entities related to the widget. Currently it only supports dashboard entities. It is used by the facet linking feature.
rawConfiguration: The untyped configuration of the widget. It’s a free-form way (JSON scalar) of storing widget properties not covered by the typed configuration such as heatmap, histogram, bullet, funnel, etc. In this case configuration is null and rawConfiguration holds all the data required by the widget.
Types of widgets
The dashboards API supports typed and untyped widgets:
Typed widgets are area, bar, billboard, line, markdown, pie, and table. They can be built directly using NerdGraph, which provides assistance with the required fields.
As an input:
You only need to provide the configuration.
visualization can be null as long as it can be inferred from the provided configuration.
As an output, the API will provide the configuration you provided plus the raw representation in JSON at rawConfiguration. Therefore, rawConfiguration is always a superset of all widget configurations.
For untyped widgets, we know and validate the shape of the JSON provided. For example, a heatmap has a specific configuration we know in advance, so we can validate it.
As an input:
configuration is not considered in this case.
rawConfiguration must be provided. See the examples below.
visualization cannot be null and it should be a fixed string like viz.heatmap or viz.bullet.
As an output, the API answers exactly with what was provided in the input.
Typed widget definitions
Area
Area supports multiple nrql queries.
Widget data element
Description
accountId
Integer
Source account to fetch data from.
query
String
The NRQL query that provides the data for the widget.
Duration of the requested time window, in milliseconds.
When provided with endTime, the time window is set to the last x milliseconds ending at the specified time.
If endTime is null, the time window is set to the last x milliseconds ending now.
endTime
Long
Optional. End of the time window, in milliseconds.
entityIds
[Integer]
Array of source agent Ids to fetch data from.
metrics
[Object]
For typeSCOPE_BREAKDOWN only. List of metrics to be fetched.
type
String
Type of the predefined chart. It can be: APPLICATION_BREAKDOWN, BACKGROUND_BREAKDOWN, BROWSER_BREAKDOWN, GC_RUNS_BREAKDOWN, SCOPE_BREAKDOWN, SOLR_BREAKDOWN.
The NRQL query that provides the data for the widget.
{
widgets: {
visualization: "viz.funnel"
configuration: null
rawConfiguration: {
nrqlQueries: [
{
accountId: 12345678,
query: "SELECT funnel(SESSION,
WHERE name ='Controller/about/main' AS 'Step 1',
WHERE name ='Controller/about/careers' AS 'Step 2')
FROM PageView"
}
]
}
}
}
{
"visualization": "viz.funnel"
"configuration": null
"rawConfiguration": {
"nrqlQueries": [
{
"accountId": 12345678,
"query": "SELECT funnel(SESSION,
WHERE name ='Controller/about/main' AS 'Step 1',
WHERE name ='Controller/about/careers' AS 'Step 2')
FROM PageView"
}
]
}
}
Heatmap
Widget data element
Description
accountId
Integer
Source account to fetch data from.
query
String
The NRQL query that provides the data for the widget.
Optional. An array of additional entities to include. The target is the entity downstream, while the source is upstream. Type, vendor, target, and source are optional.
deemphasizedConditions
[Object]
Optional. Entities with these conditions have a faded appearance in the map.
hiddenEntities
[Object]
Optional. Entities to be excluded from the map.
primaryEntities
[Object]
The primary entities which start the map (most upstream).