Micrometer: It is not possible to set a host-tag for Datadog

Created on 23 Mar 2018  路  5Comments  路  Source: micrometer-metrics/micrometer

Setting my Spring Boot 1.x application (actually Grails 3.x) properties of datadog metrics to:

management:
    metrics:
        export:
            datadog:
                enabled: true
                api-key: ***
                host-tag: myapp-dev
                steps: 1m

causes host not to be sent into datadog. I even found a problematic code which doesn't make sense at all to me.

Am I missing something or is there a bug?

doc-update question

All 5 comments

@kuceram host-tag indicates which tag to send to datadog as the "host". So you would also need to add a common tag:

@Bean
MeterRegistryCustomizer<MeterRegistry> commonTags() {
   return r -> r.config().commonTags("host", "myapp-dev");
}

Thanks @jkschneider, it make sense to me now. If you know by any chance how to set this in Grails, I would appreciate your help (see related stackoverflow question).

Thanks!

So I finally found it. In Grails, you register the bean in resources.groovy

import my.company.CommonTagCustomizer

// Place your Spring DSL code here
beans = {
    commonTags(CommonTagCustomizer)
}

And here is the definition of bean:

package my.company.monitoring

import io.micrometer.core.instrument.MeterRegistry
import io.micrometer.spring.autoconfigure.MeterRegistryCustomizer

class CommonTagCustomizer implements MeterRegistryCustomizer<MeterRegistry> {
    void customize(MeterRegistry registry) {
        registry.config().commonTags("host", "myapp-dev")
    }
}

@jkschneider It took me forever to figure out that the host-tag was referencing the common DD tag used to send the hostname. I kept thinking that host-tag meant that is the place in configuration to set the hostname & didn't realize that I had to also set the common tag. It may be just me being slow; but it could also be that the initial docs a developer reads don't clarify that. Might be a hidden documentation issue around this...

@randysecrist Fair point, and honestly one that many have struggled with. We should do better.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

edeandrea picture edeandrea  路  3Comments

jonatan-ivanov picture jonatan-ivanov  路  3Comments

fkoehler picture fkoehler  路  3Comments

wilkinsona picture wilkinsona  路  3Comments

nugnoperku picture nugnoperku  路  4Comments