In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "how to use Prometheus+Grafana to monitor Springboot applications", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to use Prometheus+Grafana method to monitor Springboot applications" article.
1 introduction
The more the project is done, the more it feels that any system is online, and the operation and maintenance monitoring is too important.
Prometheus is an excellent open source monitoring, alarm and time series database combination system, which is usually monitored with Prometheus in the most common Kubernetes container management system.
2.1 introduction to Springboot
Introducing Prometheus into dependencies is as follows:
Io.micrometer micrometer-registry-prometheus
For Springboot, open Actuator and the corresponding Endpoint:
Management.endpoints.web.exposure.include=*# or management.endpoints.web.exposure.include=prometheus
After starting Springboot, you can use the following URL to see if the monitoring data can be obtained correctly:
Localhost:8080/actuator/prometheus
The successful acquisition of data indicates that Springboot can provide monitoring data normally.
2.2 use in Docker mode
For convenience, start Prometheus using Docker:
# pull docker image docker pull prom/prometheus
Prepare the configuration file prometheus.yml:
Scrape_configs:# can specify-job_name: 'spring' # how often to collect data scrape_interval: 15s # timeout scrape_timeout: 10s # acquisition path metrics_path: / actuator/prometheus' # the address of the collection service, set to the specific address of the server where the Springboot application resides: static_configs:-targets: [' hostname:9000','hostname:8080']
Start the docker instance:
# Port is 9090, specify configuration file
Docker run-d-p 9090 config.file=/etc/prometheus/prometheus.yml 9090-v / temp/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
2.3 testing and viewing
After the successful launch, you can open the web page to view, and can display graphically, URL is http://localhost:9090/.
As shown in the figure above, after opening the web page, randomly select a corresponding monitoring indicator and parameter, and click Execute to view it.
3 Grafana
Grafana is an open source measurement analysis and visualization suite, pure JavaScript development of front-end tools, through access to libraries (such as InfluxDB), show custom reports, display charts and so on. Its UI is very flexible, has rich plug-ins and templates, and is powerful. Generally used in the monitoring of time series data.
3.1 Docker installation and startup
# pull image docker pull grafana/grafana# running instance docker run-d-p 3000 grafana/grafana
After the startup is successful, access http://localhost:3000 to check whether it is successful. The initial administrator account password is admin/admin.
3.2 configure the data source
To display data in Grafana, you need to configure the corresponding data source. In this article, you need to configure the Prometheus data source that was previously installed and enabled, as shown in the following figure:
It should be noted that Access should choose Browser mode, otherwise it will not be able to get data normally. When the configuration is complete, click Save & Test.
3.3 template application
Once you can get the data, you can customize the visualization of the data. But if you add one indicator to another, it will be troublesome. In fact, Grafana provides many excellent templates that can be found on the web https://grafana.com/grafana/dashboards.
This article uses the Spring Boot 2.1Statistics template, which is imported as follows:
Click the + sign-- > Import-- > enter the template link or ID-- > click Load.
After a successful import, you can monitor the data, and the interface is really nice:
The software version information in this example is as follows:
Springboot.version=2.2.5micrometer-registry-prometheus=1.3.5prometheus.version=2.16grafana.version=6.7.0-beta1 above is about the content of this article on "how to use Prometheus+Grafana to monitor Springboot applications". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to learn more about related knowledge, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.