Performing metric operations with the REST API
The following section provides a list of supported endpoints and an overview about running these endpoints. Before you run an endpoint, you must authenticate yourself. For more information, see
Access and authentication for the REST API
Metric Ingestion
POST /insert
https://<Host:Port>/metrics-gateway-service/api/v1.0/insert
Content-Type: Application/json
Authorization: Bearer <Jwt_Token>/<apiKey>
For instructions on obtaining the JWT token, see
Access and authentication for the REST API.
.
#Following is an example of the PATROL Agent metrics data format
[
{
"labels": {
"metricName": "<metric name>",
"hostname": "<hostname>" ,
"entityId": "<source name>:<hostname>:<entityTypeId>:<entityName>",
"entityTypeId": "<Name of the entityTypeId>",
"entityName": "<Name of entity name>",
"hostType": "<type of host>",
"isKpi": <isKpi>,
"unit": "<unit type>",
"entityId":"<entity ID>",
"instanceName":"<instance name>"
"source": "<source type>"
}
"samples": [
{
"value": <value>,
"timestamp": <timestamp>
},
{
"value": <value>,
"timestamp": <timestamp>
}
]
}
]
[
{
"labels":{
"metricName":"offset",
"hostname":"clm-HostA",
"source":"nagios",
"entityTypeId":"segmentEntityType1",
"entityName":"entitysegment",
"hostType":"server",
"isKpi":"True",
"unit":"Percent",
"entityId":"nagios:clm-pun-microbots77:segmentEntityType1:entitysegment",
"instanceName":"segment"
},
"samples":[
{
"value":90,
"timestamp":1639030067000
}
]
},
{
"labels":{
"metricName":"offset",
"hostname":"clm-HostA",
"source":"nagios",
"entityTypeId":"segmentEntityType2",
"entityName":"entitytower1",
"hostType":"server",
"isKpi":"True",
"unit":"Percent",
"parentEntityName":"entitysegment",
"parentEntityTypeId":"segmentEntityType1",
"entityId":"nagios:clm-pun-microbots77:segmentEntityType2:entitytower1",
"instanceName":"tower1",
"isDeviceMappingEnabled":"true"
},
"samples":[
{
"value":90,
"timestamp":1639030067000
}
]
Parameter Name | Value Type | Mandatory | Description |
---|---|---|---|
| Object (Map) | Yes | The following parameters are supported:
|
| Object (List) | No | List of samples. Samples contain the monitored data value and the timestamp details. The following parameters are supported:
|
Response codes:
- 200 (OK): Successful response
- 400 (Bad Request): Unsuccessful response
- 401 (Unauthorized): Unsuccessful response
POST /prometheus
https://<Host:Port>/metrics-gateway-service/api/v1.0/prometheus
Content-Type : application/x-www-form-urlencodedapplication/x-protobuf
Authorization: Bearer <Jwt_Token>/<apiKey>
Content-Encoding : Snappy
For instructions on obtaining the JWT token, see
Access and authentication for the REST API.
.
To send Prometheus metrics to BMC Helix Operations Management, following exporters are supported:
- Node exporter
- Windows exporter
- Oracle database exporter
- Kafka exporter
- Redis exporter
Response codes:
- 200 (OK): Successful response
- 400 (Bad Request): Unsuccessful response
- 401 (Unauthorized): Unsuccessful response
POST /delete
You can use this API to delete only the data that is inserted using the /insert API.
https://<Host:Port>/metrics-gateway-service/api/v1.0/delete
Content-Type: Application/json
Authorization: Bearer <Jwt_Token>/<apiKey>
For instructions on obtaining the JWT token, see
Access and authentication for the REST API.
.
{
"devices": [
{
"hostname": "<hostname>",
"source": "<source name>"
}
]
}
{
"devices": [
{
"hostname": "clm-HostA",
"source": "co"
}
]
}
Parameter Name | Value Type | Mandatory | Description |
---|---|---|---|
| Object (List) | Yes | A list of devices. The following parameters are supported:
|
Response codes:
- 200 (OK): Successful response
- 400 (Bad Request): Unsuccessful response
- 401 (Unauthorized): Unsuccessful response
Note
The monitor details in the Non BMC MonitorTypes category are retained in the system even after device deletion.
For example: entityTypeId
, entityName
Metric Query
GET /query?query=<query>
https://<Host:Port>/metrics-query-service/api/v1.0/query?query=<query>
Authorization: Bearer <Jwt_Token>
For instructions on obtaining the JWT token, see
Access and authentication for the REST API.
.
{<Labels name>="<name>"}&time=<time stamp>
{entityName="NUK_Memory"}&time=1595226431
Parameter Name | Value Type | Mandatory | Description |
---|---|---|---|
| String | Yes | Labels defined in your time series database. For example, if you have inserted the following labels, you can query the timeseries data using any of the labels such as __name__, hostname, entityId, entityTypeId, entityName, hostType, isKpi, unit, source, etc. { "labels": { "metricName": "Utilization", "hostname": "clm-HostA", "entityId": "CO:clm-HostA:DISKMONITOR:CPU_TOTAL", "entityTypeId": "DISKMONITOR", "entityName": "DISK_TOTAL", "hostType": "server", "isKpi": true, "unit": "byte", "source": "CO" } |
| Integer | No | Epoch time (in milliseconds) Note: If you do not specify the time, the API will get the data for the current timestamp. |
Response codes:
- 200 (OK): Successful response
- 401 (Unauthorized): Unsuccessful response
GET /query_range?query=<query>
https://<Host:Port>/metrics-query-service/api/v1.0/query_range?query=<query>
Authorization: Bearer <Jwt_Token>
For instructions on obtaining the JWT token, see
Access and authentication for the REST API.
.
{<labels name>="<name>"}&start=<start time stamp>&end=<end timestamp>
{source="Helix"}&start=1595230019&end=1595250019
Parameter Name | Value Type | Mandatory | Description |
---|---|---|---|
| String | Yes | Labels defined in your time series database. If you have inserted labels as shown in the following example, you can query the timeseries data using any of the labels such as, __name__, hostname, entityId, entityTypeId, entityName, hostType, isKpi, unit, source, etc. Example: { "labels": { "metricName": "Utilization", "hostname": "clm-HostA", "entityId": "CO:clm-HostA:DISKMONITOR:CPU_TOTAL", "entityTypeId": "DISKMONITOR", "entityName": "DISK_TOTAL", "hostType": "server", "isKpi": true, "unit": "byte", "source": "CO" } |
| Integer | No | Epoch time (in milliseconds) Note: If you do not specify both the start and end time, the API will get the data for the following time frame: |
end | Integer | No | Epoch time (in milliseconds) |
Response codes:
- 200 (OK): Successful response
- 401 (Unauthorized): Unsuccessful response
GET /labels
https://<Host:Port>/metrics-query-service/api/v1.0/labels
Authorization: Bearer <Jwt_Token>
For instructions on obtaining the JWT token, see
Access and authentication for the REST API.
.
{
"status": "success",
"data": [
"VictoriaMetrics_AccountID",
"__name__",
"deviceId",
"entityId",
"entityName",
"entityTypeId",
"hostname",
"isblackout",
"source"
],
}
Response codes:
- 200 (OK): Successful response
- 401 (Unauthorized): Unsuccessful response
GET /label/<lable_name>/values
https://<Host:Port>/metrics-query-service/api/v1.0/label/<lable_name>/values
Authorization: Bearer <Jwt_Token>
For instructions on obtaining the JWT token, see
Access and authentication for the REST API.
.
https://<Host:Port>/metrics-query-service/api/v1.0/label/entityName/values
Labels/Values
{
"status": "success",
"data": [
"CPU0",
"CPU1",
"NUK_CPU",
"NUK_FileSystem_Container",
"NUK_Linux_OS",
"NUK_Memory",
"NUK_Network_Container",
"boot",
"dev",
"dev-hugepages",
"dev-mqueue",
"dev-pts",
"dev-shm",
"docker0",
"ens160",
"ens192",
"lo",
"proc",
"proc-sys-fs-binfmt_misc",
],
}
Response codes:
- 200 (OK): Successful response
- 401 (Unauthorized): Unsuccessful response
GET series
https://<Host:Port>/metrics-query-service/api/v1.0/series?match[]=<condition>
Authorization: Bearer <Jwt_Token>
For instructions on obtaining the JWT token, see
Access and authentication for the REST API.
.
{
<labels name>="<name>"}&start=<time stamp>
{
hostname="clm-HostB"}&start=1596786531
#Consider the following example to understand the series API:
{hostname="clm-HostA", server="web server"} 10
{hostname="clm-HostA", server="web server"} 1
{hostname="clm-HostA", server="web server"} 10
{hostname="clm-HostA", server="web server"} 2
{hostname="clm-HostB", server="web server"} 3455
{hostname="clm-HostB", server="web server"} 321
{hostname="clm-HostB", server="web server"} 32
{hostname="clm-HostB", server="web server"} 34
#In the above example, there is only 1 unique time series matching the hostname criteria and timestamp, and therefore the /series API will display the output as shown below:
#Example Output
{hostname="clm-HostB", server="web server"}
Parameter Name | Value Type | Mandatory | Description |
---|---|---|---|
| String | Yes | Labels defined in your time series database. If you have inserted labels as shown in the following example, you can query the time series using any of the labels such as, Example: { "labels": { "metricName": "Utilization", "hostname": "clm-HostA", "entityId": "CO:clm-HostA:DISKMONITOR:CPU_TOTAL", "entityTypeId": "DISKMONITOR", "entityName": "DISK_TOTAL", "hostType": "server", "isKpi": true, "unit": "byte", "source": "CO" } |
| Integer | No | Epoch time (in milliseconds) If you do not specify the time, the API will get the data for the current timestamp. |
Response codes:
- 200 (OK): Successful response
- 401 (Unauthorized): Unsuccessful response
GET /series/count
https://<Host:Port>/metrics-query-service/api/v1.0/series/count
Authorization: Bearer <Jwt_Token>
For instructions on obtaining the JWT token, see
Access and authentication for the REST API.
.
#Consider the following example to understand the series/count API: {hostname="clm-HostA", server="web server"} 10
{hostname="clm-HostA", server="web server"} 1
{hostname="clm-HostA", server="web server"} 10
{hostname="clm-HostA", server="web server"} 2
{hostname="clm-HostB", server="web server"} 3455
{hostname="clm-HostB", server="web server"} 321
{hostname="clm-HostB", server="web server"} 32
{hostname="clm-HostB", server="web server"} 34
#In the above example, there are only 2 unique time series data, and therefore the /series/count API will display the count as 2. {hostname="clm-HostA", server="web server"}
{hostname="clm-HostB", server="web server"}
#Example Output {
"status": "success",
"data": [
2
],
}
Response codes:
- 200 (OK): Successful response
- 401 (Unauthorized): Unsuccessful response
GET /export?match=<condition>
https://<HOST_NAME>/metrics-query-service/api/v1.0/export?match=<condition>
Consider the following sample examples to understand possible values for <condition>:
https://<HOST_NAME>/metrics-query-service/api/v1.0/export?match[]={entityName="data1111"}
https://<HOST_NAME>/metrics-query-service/api/v1.0/export?match[]={__name__=" total1111"}
https://<HOST_NAME>/metrics-query-service/api/v1.0/export?match[]={entityName="data1111",__name__="total1111"}
https://<HOST_NAME>/metrics-query-service/api/v1.0/export?match[]={entityName="NUK_CPU",source="HM",hostname="<hostname>"}
Authorization: Bearer <Jwt_Token>
Payload Encoding: url-encoded key value format
For instructions on obtaining the JWT token, see
Access and authentication for the REST API.
.
{<labels name>=~"<name>"}
{__name__=~"tee.*"}
#The API will list the labels, values, and timestamps as shown in the following example
{
"metric": {
"__name__": "teemetric",
VictoriaMetrics_AccountID": "888",
"tag": "dev1",
"tag2": "inst2"
},
"values": [
110,
765
],
"timestamps": [
1589367922000,
1589368322000
]
}
{
"metric": {
"__name__": "teemetric1",
VictoriaMetrics_AccountID": "888",
"tag": "dev2",
"tag2": "inst2"
},
"values": [
110,
765
],
"timestamps": [
1589344422000,
1589128322000
]
}
Parameter Name | Value Type | Mandatory | Description |
---|---|---|---|
| String | Yes | Labels defined in your time series database. If you have inserted labels as shown in the following example, you can query the timeseries data using any of the labels such as, Example: { "labels": { "metricName": "Utilization", "hostname": "clm-HostA", "entityId": "CO:clm-HostA:DISKMONITOR:CPU_TOTAL", "entityTypeId": "DISKMONITOR", "entityName": "DISK_TOTAL", "hostType": "server", "isKpi": true, "unit": "byte", "source": "CO" } |
Response codes:
- 200 (OK): Successful response
- 401 (Unauthorized): Unsuccessful response
The response Content-Type
is application/stream+json
.
POST /query
You can run this API by specifying the API key in the header.
https://<HOST_NAME>/metrics-query-service/api/v1.0/query
Authorization: Bearer <Jwt_Token>
For instructions on obtaining the JWT token, see
Access and authentication for the REST API.
.
{<labels name>="<name>"}&time=<time stamp>
{__name__=\"Utilization\",hostname=\"prometheus-k8s-0\",entityTypeId=\"K8S_POD_CPU\"}&time=1596786531
Parameter Name | Value Type | Mandatory | Description |
---|---|---|---|
| String | Yes | Labels defined in your time series database. For example, if you have inserted the following labels, you can query the timeseries data using any of the labels such as { "labels": { "metricName": "Utilization", "hostname": "prometheus-k8s-0", |
| Integer | No | Epoch time (in milliseconds) Note: If you do not specify the time, the API will get the data for the current timestamp. |
- 200 (OK): Successful response
- 401 (Unauthorized): Unsuccessful response
POST /query_range
You can run this API by specifying the API key in the header.
https://<HOST_NAME>/metrics-query-service/api/v1.0/query_range
Authorization: Bearer <Jwt_Token>
Encoding format: url-encoded key value format
For instructions on obtaining the JWT token, see
Access and authentication for the REST API.
.
{<labels parameter name>="<name>"}&start=<start time stamp>&end=<end timestamp>
{__name__="Utilization"}&start=1595230019&end=1595250019
Parameter Name | Value Type | Mandatory | Description |
---|---|---|---|
| String | Yes | Labels defined in your time series database. If you have inserted labels as shown in the following example, you can query the time series using any of the labels such as, Example: {
"labels": {
"metricName": "Utilization",
"hostname": "clm-HostA",
"entityId": "CO:clm-HostA:DISKMONITOR:CPU_TOTAL",
"entityTypeId": "DISKMONITOR",
"entityName": "DISK_TOTAL",
"hostType": "server",
"isKpi": true,
"unit": "byte",
"source": "CO"
} |
| Integer | No | Epoch time (in milliseconds) Note: If you do not specify both the start and end time, the API will get the data for the following time frame: Current time - 5 minutes |
end | Integer | No | Epoch time (in milliseconds) |
Response codes:
- 200 (OK): Successful response
- 401 (Unauthorized): Unsuccessful response
POST /labels
https://<Host:Port>/metrics-query-service/api/v1.0/labels
Authorization: Bearer <Jwt_Token>
For instructions on obtaining the JWT token, see
Access and authentication for the REST API.
.
{
"status": "success",
"data": [
"VictoriaMetrics_AccountID",
"__name__",
"deviceId",
"entityId",
"entityName",
"entityTypeId",
"hostname",
"isblackout",
"source"
],
}
Response codes:
- 200 (OK): Successful response
- 401 (Unauthorized): Unsuccessful response
POST series
https://<HOST_NAME>/metrics-query-service/api/v1.0/series
Authorization: Bearer <Jwt_Token>
For instructions on obtaining the JWT token, see
Access and authentication for the REST API.
.
{
hostname="clm-HostB"}&start=1596786531
#Consider the following example to understand the series API:
{hostname="clm-HostA", server="web server"} 10
{hostname="clm-HostA", server="web server"} 1
{hostname="clm-HostA", server="web server"} 10
{hostname="clm-HostA", server="web server"} 2
{hostname="clm-HostB", server="web server"} 3455
{hostname="clm-HostB", server="web server"} 321
{hostname="clm-HostB", server="web server"} 32
{hostname="clm-HostB", server="web server"} 34
#Example Output - In the above example, there is only 1 unique time series matching the hostname criteria and timestamp:
{hostname="clm-HostB", server="web server"}
Response codes:
- 200 (OK): Successful response
- 401 (Unauthorized): Unsuccessful response
POST /export?match=<condition>
You can run this API by specifying the API key in the header.
https://<HOST_NAME>/metrics-query-service/api/v1.0/export?match=<condition>
Consider the following sample examples to understand possible values for <condition>:
https://<HOST_NAME>/metrics-query-service/api/v1.0/export?match[]={entityName="data1111"}
https://<HOST_NAME>/metrics-query-service/api/v1.0/export?match[]={__name__=" total1111"}
https://<HOST_NAME>/metrics-query-service/api/v1.0/export?match[]={entityName="data1111",__name__="total1111"}
https://<HOST_NAME>/metrics-query-service/api/v1.0/export?match[]={entityName="NUK_CPU",source="HM",hostname="<hostname>"}
curl -X POST 'https://$<HOST_NAME>/metrics-query-service/api/v1.0/export' -d 'match[]=<TIMESERIES_SELECTOR_QUERY>' -H 'Authorization: Bearer <JWT_TOKEN>'
Authorization: Bearer <Jwt_Token>
Payload Encoding: url-encoded key value format
For instructions on obtaining the JWT token, see
Access and authentication for the REST API.
.
{<label name>=~"<name>"}
{__name__=~"tee.*"}
Parameter Name | Value Type | Mandatory | Description |
---|---|---|---|
| String | Yes | #The API will list the labels, values, and timestamps as shown in the following example { "metric": { "__name__": "teemetric", VictoriaMetrics_AccountID": "888", "tag": "dev1", "tag2": "inst2" }, "values": [ 110, 765 ], "timestamps": [ 1589367922000, 1589368322000 ] } { "metric": { "__name__": "teemetric1", VictoriaMetrics_AccountID": "888", "tag": "dev2", "tag2": "inst2" }, "values": [ 110, 765 ], "timestamps": [ 1589344422000, 1589128322000 ] } |
Response codes:
- 200 (OK): Successful response
- 401 (Unauthorized): Unsuccessful response
The response Content-Type
is application/stream+json
.
Comments
For the metrics api query - /metrics-query-service/api/v1.0/export?match=, it should be documented that the response Content-Type is application/stream+json. Users will likely need to know this, so that the response is properly handed in their scripts (Python/etc).
I have added this. If there are more updates required, we can track them through the internal space. Closing this comment. Thank you.
Log in or register to comment.