Best Practices for Raw Data Outbound Metrics API
Select the Resolution
Time series returned by Raw Data Outbound Metrics API are aggregated in time buckets, the resolution indicates the size of a time bucket.
Example: with resolution “5Mi” (5 minutes), time series are aggregated per time bucket of 5 minutes while with resolution “D”, time series are aggregated per time bucket of 1 day. Time buckets boundaries are fixed, they always start at the beginning of a day 00:00:00 (00 hour, 00 minutes, 00 seconds). For example, with resolution “5Mi”, time buckets are the following: “00:00:00-00:04:59”, “00:05:00-00:09:59”, “00:10:00-00:14:59”, … , “23:55:00-23:59:59”.
If a requested period covers, even partially, a time bucket, then the complete time bucket is returned. For example, if the requested period is [for=“01.01.2024 00:01:00” to=“01.01.2024 00:03:00”] with resolution “5Mi” then only one time bucket is returned: [01.01.2024 00:00:00 - 01.01.2024 00:04:59]. If requested period is [for=“01.01.2024 00:02:00” to=“01.01.2024 00:05:00”] with resolution “5Mi” then two time buckets are returned: [01.01.2024 00:00:00 - 01.01.2024 00:04:59] and [01.01.2024 00:05:00 - 01.01.2024 00:09:59].
When resolution R (Raw) is supported, data is not aggregated in time buckets and the raw timestamps are returned. If resolution R is not supported, the time buckets with smallest resolution are returned by the data provider.
When resolution P (Period) is supported, all data are aggregated in a single time bucket, meaning that a single data point is returned by the data provider corresponding to the selected period.
Select the period
There are three ways to select the period to export.
Export a single data point
If only the resolution is passed to the interface and no period (parameter “period” or parameters “from” and “to” are not set), then only one data point is returned. For example if you select resolution “5Mi”, then the current “5Mi” time bucket is returned by the interface. If the current time is “08:17:47” then the current time bucket “08:15:00-08:19:59” is returned. As the current time bucket is not completed, we can use parameter ”shift” to request previous time bucket. In this case with parameter “shift=1”, we’ll get previous time bucket “08:10:00-08:14:59”. It is possible to shift by one ore more time buckets to make sure the time bucket is complete and all the data have been collected properly on SAP Cloud ALM Side (data collection latency). Remark: resolutions R (Raw) and (P) must be used with a period (see after).
-
https://{{CALM_URL}}/api/calm-metrics/v1/metrics?version=V1&provider=hm&dimensions=serviceType,serviceName,serviceId,metricName&prefix=hm&metrics=measure:value&serviceId=487f86d3-12ec-4f3a-a4e3-3ea1c894dde1&resolution=5Mi&shift=1
-
If the interface is called at 10:18:18, then the following time bucket is returned: [10:10:00-10:14:59]
Export a semantic period
With parameter “period” in addition to the parameter “resolution” you can set a period of time to collect. For example ”L6H” indicate that you want to export the last 6 hours of data (doesn’t include the current time bucket) while “C6H” indicates that you want to export the current 6 hours of data (include the current time bucket). With prefix “C” (current), the current time bucket is included, while with prefix “L” (last) the current time bucket is not included. In this case the parameter “shift” is not taken into account.
-
https://{{CALM_URL}}/api/calm-metrics/v1/metrics?version=V1&provider=hm&dimensions=serviceType,serviceName,serviceId,metricName&prefix=hm&metrics=measure:value&serviceId=487f86d3-12ec-4f3a-a4e3-3ea1c894dde1&period=L30Mi&resolution=10Mi
-
If the interface is called at 20:57:27, then the following time buckets are returned by the interface: [20:20:00-20:29:59], [20:30:00-20:39:59], [20:40:00-20:49:59]
Export an absolute period
With parameters “from” and “to” in addition to the parameter “resolution” you can select an absolute time period. Parameter “timestampFormat” indicates the format for “from” and “to” parameter. Format “analytics” (the default) is human oriented while format “unix” can be more convenient to use from a program. In this case the parameter “shift” is not taken into account.
-
https://{{CALM_URL}}/api/calm-metrics/v1/metrics?version=V1&provider=rum&dimensions=request,requestType,serviceType,serviceId,serviceName,user&metrics=measure:responseTime&serviceId=487f86d3-12ec-4f3a-a4e3-3ea1c894dde1&from=20240901200000&to=20240901230000&resolution=H×tampFormat=analytics
-
The following time buckets are returned by the interface: [2024-09-01 20:00:00 - 2024-09-01 20:59:59], [2024-09-01 21:00:00 - 2024-09-01 21:59:59], [2024-09-01 22:00:00 - 2024-09-01 22:59:59], [2024-09-01 23:00:00 - 2024-09-01 23:59:59]
Control the outbound volume
Monitor the volume
-
Outgoing Data Volume : Outgoing data volume. Daily value for the current month.
Use compression
Use Gzip compression when your API client support it.
Example
Set HTTP Header “Accept-Encoding”:” gzip, deflate, br”.
Best compression ratio is obtained by Gzip with text or json format but when your API Client doesn't support Gzip decompression, prefer format protobuf-binary to protobuf-json or text.
Example
-
Gzip not supported by the client.
-
https://{{CALM_URL}}/api/calm-metrics/v1/metrics?version=V1&provider=rum&dimensions=request,requestType,serviceType,serviceId,serviceName,user&prefix=rum&resolution=15Mi&metrics=measure:responseTime,measure:users&shift=1&serviceId=bfcd7461-8f46-4822-87e9-248e4c3ed270&format=protobuf-json
-
https://{{CALM_URL}}/api/calm-metrics/v1/metrics?version=V1&provider=rum&dimensions=request,requestType,serviceType,serviceId,serviceName,user&prefix=rum&resolution=15Mi&metrics=measure:responseTime,measure:users&shift=1&serviceId=bfcd7461-8f46-4822-87e9-248e4c3ed270&format=protobuf-binary
Avoid export overlaps
If you setup a job to extract data from an interface, make sure the job frequency corresponds to the period of data collected. If you setup the job every 5 minutes to collect 30 minutes of data, then you’ll extract 6 times the same data.
-
https://{{CALM_URL}}/api/calm-metrics/v1/metrics?version=V1&provider=rum&dimensions=request,requestType,serviceType,serviceId,serviceName,user&prefix=rum&period=L15Mi&resolution=5Mi&metrics=measure:responseTime,measure:users&shift=0&serviceId=bfcd7461-8f46-4822-87e9-248e4c3ed270&format=protobuf-binary
-
This interface call should be scheduled every 15 minutes. Make sure to schedule the job not too close to the end of the time bucket to make sure to not miss any data points due to to the data collection latency. For example, the job could be scheduled every 15 minutes starting at 00:20:00, to leave a 5 minutes gap with the end of the collected period. At "00:20:00" the job collects the time bucket "00:00:00 - 00:14:59", at "00:35:00" the job collects the time bucket "00:15:00 - 00:29:59"...
Export only needed dimensions
Export only the dimensions you need. Useless dimensions and drill-downs can significantly increase the size exported data.
Example
Collecting less dimensions and measures.
-
https://{{CALM_URL}}/api/calm-metrics/v1/metrics?version=V1&provider=hm&dimensions=serviceType,serviceName,serviceId,metricName,metricLabel&metrics=measure:value,measure:usage,measure:okStatus,measure:warningStatus,measure:criticalStatus,measure:limit&prefix=hm&resolution=5Mi&shift=1&format=protobuf-json&serviceId=487f86d3-12ec-4f3a-a4e3-3ea1c894dde1
-
https://{{CALM_URL}}/api/calm-metrics/v1/metrics?version=V1&provider=hm&dimensions=metricName&metrics=measure:value&prefix=hm&resolution=5Mi&shift=1&format=protobuf-json&serviceId=487f86d3-12ec-4f3a-a4e3-3ea1c894dde1
Filter the Data
Use the filtering capability to export only the data you need.
Example
Collecting a single metric instead of all metrics.
-
https://{{CALM_URL}}/api/calm-metrics/v1/metrics?version=V1&provider=hm&dimensions=serviceType,serviceName,serviceId,metricName,metricLabel&metrics=measure:value,measure:limit&prefix=hm&resolution=5Mi&shift=1&format=protobuf-json&serviceId=487f86d3-12ec-4f3a-a4e3-3ea1c894dde1
-
https://{{CALM_URL}}/api/calm-metrics/v1/metrics?version=V1&provider=hm&dimensions=serviceType,serviceName,serviceId,metricName,metricLabel&metrics=measure:value,measure:limit&prefix=hm&resolution=5Mi&shift=1&format=protobuf-json&serviceId=487f86d3-12ec-4f3a-a4e3-3ea1c894dde1&metricId=f36b00a7-d6f6-3bf6-8f83-97b108c27cb2