Runlength

Runlength is a formatter that prepends the length of the message, followed by a “:”. The actual message is formatted by a nested formatter.

Parameters

Separator (default: :)

This value is used as separator. By default this parameter is set to “:”.

StoreRunlengthOnly (default: false)

If this value is set to “true” only the runlength will stored. This option is useful to e.g. create metadata fields only containing the length of the payload. When set to “true” the Separator parameter will be ignored. By default this parameter is set to false.

Parameters (from core.SimpleFormatter)

Source

This value chooses the part of the message the data to be formatted should be read from. Use “” to target the message payload; other values specify the name of a metadata field to target. By default this parameter is set to “”.

Target

This value chooses the part of the message the formatted data should be stored to. Use “” to target the message payload; other values specify the name of a metadata field to target. By default this parameter is set to “”.

ApplyTo

Use this to set Source and Target to the same value. This setting will be ignored if either Source or Target is set to something else but “”. By default this parameter is set to “”.

SkipIfEmpty

When set to true, this formatter will not be applied to data that is empty or - in case of metadata - not existing. By default this parameter is set to false

Examples

This example will store the length of the payload in a separate metadata field.

exampleConsumer:
  Type: consumer.Console
  Streams: "*"
  Modulators:
    - format.MetadataCopy:
      CopyToKeys: ["length"]
    - format.Runlength:
      Target: length
      StoreRunlengthOnly: true