Man*_*oid 6 spring-boot micrometer
我有一个springboot 2应用程序,我想在AWS Cloudwatch中显示指标。
我已经将pom中的micrometer cloudwatch依赖性包括在内。
此处记录的是各种指标系统的设置,但没有cloudwatch的说明。
我需要为cloudwatch做哪些其他配置?
首先,您可能需要添加一些额外的依赖项。我需要以下内容:
Boot 无法管理这些依赖项的版本(在我的例子中除了执行器之外),因此您可能必须找出适合您的版本。
此外,还必须设置一些应用程序属性:
# disable unwanted features to prevent autoconfigure which will produce errors and abort of application startup eventually
# alternatively you can try to configure those features correctly if you intend to use them
cloud.aws.stack.auto=false
# enable micrometer for cloudwatch (only where there is actually access to it)
management.metrics.export.cloudwatch.enabled=true
# set the namespace that will contain the metrics for this application
management.metrics.export.cloudwatch.namespace=test
# set max batch size to the actual maximum (if not a bug in certain versions of micrometer for cloudwatch will send
# batches that are too big)
management.metrics.export.cloudwatch.batchSize=20
Run Code Online (Sandbox Code Playgroud)
下一步将在 AWS 中进行。与您的 EC2 实例(或您正在使用的任何实例)关联的角色需要拥有 权限CloudWatch:PutMetricData
。
使用此配置应该为您的 Spring-Boot-Application 启用 CloudWatch-Monitoring。
我遇到的消息来源之一指出您应该使用:
cloud.aws.credentials.instanceProfile=false
Run Code Online (Sandbox Code Playgroud)
这将阻止 Spring Boot 自动获取将指标推送到 CloudWatch 所需的凭据。您还可以通过另一种方式提供自己的凭据,但我没有尝试这样做。
归档时间: |
|
查看次数: |
684 次 |
最近记录: |