【问题标题】:How to set the variable instrumentationKey for azure monitoring in a spring boot application如何在 Spring Boot 应用程序中为 Azure 监控设置变量 instrumentationKey
【发布时间】:2019-07-25 16:19:33
【问题描述】:

我在 Spring Boot 项目中设置 Azure 监控时遇到问题。

我每次开始都有错误:

instrumentationKey 必须设置为向 Azure Monitor 报告指标。

我已经使用以下属性设置了 application.properties:

azure.application-insights.instrumentation-key=VALID-UUID

spring.application.name=test

项目的依赖如下:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>2.1.3</version>
    </dependency>
    <dependency>
        <groupId>com.microsoft.azure</groupId>
        <artifactId>azure-spring-boot-metrics-starter</artifactId>
        <version>2.1.4</version>
    </dependency>

【问题讨论】:

标签: java azure azure-application-insights azure-monitoring


【解决方案1】:

根据https://docs.microsoft.com/en-us/azure/azure-monitor/app/micrometer-java#using-spring-2x 文档,您还需要添加 application-insights-springboot-starter。

否则,您可以将密钥设置为azuremonitor.instrumentationKey。我的建议是添加 application-insights-springboot-starter 和 azure-spring-boot-metrics-starter

【讨论】:

    【解决方案2】:

    依存追踪

    您的错误信息来自AzureMonitorConfig

    所以我认为关键是修改为

    azuremonitor.instrumentationKey
    

    【讨论】:

    • 我不使用 azure-application-insights-spring-boot-starter 而是使用 azure-spring-boot-metrics-starter
    • 结果是由依赖项 azure-spring-boot-metrics-starter --> icrometer-registry-azure-monitor --> com.microsoft.azure:applicationinsights-core 跟踪的。您的错误消息来自github.com/micrometer-metrics/micrometer/blob/master/…
    猜你喜欢
    • 2022-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-24
    • 2017-04-16
    • 2020-05-21
    • 2021-09-11
    • 1970-01-01
    相关资源
    最近更新 更多