Alibaba Cloud Prometheus Service (Prometheus) provides HTTP API URLs. You can use an HTTP API URL to connect a Prometheus instance to your custom Grafana dashboard and obtain the monitoring data of the Prometheus instance for custom development. This topic shows you how to use an HTTP API URL to connect a Prometheus instance to your custom Grafana dashboard and obtain the monitoring data of the Prometheus instance.
Obtain an HTTP API URL
Connect the Prometheus instance to your custom Grafana dashboard
- Configure a data source on the Grafana dashboard.
- Verify the data source.
Obtain the monitoring data of the Prometheus instance
The following sample code shows how to send a request to obtain the monitoring data of the Prometheus instance by using the HTTP API URL. For more information, see 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"
}
{HTTP API}
and {Token}
with the HTTP API URL and the authentication token that you obtained in the Obtain an HTTP API URL section of this topic.
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.24420603667"
]
},
{
"metric": {
"__name__": "arms_prometheus_target_interval_length_seconds_sum",
"instance": "localhost:9335",
"interval": "30s",
"job": "_arms-prom/kubelet/1"
},
"value": [
1635302655,
"879810.747346541"
]
},
{
"metric": {
"__name__": "arms_prometheus_target_interval_length_seconds_sum",
"instance": "localhost:9335",
"interval": "20s",
"job": "_arms-prom/kubelet/1"
},
"value": [
1635302655,
"73320.13578499513"
]
}
]
}