Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Monitoring of micro-services by Spring Boot

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Click Insert metric at cursor to select the monitoring metrics; click Graph to display the metrics in a chart; click the Execute button to see the results similar to the following figure:

Function description:

Insert metric at cursor: select metrics displayed Graph: let metrics be displayed graphically Execute: draw metrics chart information Add Graph: draw more metrics charts Grafana visualization

In the previous section, we have successfully built the Prometheus service and briefly introduced the monitoring data visualization interface that comes with Prometheus. However, the user experience is not good and the features are relatively few. Let's integrate Grafana to implement a monitoring data visualization platform that is more friendly and closer to production.

You also need to install the Grafana service on the server. For simplicity, I still use the docker installation method here. For other installation methods, please refer to the official installation documentation.

Using docker, you only need one command to start Grafana, as follows:

[root@localhost ~] # docker run-d-p 3000 grafana/grafana configuration Monitoring data Source

After Grafana starts successfully, visit http://{ip}:3000/login to log in. The default account password is admin:

After logging in successfully, the home page is as follows:

First, you need to add the source of the monitoring data. Click Add data source on the home page to see an interface similar to the following:

Click Prometheus here to see an interface similar to the following, where you can configure information related to the Prometheus service:

After the save is successful, you will be prompted as follows:

Create a monitoring Dashboard

Click the + button on the navigation bar and click Dashboard, and you will see an interface similar to the following:

Click Add Query and you will see an interface similar to the following:

Add a metric query to the location marked in the red box. For more information on the metrics, please see the / actuator/prometheus endpoint of the Spring Boot application, such as jvm_memory_used_bytes, jvm_threads_states_threads, jvm_threads_live_threads, etc.

Grafana will give you better hints and support more complex calculations, such as aggregation, summation, averaging, etc. If you want to draw multiple lines, click the Add Query button. As shown in the figure above, the author draws two lines for the chart, representing daemon and Peak threads, respectively.

Click the button in the following figure and enter Title to set the chart title:

If you need to add a new chart to Dashboard, click the button in the upper left corner of the figure above:

And follow the steps below:

If you need to save the Dashboard, click the Save button in the upper right corner:

Dashboard market

So far, we have successfully integrated Grafana and Prometheus to achieve a rich chart display-put the monitoring indicators of concern on the Dashboard, and very flexible! However, the operation of this configuration is not difficult, but it is quite time-consuming.

So is there a powerful, versatile, ready-to-use Dashboard? The answer is yes! Go to Grafana Lab-Dashboards and enter keywords to search for the specified Dashboard:

As shown in the figure above, you can find several Dashboard that use Prometheus as the data source and support Micrometer. Let's briefly demonstrate how to use the Dashboard of JVM (Micrometer). Click JVM (Micrometer) to enter the Dashboard details page, as shown in the following figure:

As shown in the figure, the characteristics and configuration of the Dashboard are described in detail. The management.metrics.tags.application is already configured when the Prometheus service is installed earlier. The 4701 in the upper-right corner of the page marked with a red box is a very important number because this is the id of the Dashboard.

Going back to the home page of Grafana, let's import the Dashboard and follow the steps below:

After typing, you can see an interface similar to the following. Select the data source and click Import:

At this point, you can see an interface similar to the following. The metrics we are often concerned about are supported by the Dashboard:

In the options bar above, you can choose to view different services / applications:

In addition, there are some Dashboard that are easier to use.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report