Skip to content

Instantly share code, notes, and snippets.

@qyf404
Last active January 22, 2020 10:04
Show Gist options
  • Select an option

  • Save qyf404/dae4836dc980157c0cec461560f5866f to your computer and use it in GitHub Desktop.

Select an option

Save qyf404/dae4836dc980157c0cec461560f5866f to your computer and use it in GitHub Desktop.

Revisions

  1. qyf404 revised this gist Jan 22, 2020. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion Application.java
    Original file line number Diff line number Diff line change
    @@ -4,5 +4,6 @@
    @Bean
    public MeterRegistryCustomizer<MeterRegistry> metricsCommonTags(RcConfig rcConfig) {
    return registry -> registry.config()
    .commonTags("appname:myapp", "nodename:007");
    .commonTags("appname", "myapp",
    "nodename", "007");
    }
  2. qyf404 created this gist Jan 22, 2020.
    8 changes: 8 additions & 0 deletions Application.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    /**
    * 这是个可选项, 用来添加一些自定义tag
    */
    @Bean
    public MeterRegistryCustomizer<MeterRegistry> metricsCommonTags(RcConfig rcConfig) {
    return registry -> registry.config()
    .commonTags("appname:myapp", "nodename:007");
    }
    7 changes: 7 additions & 0 deletions application.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@

    management:
    metrics.export.datadog:
    apiKey: ${your_datadog_key}
    enabled: true
    hostTag: ${your_host_name}
    step: 10s
    16 changes: 16 additions & 0 deletions pom.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.2.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <dependencies>
    <dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-registry-datadog</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    </dependencies>