将Azure Application Insights与Spring Boot结合使用(4/7)

本文是关于在Azure上部署Spring Boot和Angular应用系列的第四部分,重点介绍如何设置和使用Azure Application Insights进行应用性能管理。通过Azure Application Insights,可以全面监控服务器端(Java)和前端(Angular)应用,提供定制化仪表板,实现低成本的性能优化。文章详细介绍了设置Application Insights的步骤,包括在Spring Boot应用中的配置,并展示了如何测试和利用实时指标流来监控应用性能。
摘要由CSDN通过智能技术生成

此博客文章是“在Azure上部署Spring Boot和Angular应用程序”系列文章的一部分,这里是文章的完整列表:

What is Azure Application Insights and why you should use it

在本系列的前几部分中,我们开发了Spring Boot和Angular应用程序,创建了Azure基础结构,并自动将应用程序部署到Azure。 但是,当出现问题时会发生什么? 我们讨论了成本和预算,但是,如果我们不知道应用程序在用户访问时的行为,该如何优化它们?

一种zure Application Insights is an application performance management (APM) service provided by Azure. This is the first thing you should set up with any application: without monitoring and insights, you are blind to any performance, infrastructure, or misconfiguration that may occur to your application.

Azure Application Insights是一个引人注目的解决方案:

  • 这是非常完整的,正如我们在这一系列博客文章中所看到的,我们将同时监视服务器端(Java)应用程序和前端和(Angular)应用程序它提供了高级且高度可定制的仪表板它具有免费层(适用于简单的应用程序),否则非常便宜如果您是Azure用户,显然,这将是您的默认选择,因为其中包括

Set up Azure Application Insights

When we created our Azure infrastructure in the part 2 of this series, we asked Azure Web App to automatically set up monitoring. If you didn't check that box, no worries! Just search for "Application Insights" in the Azure portal and create a new instance. What is important is to have the "Instrumentation Key", which is available from the "Overview" page on your Azure Application Insights instance, and which will be used to send monitoring data from your running application.

Use Azure Application Insights with Spring Boot

现在,我们将在Spring Boot应用程序中配置Azure Application Insights。

Currently, Microsoft provides a Spring Boot Starter for automatically configuring Azure Application Insights: applicationinsights-spring-boot-starter, which is available here on Maven Central and which is fully documented here. This is done by the Azure Application Insights team, and this is the starter we will we use here.

Please note that Microsoft also provide a azure-spring-boot-metrics-starter, which is available here on Maven Central, and which is fully documented here, and adds Micrometer monitoring support on top of the previous starter. Its current version, at the time of this writing, uses a different configuration key as applicationinsights-spring-boot-starter, so we think it might be better to wait until both starters use the same configuration.

如applicationinsights-spring-boot-starter是一个Spring Boot启动器,所有要做的就是将其库添加到项目的pom.xml,并配置其天蓝色的应用程序见解仪器密钥Spring Boot属性。 有几种方法可以做到,我们将最简单地添加到我们的应用程序产品配置文件,因此我们在生产中设置了监视。

然后,需要执行的其他一些配置步骤:

  • 去除千分尺普罗米修斯项目的依赖pom.xml,因为Prometheus现在已由Azure Application Insights取代。添加applicationinsights-日志-logback依赖关系,因此所有生产日志都将发送到Azure Application Insights。 当我们配置LOGGING_LEVEL配置Azure Web App的关键,我们应该拥有业务代码中的所有调试信息。重新配置logback-spring.xml文件以从Spring Boot获取Azure Application Insights检测密钥,并设置com.microsoft.applicationinsights在信息级别(否则它将使我们充满信息)。

You can check the changes we just made to set up Azure Application Insights on this commit.

由于我们还配置了Logback以将所有日志发送到Azure Application Insights,因此它们现在将在此处聚合,并且可以轻松地进行搜索:

现在已经完成所有设置,并且我们已经配置了完整的持续集成/连续部署管道,我们所需要做的就是将代码推送到GitHub,并观察我们的应用程序是否自动更新。

部署完应用程序后,就该测试一下Application Insights的工作方式! 转到您的Application Insights实例,然后选择“实时指标流”。 如果您的应用程序已连接,则一切就绪!

Testing Azure Application Insights

JHipster已为我们的应用程序生成了量角器测试:打开protractor.conf.js文件并更改baseUrl属性以指向您的Azure Web App实例。 然后,您可以通过键入以下内容来运行量角器测试npm运行e2e。 这将启动浏览器,并在应用程序中执行一系列方案,包括失败的方案。

如果一切设置正确,则在“实时指标流”中,您应该看到正在运行的方案:

然后,您可以使用常规的仪表板来检查您的Spring Application性能:

这些仪表板非常完整,它们将使您更好地了解应用程序中的潜在问题。 在本系列的下一篇文章中,我们将进行相同的配置,但是使用Angular前端应用程序:然后,您将能够获得有关前端用户交互以及服务器端性能指标的汇总视图 !

from: https://dev.to//azure/using-azure-application-insights-with-spring-boot-4-7-263i

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值