Get Metrics
The Get Metrics operation retrieves the current set of metrics associated with an established metrics context.
HTTP method and URI
GET /api/services/metrics/context/{metrics-context-id}
In this request, the URI variable {metrics-context-id} is the identifier of the metrics context object for which metrics are to be obtained.
Response body contents
On successful completion, the response body contains the set of metrics associated with the metrics context. The response is sent using HTTP chunked transfer encoding and UTF-8 character encoding. A MIME media type of application/vnd.ibm-z-zmanager-metrics is used and is specified in the Content-Type header on the response.
Because performance and scalability are a major concern for the metrics service, the response body is in a terse custom format, rather than being presented as a JSON object. The data type, name, and order information required to parse and interpret the response is provided in a previous Create Metrics Context response.
Data in this format will be delimited by newlines and commas.
Using a partial Extended Backus-Naur Form, where a comma (,) indicates concatenation and curly braces ({}) indicate 0 or more repetitions, we can express the format this way:
MetricsResponse = {MetricsGroup},NL
MetricsGroup = MetricsGroupName,NL,{ObjectValues},NL
MetricsGroupName = StringValue
NL = “\n”
ObjectValues = ObjectURI,NL,Timestamp,NL,ValueRows,NL
Timestamp = LongValue
ObjectURI = StringValue
ValueRows = ValueRow,{ValueRow}
ValueRow = Value,{“,”,Value},NL
Value = BooleanValue | ByteValue | DoubleValue | LongValue | IntegerValue | ShortValue | StringValue
The MetricsGroupName is the name of the metrics group, as a StringValue as defined below.
The Timestamp is the time when
the associated values were buffered (i.e. cached
) on the HMC.
It is expressed as an epoch
timestamp: a LongValue giving the
milliseconds since January 1, 1970, 00:00:00 GMT (just as is expected,
for example, by the constructor of a java.util.Date object).
The ObjectURI is the canonical URI of the object, as a StringValue as defined below.
NL is a single newline character (Unicode U+000A).
Value
will be represented as strings
according to the following rules and limits:- BooleanValue
- Either the string true or the string false.
- ByteValue
- A string representation of a signed decimal integer in the range -128 to 127 (i.e. the range of a signed 8 bit integer).
- DoubleValue
- A string representation of a 64 bit IEEE 754 floating point number in the range +/-4.9E-324 to +/-3.4028235E+38. Note that, although IEEE 754 provides for representations of positive or negative Infinity and NaN, such values are not allowed in the metric data feed and thus will not appear in a metrics service result. For results with a magnitude greater than or equal to 10^-3 and less than 10^7, the string representation will be a dotted decimal (e.g. 1.7, -32.467). For results with magnitudes outside that range, the string representation will be computerized scientific notation (e.g. -4.23E127).
- LongValue
- A string representation of a signed decimal integer in the range -9223372036854775808 to 9223372036854775807 (i.e. the range of a signed 64 bit integer).
- IntegerValue
- A string representation of a signed decimal integer in the range -2147483648 to 2147483647 (i.e. the range of a signed 32 bit integer).
- ShortValue
- A string representation of a signed decimal integer in the range -32768 to 32767 (i.e. the range of a signed 16 bit integer).
- StringValue
- A string starting with a double-quote, ending with a double-quote, and with any embedded double-quotes or backslashes escaped with a preceding backslash (i.e. escaped as \" and \\).
Description
On successful execution status code 200 (OK) is returned, with a response body as described above.
The URI path on the request must designate an existing metrics context for the current API session. If the URI designates an unrecognized context for the API session, then status code 404 (Not Found) is returned.
Note that under some circumstances the metrics service may delete a metrics context, requiring the client to establish a new context in order to resume metric retrievals. For example, the metrics service may choose to delete a given context if the time since the last associated Get Metrics request has exceeded 4 times the anticipated frequency specified when the context was created. In addition, the client may explicitly delete a metrics context with the Delete Metrics Context operation. If the URI designates a context that was once valid for the current API session, but no longer is, then status code 409 (Conflict) is returned.
Authorization requirements
Only metrics referencing managed objects accessible according to the permissions associated with the API session under which the Get Metrics is being issued will be returned. Note that there is no indication through an HTTP status or reason code that results may have been restricted due to authorization restrictions. Rather, success is indicated and the responses are just as if any restricted objects did not exist.
HTTP status and reason codes
On success, HTTP status code 200 (OK) is returned and the response body is provided as described in Response body contents.
The following HTTP status codes are returned for the indicated errors, and the response body is a standard error response body providing the reason code indicated and associated error message.
HTTP error status code | Reason code | Description |
---|---|---|
400 (Bad Request) | Various | Errors were detected during common request validation. See Common request validation reason codes for a list of the possible reason codes. |
404 (Not Found) | 1 | The metrics context ID in the URI ({metrics-context-id}) does not designate a metrics context for the associated API session. |
409 (Conflict) | 1 | The metrics context ID in the URI ({metrics-context-id}) designates a metrics context for the associated API session that is no longer valid. |
Additional standard status and reason codes can be returned, as described in Invoking API operations.
Usage notes
- Repeated metrics retrievals, even consecutive retrievals against a common metrics context, will not necessarily yield metrics for the exact same set of objects. Objects can come and go from the system's inventory due to various circumstances unrelated to the metrics data. The metrics feed for a particular metric group may stop for some reason, and the metrics data may therefore expire from the HMC's buffer (i.e. the metrics cache). The access permissions of a user associated with a metrics context may change, giving the user access to a smaller or larger set of objects (and therefore, perhaps, a smaller or larger set of metrics data).
- It is possible that there may be no metrics to return for one or more metric groups associated with the specified metrics context. For example, data for a metric group may not be buffered on the HMC at the time of the Get Metrics invocation, or authorization restrictions related to objects in a requested metric group may prevent any metrics for that group from being returned. If there is no metric data to be returned for a metric group name, then that group name does not appear in the response body. Furthermore, if there is no metric data to return for any metric group name associated with a context, the response body format above specifies that the body will consist only of a single newline character. This is nonetheless considered a successful response. In other words, an HTTP status code 200 (OK) will still be returned with such a response.