Gets data points of the specified metrics.
You can receive either one aggregated data point per tuple (unique combinations of metric—dimension—dimension value) or a list of data points per tuple. See the description of the resolution parameter of the request for more information.
The following limits apply:
:sort
transformation doesn't affect these) are processed and the rest are ignored.These limits apply to the datapoints that the query reads in the database. The amount of datapoints in the final result might be different. For example, if the :fold
transformation is used, the query reads multiple data points but returns just one aggregated data point per tuple.
The request produces one of the following types of payload, depending on the value of the Accept request header:
application/json
text/csv; header=present
—a CSV table with header rowtext/csv; header=absent
—a CSV table without header rowIf no Accept header is provided with the request, an application/json
payload is returned.
GET | SaaS | https://{your-environment-id}.live.dynatrace.com/api/v2/metrics/query |
Environment ActiveGateCluster ActiveGate | https://{your-activegate-domain}:9999/e/{your-environment-id}/api/v2/metrics/query |
To execute this request, you need an access token with metrics.read
scope.
To learn how to obtain and use it, see Tokens and authentication.
Selects 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 (~
):
"
)~
)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.
The desired resolution of data points.
You can use one of the following options:
Valid units for the timespan are:
m
: minutesh
: hoursd
: daysw
: weeksM
: monthsq
: quartersy
: yearsIf not set, the default is 120 data points.
For example:
resolution=10m
resolution=3w
The start of the requested timeframe.
You can use one of the following formats:
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.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
: minutesh
: hoursd
: daysw
: weeksM
: monthsy
: yearsIf not set, the relative timeframe of two hours is used (now-2h
).
The end of the requested timeframe.
You can use one of the following formats:
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.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
: minutesh
: hoursd
: daysw
: weeksM
: monthsy
: yearsIf not set, the current timestamp is used.
Specifies the entity scope of the query. Only data points delivered by matched entities are included in response.
You must set one of these criteria:
type("TYPE")
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("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.mzId(123)
mzName("value")
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.healthState("HEALTHY")
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 timelt
: earlier than the specified timegte
: later than or at the specified timegt
: later than the specified time<attribute>("value1","value2")
and <attribute>.exists()
. To fetch the list of available attributes, execute the GET entity type request and check the properties field of the response.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.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.
The 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").Syntax or validation error. From and to parameters, entitySelector or resolution are incorrect individually or in their combined meaning.
A metric has not been found.
Not acceptable. The requested media type is not supported. Check the Accept header of your request.
MetricData
objectA list of metrics and their data points.
Deprecated. This field is returned for compatibility reasons. It always has the value of null
.
The timeslot resolution in the result.
The total number of primary entities in the result.
Has the 0
value if none of the requested metrics is suitable for pagination.
A list of warnings
MetricSeriesCollection
objectData points of a metric.
A list of filtered metric keys along with filters that have been applied to these keys, from the optionalFilter
parameter.
The ratio of queried data points divided by the maximum number of data points per metric that are allowed in a single query.
The ratio of queried dimension tuples divided by the maximum number of dimension tuples allowed in a single query.
The key of the metric.
If any transformation is applied, it is included here.
A list of potential warnings that affect this ID. For example deprecated feature usage etc.
AppliedFilter
objectOptional filters that took effect.
The keys of all metrics that this filter has been applied to.
Can contain multiple metrics for complex expressions and always at least one key.
Filter
objectA dimensional or series filter on a metric.
For filters that match a dimension against a valkue, such as eq
or ne
, holds the value to compare the dimension against.
For the operands of series
filters that match against a number, holds the number to compare against.
A way of viewing a series as a single value for the purpose of sorting or series-based filters.
If the type applies to a dimension, then holds the target dimension.
If the type applies to n dimensions, then holds the target dimensions. Currently only used for the remainder
filter.
Type of this filter, determines which other fields are present.Can be any of:
eq
,ne
,prefix
,in
,remainder
,suffix
,contains
,existsKey
,series
,or
,and
,not
,ge
,gt
,le
,lt
,otherwise
.and
contains
eq
existsKey
ge
gt
in
le
lt
ne
not
or
otherwise
prefix
remainder
series
suffix
Invocation
objectInvocation of a function, e.g. the entitySelector
function.
Arguments to pass to the function, e.g. entity selector source code.
Function that is invoked, e.g. entitySelector
.
Rollup
objectA way of viewing a series as a single value for the purpose of sorting or series-based filters.
AUTO
AVG
COUNT
MAX
MEDIAN
MIN
PERCENTILE
SUM
VALUE
MetricSeries
objectData points per dimension of a metric.
The data is represented by two arrays of the same length: timestamps and values. Entries of the same index from both arrays form a timestamped data point.
Deprecated, refer to dimensionMap
instead.
The ordered list of dimensions to which the data point list belongs.
Each metric can have a certain number of dimensions. Dimensions exceeding this number are aggregated into one, which is shown as null
here.
A list of timestamps of data points.
The value of data point for each time from this array is located in values array at the same index.
A list of values of data points.
The timestamp of data point for each value from this array is located in timestamps array at the same index.
MetricQueryDQLTranslation
objectMetric query translation to DQL.
Error message - only present if the status is not supported
The DQL query corresponding to the metric query
The status of the DQL translation, either success
or not supported
not supported
success
{"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."]}
Dynatrace stores data in time slots. The MetricValue object shows the ending timestamp of the slot. If the time, set in the from or to parameters of your query, falls within the data time slot, this time slot is included in the response.
If the timestamp of the last data slot lays outside of the specified timeframe, the last data point of the response has a later timestamp than the specified in to query parameter.
Dynatrace does not predict future data. The timestamp of the last data point may lay in the future, due to data slots principle, described above. In this case, this data slot has incomplete data.
In these examples, the requests query the data points of the builtin:host.cpu.usage and builtin:host.cpu.idle metrics.
The timeframe is set to last 5 minutes. To achieve that, the from query parameter is set to now-5m
.
Only data from these two hosts (HOST-0990886B7D39FE29 and HOST-0956C3557E9109C1) is included in the response. To achieve this, the entitySelector query parameter is set to type("dt.entity.host"),entityId("HOST-0990886B7D39FE29")
.
Because host is a dimension of the queried metrics, you can achieve the same filtering by applying the :filter
transformation to the metrics themselves by setting the metricSelector query parameter to builtin:host.cpu.(usage,idle):filter(or(eq("dt.entity.host","HOST-0990886B7D39FE29"),eq("dt.entity.host","HOST-0956C3557E9109C1")))
and omitting entitySelector as redundant.
The difference between the queries is the representation of data—the first shows the list of data points, while the second shows just one aggregated data point for each series (the :fold
transformation is applied at the end).
The API token is passed in the Authorization header.
The response is in application/json
format.