使用JavaMelody监视Java微服务

Javamelody is an open source project that helps you get metrics from your service. With it you can discover possible failures before sending you code to production. It is very easy to include in your application and in this tutorial, we will show you how to do it.

Creating Demo App

Let's start creating a spring boot application. Access https://start.spring.io/ to generate our demo app. You can use your own package name on Group field.

And add only Web dependency

And then, generate project.

A zip file will be generated with our project and can be imported into your preferred IDE.
A generated project looks like this:

If you prefer to use this demo code, clone the github project:
https://github.com/sandrogiacom/javamelody-spring-demo

Add JavaMelody dependency

现在,让我们添加javamelody的spring boot依赖关系

<dependency>
    <groupId>net.bull.javamelody</groupId>
    <artifactId>javamelody-spring-boot-starter</artifactId>
    <version>1.77.0</version>
</dependency>

Run app

Next you can run your spring-boot application and open http://localhost:8080/monitoring to browse the monitoring reports.

指标将开始被捕获,但是我们的应用程序中仍然没有代码。 让我们创建一个休息端点。

Create a Rest Controller

添加一个新的类HelloController,如下所示:

@RestController
@RequestMapping("/hello")
public class HelloController {
    @GetMapping
    public String sayHello() {
        return "Hello JavaMelody!";
    }
}

Restart your application and open http://localhost:8080/hello
Run this URL many times. After that, open http://localhost:8080/monitoring again.

Results

如您所见,指标开始收集:

More JavaMelody Resources

JavaMelody具有许多功能,例如:

  • 插件:(Jenkins,JIRA,Bamboo,Liferay,Alfresco,Sonar,Grails)PDF报告生成(通过邮件每周,每日或每月生成报告)脚本和警报(詹金斯与Groovy)集中监控服务器真实用户监控数据库监控将指标发送到AWS CloudWatch,Graphite自定义报告,样式,图标和其他资源

Conclusion

JavaMelody helps you anticipate problems with your application. For best results, use with some stress tool, such as ĴMeter.

GitHub logo sandrogiacom / javamelody-spring-demo

How to monitoring your spring boot app with Javamelody

javamelody-spring-demo

How to monitoring your spring boot app with Javamelody

https://dev.to/sandrogiacom/monitoring-java-microservices-with-javamelody-1ndg




from: https://dev.to//sandrogiacom/monitoring-java-microservices-with-javamelody-1ndg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值