Managed Service for Prometheus provides HTTP API URLs. You can use an HTTP API URL to import the monitoring data of a Prometheus instance to your self-built Grafana system, or obtain the data of Managed Service for Prometheus for custom development. This topic describes how to use an HTTP API URL to import the monitoring data of a Prometheus instance to your self-built Grafana system, and obtain the data of Managed Service for Prometheus.
Obtain an HTTP API URL
- Log on to the ARMS console.
- In the left-side navigation pane, choose .
- On the Managed Service for Prometheus page, select the region where the Prometheus instance that you want to manage is created and click Settings in the Actions column.
- On the Settings tab, copy an HTTP API URL for access from the Internet or from an internal network. Note If the Prometheus instance is created to monitor a cloud service, copy the corresponding HTTP API URL based on the type of the cloud service.
- Optional:Click Generate Token to obtain the authentication token for the Prometheus instance. The token is used to ensure data security when monitoring data is imported to Grafana. Important After the authentication token is generated, you must specify the token when you add the Prometheus instance to your Grafana system as a data source. Otherwise, monitoring data cannot be read from the Prometheus instance.
Import the monitoring data of the Prometheus instance to your self-built Grafana system
- Configure a data source in the Grafana system.
- Verify the result.
Obtain the data of Managed Service for Prometheus
The sample request shows how to call the data of Managed Service for Prometheus. For information about how to use HTTP API to obtain the data of Managed Service for Prometheus, see Prometheus HTTP API.
GET {HTTP API}/api/v1/query
Accept: application/json
Content-Type: application/json
Authorization: {Token}
{
"query":"arms_prometheus_target_interval_length_seconds_sum",
"time":"1635302655",
"timeout":"1000"
}
Note Replace the
{HTTP API}
parameter with the actual HTTP API URL and the {Token}
parameter with the actual authentication token. For more information, see Obtain an HTTP API URL. Sample response:
{
"status": "success",
"data": {
"resultType": "vector",
"result": [
{
"metric": {
"__name__": "arms_prometheus_target_interval_length_seconds_sum",
"instance": "localhost:9335",
"interval": "15s",
"job": "_arms-prom/kubelet/1"
},
"value": [
1635302655,
"146655.24420603***"
]
},
{
"metric": {
"__name__": "arms_prometheus_target_interval_length_seconds_sum",
"instance": "localhost:9335",
"interval": "30s",
"job": "_arms-prom/kubelet/1"
},
"value": [
1635302655,
"879810.747346***"
]
},
{
"metric": {
"__name__": "arms_prometheus_target_interval_length_seconds_sum",
"instance": "localhost:9335",
"interval": "20s",
"job": "_arms-prom/kubelet/1"
},
"value": [
1635302655,
"73320.13578499***"
]
}
]
}