Add statsd metric export auto-configuration
Update MetricExportAutoConfiguration to auto-configure statsd metrics export when a `spring.metrics.export.statsd.host` property is set. Closes gh-3719
This commit is contained in:
committed by
Phillip Webb
parent
9128f2b902
commit
70031cca66
@@ -790,6 +790,9 @@ content into your application; rather pick only the properties that you need.
|
||||
spring.metrics.export.excludes= # list of patterns for metric names to exclude. Applied after the includes
|
||||
spring.metrics.export.redis.prefix=spring.metrics # prefix for redis repository if active
|
||||
spring.metrics.export.redis.key=keys.spring.metrics # key for redis repository export (if active)
|
||||
spring.metrics.export.statsd.host= # host of the statsd server
|
||||
spring.metrics.export.statsd.port=8125 # port of the statsd server
|
||||
spring.metrics.export.statsd.prefix= # prefix for exported metrics
|
||||
spring.metrics.export.triggers.*= # specific trigger properties per MetricWriter bean name
|
||||
|
||||
# SENDGRID ({sc-spring-boot-autoconfigure}/sendgrid/SendGridAutoConfiguration.{sc-ext}[SendGridAutoConfiguration])
|
||||
|
||||
@@ -1142,28 +1142,28 @@ curl localhost:4242/api/query?start=1h-ago&m=max:counter.status.200.root
|
||||
|
||||
[[production-ready-metric-writers-export-to-statsd]]
|
||||
==== Example: Export to Statsd
|
||||
If you provide a `@Bean` of type `StatsdMetricWriter` and mark it `@ExportMetricWriter` the metrics are exported to a
|
||||
statsd server:
|
||||
To export metrics to Statsd add a `spring.metrics.export.statsd.host` value to your
|
||||
`application.properties` file. Connections will be opened to port `8125` unless a
|
||||
`spring.metrics.export.statsd.port` override is provided. You can use
|
||||
`spring.metrics.export.statsd.prefix` if you want a custom prefix.
|
||||
|
||||
Alternatively, you can provide a `@Bean` of type `StatsdMetricWriter` and mark it
|
||||
`@ExportMetricWriter`:
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
@Value("${spring.application.name:application}.${random.value:0000}")
|
||||
private String prefix = "metrics";
|
||||
|
||||
@Value("${statsd.host:localhost}")
|
||||
private String host = "localhost";
|
||||
|
||||
@Value("${statsd.port:8125}")
|
||||
private int port;
|
||||
|
||||
@Bean
|
||||
@ExportMetricWriter
|
||||
MetricWriter metricWriter() {
|
||||
return new StatsdMetricWriter(prefix, host, port);
|
||||
return new StatsdMetricWriter(prefix, "localhost", "8125");
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
|
||||
[[production-ready-metric-writers-export-to-jmx]]
|
||||
==== Example: Export to JMX
|
||||
If you provide a `@Bean` of type `JmxMetricWriter` marked `@ExportMetricWriter` the metrics are exported as MBeans to
|
||||
|
||||
Reference in New Issue
Block a user