Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 如何调用 prometheus api 接口获取CPU利用率和内存利用率
Hello everyone, I want to call the Prometheus API in Java code to get the CPU and memory utilization at a specific point in time, and then perform subsequent logic processing. The examples given in the official documentation are somewhat brief, and I don’t understand exactly how to call the URL, plus I noticed that the URL changes from time to time. So, I would like to ask how to call this URL.
The related post I found is this: Best Practices for Monitoring TiDB with Grafana | PingCAP Documentation Center in tip 7.
Please post the official link.
Okay, thank you! I’ll look into it.
Okay, I have re-edited it.
Just follow the standard, TiDB comes with the standard Prometheus.
Prometheus data is stored in a time-series database, and you can directly query it to obtain monitoring data.
Directly access the Prometheus API to obtain the relevant information?
I also want to learn more…
I see that TiDB directly uses Prometheus, so you can refer to the Prometheus documentation to learn how to call the API. For example, the following link might be helpful:
client_java (prometheus.github.io)
You can directly query in the Prometheus library, but you need to study the documentation for specific usage.
Just call the Prometheus API directly.
Prometheus API documentation
Check the official Prometheus API documentation, it should be there.