Skip to main content
Version: 3.3.1

transition

Performs various actions based on a changed field

Field NameDescriptionTypeDefault
conditionOnly run this action if the condition the specified condition is metexpression-
watch-fieldA field that is watched for changesfield-
elapsed-output-fieldA field that will be used to store elapsed time between state changesfield-
time-fieldA field containing a time valueiso time field-
markerGenerate a new event, depending on if a transition has happenedarray of strings-
value-at-last-change-output-fieldContains state value of before transition happenedfield-
time-at-last-change-output-fieldContains timestamp of before transition happenedfield-
time-at-last-change-output-formatThe time format to be used for the time-at-last-change-output-fieldtime format-
candidate-time-at-transition-output-fieldThe time field of the record that caused the transitionfield-
threshold-countNumber of times a value must have been seen in a row, to consider a state change a transitioninteger1
threshold-count-output-fieldA field to record the action threshold count at the time of changefield-
group-byAllows tracking transitions individually in the case of aggregated datafield-
save-fileA file to persist state, to know where we left off in the case where the Pipe is restartedpath-
maximum-ageThe maximum age of any recorded historystring-
maximum-age-markerThe marker in the event stream to watch for to trigger a maximum age record sweepstring-

condition

Only run this action if the condition the specified condition is met

Type: expression

watch-field

A field that is watched for changes

The field value may be a string, number or boolean

Type: field

Example

input:

input:
exec:
command:
echo '{"state":0}';
sleep 1;
echo '{"state":1}';
sleep 1;
echo '{"state":1}';
raw: true
no-strip-linefeeds: true

action:

transition:
watch: state
elapsed-output-field: elapsed

output:

{"state":0,"elapsed":0}
{"state":1,"elapsed":0}
{"state":1,"elapsed":1002}

elapsed-output-field

A field that will be used to store elapsed time between state changes

Type: field

time-field

A field containing a time value

If not specified, system time is used instead.

Type: iso time field

Example

input:

{"time":"2020-02-03T15:34:55.149Z","state":0}
{"time":"2020-02-03T15:34:56.149Z","state":1}
{"time":"2020-02-03T15:34:57.149Z","state":1}

action:

transition:
watch: state
elapsed-output-field: elapsed
time-field: time

output:

{"time":"2020-02-03T15:34:55.149Z","state":0,"elapsed":0}
{"time":"2020-02-03T15:34:56.149Z","state":1,"elapsed":0}
{"time":"2020-02-03T15:34:57.149Z","state":1,"elapsed":1000}

marker

Generate a new event, depending on if a transition has happened

Type: array of strings

Example

input:

{"time":"2020-02-03T15:34:55.149Z","state":0}
{"time":"2020-02-03T15:34:56.149Z","state":1}
{"time":"2020-02-03T15:34:57.149Z","state":1}
{"time":"2020-02-03T15:34:58.149Z","state":0}

action:

transition:
watch: state
elapsed-output-field: elapsed
time-field: time
marker:
- marker

output:

{"time":"2020-02-03T15:34:55.149Z","state":0}
{"_marker":"marker","state":1,"elapsed":1000}
{"time":"2020-02-03T15:34:56.149Z","state":1}
{"time":"2020-02-03T15:34:57.149Z","state":1}
{"_marker":"marker","state":0,"elapsed":2000}
{"time":"2020-02-03T15:34:58.149Z","state":0}

value-at-last-change-output-field

Contains state value of before transition happened

This is useful for associating states with their duration

Type: field

Example

input:

{"time":"2020-02-03T15:34:55.149Z","state":0}
{"time":"2020-02-03T15:34:56.149Z","state":1}
{"time":"2020-02-03T15:34:57.149Z","state":1}
{"time":"2020-02-03T15:34:58.149Z","state":0}

action:

transition:
watch: state
elapsed-output-field: elapsed
time-field: time
marker:
- marker
value-at-last-change-output-field: previous

output:

{"time":"2020-02-03T15:34:55.149Z","state":0}
{"_marker":"marker","state":1,"elapsed":1000,"previous":0}
{"time":"2020-02-03T15:34:56.149Z","state":1}
{"time":"2020-02-03T15:34:57.149Z","state":1}
{"_marker":"marker","state":0,"elapsed":2000,"previous":1}
{"time":"2020-02-03T15:34:58.149Z","state":0}

time-at-last-change-output-field

Contains timestamp of before transition happened

Type: field

Example

input:

{"time":"2020-02-03T15:34:55.149Z","state":0}
{"time":"2020-02-03T15:34:56.149Z","state":1}
{"time":"2020-02-03T15:34:57.149Z","state":1}
{"time":"2020-02-03T15:34:58.149Z","state":0}

action:

transition:
watch: state
elapsed-output-field: elapsed
time-field: time
time-at-last-change-output-field: previous

output:

{"time":"2020-02-03T15:34:55.149Z","state":0,"elapsed":0,"previous":"2020-02-03T15:34:55.149Z"}
{"time":"2020-02-03T15:34:56.149Z","state":1,"elapsed":0,"previous":"2020-02-03T15:34:56.149Z"}
{"time":"2020-02-03T15:34:57.149Z","state":1,"elapsed":1000,"previous":"2020-02-03T15:34:56.149Z"}
{"time":"2020-02-03T15:34:58.149Z","state":0,"elapsed":0,"previous":"2020-02-03T15:34:58.149Z"}

Example: With a marker

input:

{"time":"2020-02-03T15:34:55.149Z","state":0}
{"time":"2020-02-03T15:34:56.149Z","state":1}
{"time":"2020-02-03T15:34:57.149Z","state":1}
{"time":"2020-02-03T15:34:58.149Z","state":0}

action:

transition:
watch: state
elapsed-output-field: elapsed
time-field: time
marker:
- marker
time-at-last-change-output-field: previous

output:

{"time":"2020-02-03T15:34:55.149Z","state":0}
{"_marker":"marker","state":1,"elapsed":1000,"previous":"2020-02-03T15:34:56.149Z"}
{"time":"2020-02-03T15:34:56.149Z","state":1}
{"time":"2020-02-03T15:34:57.149Z","state":1}
{"_marker":"marker","state":0,"elapsed":2000,"previous":"2020-02-03T15:34:58.149Z"}
{"time":"2020-02-03T15:34:58.149Z","state":0}

time-at-last-change-output-format

The time format to be used for the time-at-last-change-output-field

Type: time format

candidate-time-at-transition-output-field

The time field of the record that caused the transition

Type: field

threshold-count

Number of times a value must have been seen in a row, to consider a state change a transition

Note: This results in the watch field modified

Type: integer

Example

input:

{"time":"2020-02-03T15:34:45.149Z","state":0}
{"time":"2020-02-03T15:34:46.149Z","state":1}
{"time":"2020-02-03T15:34:47.149Z","state":1}
{"time":"2020-02-03T15:34:48.149Z","state":1}
{"time":"2020-02-03T15:34:49.149Z","state":0}
{"time":"2020-02-03T15:34:50.149Z","state":1}
{"time":"2020-02-03T15:34:51.149Z","state":0}
{"time":"2020-02-03T15:34:52.149Z","state":1}
{"time":"2020-02-03T15:34:53.149Z","state":0}
{"time":"2020-02-03T15:34:54.149Z","state":0}

action:

transition:
watch: state
elapsed-output-field: elapsed
time-field: time
threshold-count: 2

output:

{"time":"2020-02-03T15:34:45.149Z","state":0,"elapsed":0}
{"time":"2020-02-03T15:34:46.149Z","state":1,"elapsed":1000}
{"time":"2020-02-03T15:34:47.149Z","state":1,"elapsed":2000}
{"time":"2020-02-03T15:34:48.149Z","state":1,"elapsed":3000}
{"time":"2020-02-03T15:34:49.149Z","state":1,"elapsed":4000}
{"time":"2020-02-03T15:34:50.149Z","state":1,"elapsed":5000}
{"time":"2020-02-03T15:34:51.149Z","state":1,"elapsed":6000}
{"time":"2020-02-03T15:34:52.149Z","state":1,"elapsed":7000}
{"time":"2020-02-03T15:34:53.149Z","state":1,"elapsed":8000}
{"time":"2020-02-03T15:34:54.149Z","state":0,"elapsed":1000}

Example

input:

{"time":"2020-02-03T15:34:45.149Z","state":0}
{"time":"2020-02-03T15:34:46.149Z","state":1}
{"time":"2020-02-03T15:34:47.149Z","state":1}
{"time":"2020-02-03T15:34:48.149Z","state":1}
{"time":"2020-02-03T15:34:49.149Z","state":0}
{"time":"2020-02-03T15:34:50.149Z","state":1}
{"time":"2020-02-03T15:34:51.149Z","state":0}
{"time":"2020-02-03T15:34:52.149Z","state":1}
{"time":"2020-02-03T15:34:53.149Z","state":0}
{"time":"2020-02-03T15:34:54.149Z","state":0}

action:

transition:
watch: state
elapsed-output-field: elapsed
time-field: time
threshold-count: 1

output:

{"time":"2020-02-03T15:34:45.149Z","state":0,"elapsed":0}
{"time":"2020-02-03T15:34:46.149Z","state":1,"elapsed":0}
{"time":"2020-02-03T15:34:47.149Z","state":1,"elapsed":1000}
{"time":"2020-02-03T15:34:48.149Z","state":1,"elapsed":2000}
{"time":"2020-02-03T15:34:49.149Z","state":0,"elapsed":0}
{"time":"2020-02-03T15:34:50.149Z","state":1,"elapsed":0}
{"time":"2020-02-03T15:34:51.149Z","state":0,"elapsed":0}
{"time":"2020-02-03T15:34:52.149Z","state":1,"elapsed":0}
{"time":"2020-02-03T15:34:53.149Z","state":0,"elapsed":0}
{"time":"2020-02-03T15:34:54.149Z","state":0,"elapsed":1000}

threshold-count-output-field

A field to record the action threshold count at the time of change

Type: field

group-by

Allows tracking transitions individually in the case of aggregated data

Type: field

Example

input:

{"time":"2020-02-03T15:34:45.149Z","name":"john","state":0}
{"time":"2020-02-03T15:34:46.149Z","name":"jane","state":0}
{"time":"2020-02-03T15:34:47.149Z","name":"john","state":1}
{"time":"2020-02-03T15:34:48.149Z","name":"jane","state":1}
{"time":"2020-02-03T15:34:49.149Z","name":"john","state":1}
{"time":"2020-02-03T15:34:50.149Z","name":"jane","state":1}

action:

transition:
watch: state
elapsed-output-field: elapsed
time-field: time
group-by: name

output:

{"time":"2020-02-03T15:34:45.149Z","name":"john","state":0,"elapsed":0}
{"time":"2020-02-03T15:34:46.149Z","name":"jane","state":0,"elapsed":0}
{"time":"2020-02-03T15:34:47.149Z","name":"john","state":1,"elapsed":0}
{"time":"2020-02-03T15:34:48.149Z","name":"jane","state":1,"elapsed":0}
{"time":"2020-02-03T15:34:49.149Z","name":"john","state":1,"elapsed":2000}
{"time":"2020-02-03T15:34:50.149Z","name":"jane","state":1,"elapsed":2000}

Example: Without group-by usage

input:

{"time":"2020-02-03T15:34:45.149Z","name":"john","state":0}
{"time":"2020-02-03T15:34:46.149Z","name":"jane","state":0}
{"time":"2020-02-03T15:34:47.149Z","name":"john","state":1}
{"time":"2020-02-03T15:34:48.149Z","name":"jane","state":1}
{"time":"2020-02-03T15:34:49.149Z","name":"john","state":1}
{"time":"2020-02-03T15:34:50.149Z","name":"jane","state":1}

action:

transition:
watch: state
elapsed-output-field: elapsed
time-field: time

output:

{"time":"2020-02-03T15:34:45.149Z","name":"john","state":0,"elapsed":0}
{"time":"2020-02-03T15:34:46.149Z","name":"jane","state":0,"elapsed":1000}
{"time":"2020-02-03T15:34:47.149Z","name":"john","state":1,"elapsed":0}
{"time":"2020-02-03T15:34:48.149Z","name":"jane","state":1,"elapsed":1000}
{"time":"2020-02-03T15:34:49.149Z","name":"john","state":1,"elapsed":2000}
{"time":"2020-02-03T15:34:50.149Z","name":"jane","state":1,"elapsed":3000}

save-file

A file to persist state, to know where we left off in the case where the Pipe is restarted

Type: path

Example

input:

{"time":"2020-02-03T15:34:55.149Z","state":0}
{"time":"2020-02-03T15:34:56.149Z","state":1}
{"time":"2020-02-03T15:34:57.149Z","state":1}

action:

transition:
watch: state
elapsed-output-field: elapsed
time-field: time
save-file: transition-state.yml

output:

{"time":"2020-02-03T15:34:55.149Z","state":0,"elapsed":0}
{"time":"2020-02-03T15:34:56.149Z","state":1,"elapsed":0}
{"time":"2020-02-03T15:34:57.149Z","state":1,"elapsed":1000}

maximum-age

The maximum age of any recorded history

Type: string

maximum-age-marker

The marker in the event stream to watch for to trigger a maximum age record sweep

Type: string