README.adoc

Field Value Counter Sink

A field value counter is a Metric used for counting occurrences of unique values for a named field in a message payload.

Input

Headers

content-type: application/octet-stream

Payload

  • POJO (Java bean)

  • Map

Headers

content-type: text/plain

Payload

  • JSON String

Headers

content-type: application/x-spring-tuple

Payload

  • Tuple

For example suppose a message source produces a payload with a field named user :

class Foo {
   String user;
   public Foo(String user) {
       this.user = user;
   }
}

If the stream source produces messages with the following objects:

   new Foo("fred")
   new Foo("sue")
   new Foo("dave")
   new Foo("sue")

The field value counter on the field user will contain:

fred:1, sue:2, dave:1

Multi-value fields are also supported. For example, if a field contains a list, each value will be counted once:

users:["dave","fred","sue"]
users:["sue","jon"]

The field value counter on the field users will contain:

dave:1, fred:1, sue:2, jon:1

Output

N/A

Options

The field-value-counter sink has the following options:

field-value-counter.field-name

The field name to extract for the counter. (String, default: <none>)

field-value-counter.name

The name of the counter to increment. (String, default: <none>)

field-value-counter.name-expression

A SpEL expression (against the incoming Message) to derive the name of the counter to increment. (Expression, default: <none>)

spring.redis.database

Database index used by the connection factory. (Integer, default: 0)

spring.redis.host

Redis server host. (String, default: localhost)

spring.redis.password

Login password of the redis server. (String, default: <none>)

spring.redis.port

Redis server port. (Integer, default: 6379)

spring.redis.ssl

Whether to enable SSL support. (Boolean, default: false)

spring.redis.timeout

Connection timeout. (Duration, default: <none>)

spring.redis.url

Connection URL. Overrides host, port, and password. User is ignored. Example: redis://user:password@example.com:6379 (String, default: <none>)

Build

$ ./mvnw clean install -PgenerateApps
$ cd apps

You can find the corresponding binder based projects here. You can then cd into one one of the folders and build it:

$ ./mvnw clean package

Examples

java -jar field-value-counter-sink.jar --fieldName=<field-name> --name=<name of the counter>