Enrichers provide advanced manipulation of an entity's sensor values. See below for documentation of the stock enrichers available in Apache Brooklyn.
org.apache.brooklyn.enricher.stock.Transformer
Takes a source sensor and modifies it in some way before publishing the result in a new sensor. See below an example using $brooklyn:formatString.
{% highlight yaml %} {% read example_yaml/enricher-transformer.yaml %} {% endhighlight %}
org.apache.brooklyn.enricher.stock.Propagator
Use propagator to duplicate one sensor as another, giving the supplied sensor mapping. The other use of Propagator is where you specify a producer (using $brooklyn:entity(...) as below) from which to take sensors; in that mode you can specify propagate as a list of sensors whose names are unchanged, instead of (or in addition to) this map.
{% highlight yaml %} {% read example_yaml/enricher-propagator.yaml %} {% endhighlight %}
org.apache.brooklyn.enricher.stock.Aggregator
Aggregates multiple sensor values (usually across a tier, esp. a cluster) and performs a supplied aggregation method to them to return an aggregate figure, e.g. sum, mean, median, etc.
{% highlight yaml %} {% read example_yaml/enricher-aggregator.yaml %} {% endhighlight %}
There are a number of additional configuration keys available for the Aggregators:
| Configuration Key | Default | Description |
|---|---|---|
| enricher.transformation.untyped | list | Specifies a transformation, as a function from a collection to the value, or as a string matching a pre-defined named transformation, such as ‘average’ (for numbers), ‘sum’ (for numbers), ‘isQuorate’ (to compute a quorum), ‘first’ (the first value, or null if empty), or ‘list’ (the default, putting any collection of items into a list) |
| quorum.check.type | The requirement to be considered quorate -- possible values: ‘all’, ‘allAndAtLeastOne’, ‘atLeastOne’, ‘atLeastOneUnlessEmpty’, ‘alwaysHealthy’", “allAndAtLeastOne” | |
| quorum.total.size | 1 | The total size to consider when determining if quorate |
org.apache.brooklyn.enricher.stock.Joiner
Joins a sensor whose output is a list into a single item joined by a separator.
{% highlight yaml %} {% read example_yaml/enricher-joiner.yaml %} {% endhighlight %}
There are a number of additional configuration keys available for the joiner:
| Configuration Key | Default | Description |
|---|---|---|
| enricher.joiner.separator | , | Separator string to insert between each argument |
| enricher.joiner.keyValueSeparator | = | Separator string to insert between each key-value pair |
| enricher.joiner.joinMapEntries | false | Whether to add map entries as key-value pairs or just use the value |
| enricher.joiner.quote | true | Whether to bash-escape each parameter and wrap in double-quotes |
| enricher.joiner.minimum | 0 | Minimum number of elements to join; if fewer than this, sets null |
| enricher.joiner.maximum | null | Maximum number of elements to join (null means all elements taken) |
org.apache.brooklyn.policy.enricher.DeltaEnricher
Converts an absolute sensor into a delta sensor (i.e. the difference between the current and previous value)
org.apache.brooklyn.enricher.stock.YamlTimeWeightedDeltaEnricher
Converts absolute sensor values into a difference over time. The enricher.delta.period indicates the measurement interval.
{% highlight yaml %} {% read example_yaml/enricher-time-weighted-delta.yaml %} {% endhighlight %}
org.apache.brooklyn.policy.enricher.RollingMeanEnricher
Transforms a sensor into a rolling average based on a fixed window size. This is useful for smoothing sample type metrics, such as latency or CPU time
org.apache.brooklyn.policy.enricher.RollingTimeWindowMeanEnricher
Transforms a sensor's data into a rolling average based on a time window. This time window can be specified with the config key confidenceRequired - Minimum confidence level (ie period covered) required to publish a rolling average (default 8d).
org.apache.brooklyn.policy.enricher.RollingTimeWindowMeanEnricher.HttpLatencyDetector
An Enricher which computes latency in accessing a URL, normally by periodically polling that URL. This is then published in the sensors web.request.latency.last and web.request.latency.windowed.
There are a number of additional configuration keys available for the Http Latency Detector:
| Configuration Key | Default | Description |
|---|---|---|
| latencyDetector.url | The URL to compute the latency of | |
| latencyDetector.urlSensor | A sensor containing the URL to compute the latency of | |
| latencyDetector.urlPostProcessing | Function applied to the urlSensor value, to determine the URL to use | |
| latencyDetector.rollup | The window size (in duration) over which to compute | |
| latencyDetector.requireServiceUp | false | Require the service is up |
| latencyDetector.period | 1s | The period of polling |
org.apache.brooklyn.enricher.stock.Combiner
Can be used to combine the values of sensors. This enricher should be instantiated using Enrichers.builder().combining(..). This enricher is only available in Java blueprints and cannot be used in YAML.
If an entity needs an enricher whose source sensor (enricher.sourceSensor) belongs to another entity, then the enricher configuration must include an enricher.producer key referring to the other entity.
For example, if we consider the Transfomer from above, suppose that enricher.sourceSensor: $brooklyn:sensor("urls.tcp.list") is actually a sensor on a different entity called load.balancer. In this case, we would need to supply an enricher.producer value.
{% highlight yaml %} {% read example_yaml/enricher-transformer.yaml %} {% endhighlight %}
It is important to note that the value supplied to enricher.producer must be immediately resolvable. While it would be valid DSL syntax to write:
{% highlight yaml %} enricher.producer: brooklyn:entity($brooklyn:attributeWhenReady(“load.balancer.entity”)) {% endhighlight %}
(assuming the load.balancer.entity sensor returns a Brooklyn entity), this will not function properly because enricher.producer will unsuccessfully attempt to get the supplied entity immediately.