apmmetric.get

Description

integer/array apmmetric.get(object parameters)

The method allows you to retrieve metric data points according to the given parameters.

This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

Parameter Type Description
time_from timestamp Return only data points whose time is at or after the given time.

Parameter behavior:
- required
time_till timestamp Return only data points whose time is before the given time.

Parameter behavior:
- required
types integer/array Return only data points of the given types.

Refer to the APM metric object page for a list of supported metric types.
with_flags_on integer Return only data points that have all of the given flags set.
To specify several flags, use the sum of their values.
with_flags_off integer Return only data points that have none of the given flags set.
To specify several flags, use the sum of their values.
resource_attributes object/array Return only data points with the given resource attributes.
Format: [{"key": "<key>", "value": "<value>", "operator": "<operator>"}, ...].
An empty array returns all data points.

Possible operator values:
0 - (default) Contains;
1 - Equals;
2 - Does not contain;
3 - Does not equal;
4 - Exists;
5 - Does not exist.
resource_attributes_evaltype integer Evaluation method for the conditions in resource_attributes.

Possible values:
0 - (default) And/Or;
2 - Or.
scope_attributes object/array Return only data points with the given scope attributes.
Format: [{"key": "<key>", "value": "<value>", "operator": "<operator>"}, ...].
An empty array returns all data points.

Possible operator values:
0 - (default) Contains;
1 - Equals;
2 - Does not contain;
3 - Does not equal;
4 - Exists;
5 - Does not exist.
scope_attributes_evaltype integer Evaluation method for the conditions in scope_attributes.

Possible values:
0 - (default) And/Or;
2 - Or.
attributes object/array Return only data points with the given attributes.
Format: [{"key": "<key>", "value": "<value>", "operator": "<operator>"}, ...].
An empty array returns all data points.

Possible operator values:
0 - (default) Contains;
1 - Equals;
2 - Does not contain;
3 - Does not equal;
4 - Exists;
5 - Does not exist.
attributes_evaltype integer Evaluation method for the conditions in attributes.

Possible values:
0 - (default) And/Or;
2 - Or.
filter object Return only those results that exactly match the given filter.

Accepts an object, where the keys are property names, and the values are either a single value or an array of values to match against.

Supported properties: resource_schema_url, scope_schema_url, scope_name, scope_version, service_name, metric_name, metric_unit, flags.
search object Return results that match the given pattern (case-insensitive).

Accepts an object, where the keys are property names, and the values are strings to search for. If no additional options are given, this will perform a LIKE "%…%" search.

Supported properties: resource_schema_url, scope_schema_url, scope_name, scope_version, service_name, metric_name, metric_description, metric_unit.
sortfield string/array Sort the result by the given properties.

Possible values: type, resource_schema_url, scope_schema_url, scope_name, scope_version, service_name, metric_name, metric_unit, start_time_unix, time_unix.
offset integer Number of records to skip before returning the result.
countOutput boolean These parameters are described in the reference commentary.
excludeSearch boolean
limit integer
output query
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch boolean

Return values

(integer/array) Returns either:

  • an array of objects;
  • the count of retrieved objects, if the countOutput parameter has been used.

Examples

Retrieving histogram data points

Retrieve the latest data point of the http.server.request.duration histogram metric of the zabbix-frontend service.

Request:

{
    "jsonrpc": "2.0",
    "method": "apmmetric.get",
    "params": {
        "output": ["metric_name", "metric_unit", "time_unix", "count", "sum", "min", "max", "explicit_bounds", "bucket_counts", "exemplars"],
        "time_from": 1790848800,
        "time_till": 1790852400,
        "types": 2,
        "filter": {
            "service_name": "zabbix-frontend",
            "metric_name": "http.server.request.duration"
        },
        "sortfield": "time_unix",
        "sortorder": "DESC",
        "limit": 1
    },
    "id": 1
}

Response:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "metric_name": "http.server.request.duration",
            "metric_unit": "s",
            "time_unix": "1790852390000000000",
            "count": "1842",
            "sum": "412.773",
            "min": "0.0061",
            "max": "1.098",
            "explicit_bounds": ["0.005", "0.05", "0.1", "0.25", "0.5", "1"],
            "bucket_counts": ["0", "211", "904", "512", "167", "41", "7"],
            "exemplars": [
                {
                    "traceid": "dee625f33cb0994e86c5cd4640e3b09c",
                    "spanid": "3f8b2c6d1e9a7054",
                    "value": "1.098",
                    "time_unix": "1790850513439147623",
                    "filtered_attributes": {}
                }
            ]
        }
    ],
    "id": 1
}

See also

Source

CApmMetric::get() in ui/include/classes/api/services/CApmMetric.php.