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?
@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.