Align the exporter and the trigger name

Fix #903

Use 'application' as the trigger name consistently.

Since 'application' would be a too generic name for
the Exporter bean, use a BeanPostProcessor to install
the exporter in the `MetricExporters` bean.

Additional updates

- rename binding to `applicationMetrics` (we can decide later how
  the channel is named)
- remove the default setting for `spring.metrics.export`
- Improve documentation

Fix #904

Docs updates

Properly escape asciidoc control characters
This commit is contained in:
Marius Bogoevici
2017-04-07 02:18:25 -04:00
committed by Vinicius Carvalho
parent 161011fcde
commit d6fe841a63
6 changed files with 138 additions and 76 deletions

View File

@@ -1914,49 +1914,40 @@ Spring Cloud Stream provides a health indicator for binders.
It is registered under the name of `binders` and can be enabled or disabled by setting the `management.health.binders.enabled` property.
== Metrics Emitter
Spring Cloud Stream provides a module called `spring-cloud-stream-metrics` that can be used to emit any available metric from https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-metrics.html[Spring Boot metrics endpoint] to a named channel.
This module allow operators to collect metrics from stream applications without relying on polling their endpoints.
HTTP polling can be challenging on cloud environments since applications could be on a private network or behind a Load balancer that prevents per instance access.
The module is activated when you set the destination name for metrics binding, e.g. `spring.cloud.stream.bindings.applicationMetrics.destination=<DESTINATION_NAME>`.
`applicationMetrics` can be configured in a similar fashion to any other producer binding.
The default `contentType` setting of `applicationMetrics` is `application/json`.
The module is activated when you set the destination name for its channel, `spring.cloud.stream.bindings.applicationMetricsChannel.destination=<DESTINATION_NAME>`.
`applicationMetricsChannel` can be configured in a similar fashion to any other bound output channel.
The default `contentType` setting of `applicationMetricsChannel` is `application/json`.
The following properties can be used for customizing the emission of metrics:
By default the module is configured to only send Spring Integration message channel metrics.
Available properties for customization using the prefix `spring.cloud.stream.metrics`.
key::
spring.cloud.stream.metrics.key::
The name of the metric being emitted. Should be an unique value per application.
+
Default:: `${spring.application.name:${vcap.application.name:${spring.config.name:application}}}`
+
delay-millis::
The period in which metrics will be posted to the channel
+
Default: `5000`.
+
prefix::
Prefix string to be prepended to the metrics name
spring.cloud.stream.metrics.prefix::
Prefix string to be prepended to the metrics key.
+
Default: ``
+
includes::
An array of strings containing regex patterns of metrics that should be included.
+
Default: `integration**`
+
excludes::
An array of strings containing regex patterns of metrics that should be excluded.
+
Default: ``
+
properties::
spring.cloud.stream.metrics.properties::
Just like the `includes` option, it allows white listing application properties that will be added to the metrics payload
+
Default: null.
A detailed overview of the metrics export process can be found in the https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-metrics.html#production-ready-metric-writers[Spring Boot reference documentation].
Spring Cloud Stream provides a metric exporter named `application` that can be configured via regular https://github.com/spring-projects/spring-boot/blob/1.5.x/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/export/TriggerProperties.java[Spring Boot metrics configuration properties].
The exporter can be configured either by using the global Spring Boot configuration settings for exporters, or by using exporter-specific properties.
For using the global configuration settings, the properties should be prefixed by `spring.metric.export` (e.g. `spring.metric.export.includes=integration+++**+++`).
These configuration options will apply to all exporters (unless they have been configured differently).
Alternatively, if it is intended to use configuration settings that are different from the other exporters (e.g. for restricting the number of metrics published), the Spring Cloud Stream provided metrics exporter can be configured using the prefix `spring.metrics.export.triggers.application` (e.g. `spring.metrics.export.triggers.application.includes=integration+++**+++`).
[NOTE]
====
Due to Spring Boot's https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-relaxed-binding[relaxed binding] the value of a property being included can be slightly different than the original value.