Skip to main content

Query Metric

The following limits apply:

  • The amount of aggregated data points in the response is limited to 1,000
  • The amount of series in the response is limited to 1,000
    • The amount of data points per series is limited to 10,080 (minutes of one week)
    • The overall amount of data points is limited to 100,000

The dataPointCountRatio specifies the ratio of queried data points divided by the maximum number of data points per metric that are allowed in a single query. The dimensionCountRatio specifies the ratio of queried dimension tuples divided by the maximum number of dimension tuples allowed in a single query.

Basic Parameters

ParameterDescription
Metric SelectorSelects metrics for the query by their keys. You can select up to 10 metrics for one query.

You can specify multiple metric keys separated by commas (for example, metrickey1,metrickey2). To select multiple metrics belonging to the same parent, list the last part of the required metric keys in parentheses, separated by commas, while keeping the common part untouched. For example, to list the builtin:host.cpu.idle and builtin:host.cpu.user metric, write: builtin:host.cpu.(idle,user).



If the metric key contains any symbols you must quote (") the key. The following characters inside of a quoted metric key must be escaped with a tilde (~):

Quotes (")
Tildes (~)

For example, to query the metric with the key of ext:selfmonitoring.jmx.Agents: Type "APACHE" you must specify this selector:

"ext:selfmonitoring.jmx.Agents: Type ~"APACHE~""

You can set additional transformation operators, separated by a colon (:). See Metrics selector transformations in Dynatrace Documentation for additional information on available result transformations and syntax.

Advanced Parameters

ParameterDescription
Entity SelectorSpecifies the entity scope of the query. Only data points delivered by matched entities are included in response.

You must set one of these criteria:

Entity type: type("TYPE")
Dynatrace entity ID: entityId("id"). You can specify several IDs, separated by a comma (entityId("id-1","id-2")). All requested entities must be of the same type.

You can add one or more of the following criteria. Values are case-sensitive and the EQUALS operator is used unless otherwise specified.

Tag: tag("value"). Tags in [context]key:value, key:value, and value formats are detected and parsed automatically. Any colons (:) that are part of the key or value must be escaped with a backslash(\). Otherwise, it will be interpreted as the separator between the key and the value. All tag values are case-sensitive.
Management zone ID: mzId(123)
Management zone name: mzName("value")
Entity name:
entityName.equals: performs a non-casesensitive EQUALS query.
entityName.startsWith: changes the operator to BEGINS WITH.
entityName.in: enables you to provide multiple values. The EQUALS operator applies.
caseSensitive(entityName.equals("value")): takes any entity name criterion as an argument and makes the value case-sensitive.
Health state (HEALTHY,UNHEALTHY): healthState("HEALTHY")
First seen timestamp: firstSeenTms.<operator>(now-3h). Use any timestamp format from the from/to parameters.
The following operators are available:
lte: earlier than or at the specified time
lt: earlier than the specified time
gte: later than or at the specified time
gt: later than the specified time
Entity attribute: ("value1","value2") and .exists(). To fetch the list of available attributes, execute the GET entity type request and check the properties field of the response.
Relationships: fromRelationships.<relationshipName>() and toRelationships.<relationshipName>(). This criterion takes an entity selector as an attribute. To fetch the list of available relationships, execute the GET entity type request and check the fromRelationships and toRelationships fields.
* Negation: not(<criterion>). Inverts any criterion except for type.

For more information, see Entity selector in Dynatrace Documentation.

To set several criteria, separate them with a comma (,). For example, type("HOST"),healthState("HEALTHY"). Only results matching all criteria are included in the response.

The maximum string length is 2,000 characters.

Use the GET /metrics/{metricId} call to fetch the list of possible entity types for your metric.

To set a universal scope matching all entities, omit this parameter.
FromThe start of the requested timeframe.

You can use one of the following formats:
Timestamp in UTC milliseconds.
Human-readable format of 2021-01-25T05:57:01.123+01:00. If no time zone is specified, UTC is used. You can use a space character instead of the T. Seconds and fractions of a second are optional.
Relative timeframe, back from now. The format is now-NU/A, where N is the amount of time, U is the unit of time, and A is an alignment. The alignment rounds all the smaller values to the nearest zero in the past. For example, now-1y/w is one year back, aligned by a week.
You can also specify relative timeframe without an alignment: now-NU.
Supported time units for the relative timeframe are:
m: minutes
h: hours
d: days
w: weeks
M: months
* y: years

If not set, the relative timeframe of two hours is used (now-2h).
Management Zone SelectorThe management zone scope of the query. Only metrics data relating to the specified management zones are included to the response.

You can set one or more of the following criteria. Values are case-sensitive and the EQUALS operator is used. If several values are specified, the OR logic applies.

mzId(123,456)
mzName("name-1","name-2")
To set several criteria, separate them with a comma (,). For example, mzName("name-1","name-2"),mzId(1234). Only results matching all of the criteria are included in the response.For example, to list metrics that have the id 123 OR 234 AND the name name-1 OR name-2, use this mzSelector: `mzId(123,234),mzName("name-1","name-2").
ResolutionThe desired resolution of data points.

You can use one of the following options:
The desired amount of data points. This is the default option. This is a reference number of points, which is not necessarily equal to the number of the returned data points.
The desired timespan between data points. This is a reference timespan, which is not necessarily equal to the returned timespan. To use this option, specify the unit of the timespan.

Valid units for the timespan are:
m: minutes
h: hours
d: days
w: weeks
M: months
q: quarters
y: years

If not set, the default is 120 data points.

For example:

Get data points which are 10 minutes apart: resolution=10m
* Get data points which are 3 weeks apart: resolution=3w.
ToThe end of the requested timeframe.

You can use one of the following formats:
Timestamp in UTC milliseconds.
Human-readable format of 2021-01-25T05:57:01.123+01:00. If no time zone is specified, UTC is used. You can use a space character instead of the T. Seconds and fractions of a second are optional.
Relative timeframe, back from now. The format is now-NU/A, where N is the amount of time, U is the unit of time, and A is an alignment. The alignment rounds all the smaller values to the nearest zero in the past. For example, now-1y/w is one year back, aligned by a week.
You can also specify relative timeframe without an alignment: now-NU.
Supported time units for the relative timeframe are:
m: minutes
h: hours
d: days
w: weeks
M: months
* y: years

If not set, the current timestamp is used.

Example Output

{
"nextPageKey": "null",
"resolution": "1h",
"result": [
{
"data": [
{
"dimensionMap": {
"dt.entity.disk": "DISK-F1266E1D0AAC2C3F",
"dt.entity.host": "HOST-F1266E1D0AAC2C3C"
},
"dimensions": [
"HOST-F1266E1D0AAC2C3C",
"DISK-F1266E1D0AAC2C3F"
],
"timestamps": [
3151435100000,
3151438700000,
3151442300000
],
"values": [
11.1,
22.2,
33.3
]
},
{
"dimensions": [
"HOST-F1266E1D0AAC2C3C",
"DISK-F1266E1D0AAC2C3D"
],
"timestamps": [
3151435100000,
3151438700000,
3151442300000
],
"values": [
111.1,
222.2,
333.3
]
}
],
"dataPointCountRatio": "0.1211",
"dimensionCountRatio": "0.0322",
"metricId": "builtin:host.disk.avail"
},
{
"data": [],
"metricId": "builtin:host.cpu.idle:filter(eq(\"dt.entityhost\",HOST-123))",
"warnings": [
"The dimension key `dt.entityhost` has been referenced, but the metric has no such key."
]
}
],
"totalCount": 3,
"warnings": [
"The dimension key `dt.entityhost` has been referenced, but the metric has no such key."
]
}

Workflow Library Example

Query Metric with Dynatrace and Send Results Via Email

Workflow LibraryPreview this Workflow on desktop