DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Keep Your Application Secrets Secret
  • Building Mancala Game in Microservices Using Spring Boot (Part 2: Mancala API Implementation)
  • DGS GraphQL and Spring Boot
  • A Practical Guide to Creating a Spring Modulith Project

Trending

  • Build Your First AI Model in Python: A Beginner's Guide (1 of 3)
  • Teradata Performance and Skew Prevention Tips
  • Java 23 Features: A Deep Dive Into the Newest Enhancements
  • A Guide to Container Runtimes
  1. DZone
  2. Coding
  3. Frameworks
  4. Monitoring SpringBoot2 Metrics with HertzBeat

Monitoring SpringBoot2 Metrics with HertzBeat

Use the open-source real-time monitoring tool HertzBeat to monitor and alarm the SpringBoot2 application, and it will be done in five minutes!

By 
gong tom user avatar
gong tom
·
Mar. 31, 23 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
5.0K Views

Join the DZone community and get the full member experience.

Join For Free

Use the open-source real-time monitoring tool HertzBeat to monitor and alarm the SpringBoot2 application, and it will be done in five minutes!

HertzBeat Intro

HertzBeat is an open-source, real-time monitoring tool with custom-monitor and agentLess.

Monitor+Alerter+Notify all in one. Support monitoring web service, database, os, middleware, cloud-native, network, and more. More flexible threshold rule(calculation expression), timely notification delivery by Discord Slack Telegram Email DingDing WeChat FeiShu Webhook SMS.

We make protocols such as Http, Jmx, Ssh, Snmp, Jdbc configurable, and you only need to configure YML online to collect any metrics you want. Do you believe that you can immediately adapt a new monitoring type, such as K8s or Docker, just by configuring online?

HertzBeat's powerful custom-define, multi-type support, easy expansion, and low coupling hope to help developers and micro teams quickly build their own monitoring system.

Monitoring SpringBoot2 Metrics With HertzBeat in 5 Minutes

A prerequisite is that you already have the SpringBoot2 application environment and HertzBeat environment.

  • HertzBeat Installation and deployment documentation

The actuator Indicator Endpoint Is Exposed on the SpringBoot2 Application Side, Which Will Provide Metrics Endpoints Data

  1. Open SpringBoot Actuator Endpoint to expose metrics health env indicator interface
YAML
 
management:
   endpoints:
     web:
       exposure:
         include:
           - 'metrics'
           - 'health'
           - 'env'
     enabled-by-default: on


  1. After restarting, test whether the access indicator interface ip:port/actuator has response JSON data as follows:
JSON
 
{
   "_links": {
     "self": {
       "href": "http://localhost:1157/actuator",
       "templated": false
     },
     "health-path": {
       "href": "http://localhost:1157/actuator/health/{*path}",
       "templated": true
     },
     "health": {
       "href": "http://localhost:1157/actuator/health",
       "templated": false
     },
     "env": {
       "href": "http://localhost:1157/actuator/env",
       "templated": false
     },
     "env-toMatch": {
       "href": "http://localhost:1157/actuator/env/{toMatch}",
       "templated": true
     },
     "metrics-requiredMetricName": {
       "href": "http://localhost:1157/actuator/metrics/{requiredMetricName}",
       "templated": true
     },
     "metrics": {
       "href": "http://localhost:1157/actuator/metrics",
       "templated": false
     }
   }


Add SpringBoot2 Application Monitoring in the Hertzbeat Monitoring UI

  1. Click to add SpringBoot2 monitoring

Path: Menu -> Application Service Monitoring -> SpringBoot2 -> Add SpringBoot2 Monitoring

Path Menu

  1. Configure the parameters required for new monitoring SpringBoot2

Fill in the SpringBoot2 application peer IP, service port (default 8080), an account password, etc., on the monitoring page, and finally click OK to add. For other parameters, such as collection interval, timeout period, etc., please refer to the help document.

Setting Advanced Peram

  1. Complete now. We have added the monitoring of the SpringBoot2 application. Check the monitoring list to see our additions.

Local host

  1. Click Operation->Monitoring Details Icon of the monitoring list item to browse the real-time monitoring indicator data of the SpringBoot2 application.

Service Monitor

  1. Click Monitoring History Details TAB to browse the historical monitoring indicator data chart of the SpringBoot2 application.

Monitoring History Details TAB

DONE! Done! It doesn't require us to deploy agents or various cumbersome operations. Isn't it very simple? Just one step to configure the IP port on the HertzBeat monitoring page and add SpringBoot2 application monitoring.

Through the above, we have completed the monitoring of the SpringBoot2 application. We can check the status and availability of various indicators of the SpringBoot2 application at any time in HertzBeat.

Of course, it is impossible to manually check the indicators in real-time. Monitoring is often accompanied by alarm thresholds. When the performance indicators of the SpringBoot2 application exceed our threshold or the SpringBoot2 application itself is abnormal, we can promptly notify our corresponding person in charge. The person in charge receives the notification and handles it. This is a complete monitoring and alarm process.

Next, we will demonstrate step by step how to configure the threshold alarm notification in the HertzBeat system. When the indicators of the SpringBoot2 application are abnormal, we will be notified in time

Add SpringBoot2 Application Indicator Threshold Alarm in Hertzbeat System

  1. Configure an alarm threshold for an important indicator

Path: Menu -> Threshold Rules -> Add Threshold

  • Select the configured indicator object. SpringBoot2 application monitoring mainly focuses on stack memory threads and other related indicators. For example, we set the threshold for the indicator threads -> threads. When the number of threads in the runnable state is greater than At 300, an alert is issued.
  • Here we configure to send an alarm when size, state of equals(state, "runnable"") && size>300 of this indicator, the alarm level is a warning alarm, which will be triggered three times, specifically as shown below.

warning alarm

 New Threshold
  1. Add message notification recipients

Configure the receiver to let the alarm message know who to send and how to send it.

Path: Menu -> Alarm Notification -> Alarm Recipient -> Add New Recipient

Message notification methods support email, DingTalk, WeChat Work, Feishu, WebHook, SMS, etc. Here we take the commonly used DingTalk as an example.

  • Refer to this Help Documentation to configure the robot on DingTalk and set the security custom keyword HertzBeat, get the corresponding access_token value.
  • Configure the receiver parameters in HertzBeat as follows.

【Alarm Notification】->【New Recipient】->【Select DingTalk Robot Notification Method】->【Set DingTalk Robot ACCESS_TOKEN】->【OK】

Path menu

  1. Configure the associated alarm notification strategy [Add notification strategy] -> [Associate the recipient just set] -> [OK]

Configure the alarm notification policy to bind the alarm message with the receiver so that you can decide which alarms to send to whom.

Finished. Now we wait for the warning message to come.

[HertzBeat warning notification]
Alarm target object: springboot2.threads.size
Affiliated monitoring ID: 483783444839322
Belonging monitoring name: SPRINGBOOT2_localhost
Alarm level: warning alarm
Alarm trigger time: 2023-03-22 21:13:44
Content details: The springboot2 service's runnable state threads num is over 300, now is 444.

Summary

This practical article took us to experience how to use the open-source real-time monitoring tool HertzBeat to monitor SpringBoot2 application indicator data. We can find that HertzBeat, which integrates monitoring-alarm-notification, is more convenient in operation and use. Just click a little on the page. The SpringBoot2 application can be included in the monitoring and alarm notification, and the tedious operations of deploying multiple components and writing configuration files are no longer needed.

Only one docker command is needed to install and experience heartbeat:

docker run -d -p 1157:1157 --name hertzbeat tancloud/hertzbeat

More Powerful

Through the simple steps above, we have realized the monitoring of SpringBoot2, but the built-in indicators in it do not meet the needs. Can we customize and monitor more indicators of SpringBoot2? The answer is, of course, yes; through Monitoring Definition->SpringBoot2 on the page, you can customize and modify the performance indicators you want to monitor by editing the following YML configuration file at any time.

Monitor the page


Open source application Spring Boot

Published at DZone with permission of gong tom. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Keep Your Application Secrets Secret
  • Building Mancala Game in Microservices Using Spring Boot (Part 2: Mancala API Implementation)
  • DGS GraphQL and Spring Boot
  • A Practical Guide to Creating a Spring Modulith Project

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!