How to use Prometheus to collect custom parameters for your own server
How to use Prometheus to collect custom parameters for your own server, I believe many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Use a simple example to illustrate.
I built the simplest server with express and http, listening on port 8081.
On metrics endpoint, I will print out how many requests the server has served since it was started. Here I simply use a counter maintained in memory to simulate the number of service requests. Each time metrics is requested, the counter is incremented by one.
Localhost:8081/metrics test:
Open the configuration file prometheus.yml for the Prometheus server:
To add a job, static_configs 's target is configured as my own server localhost:8081.
Localhost:9090 accesses Prometheus's web UI:
By switching to the graphical interface, you can see the trend graph of my server responding to service requests over time. The horizontal axis is the point in time, and the vertical axis is the service response request collected by the Prometheus server from my test server every 15 seconds by default.
After reading the above, do you know how to use Prometheus to collect custom parameters for your own server? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!