The add operator adds a value to an entry's record, labels, or resource.
| Field | Default | Description |
|---|---|---|
id |
add |
A unique identifier for the operator |
output |
Next in pipeline | The connected operator(s) that will receive all outbound entries |
field |
required | The field to be added. |
value |
required | value is either a static value or an expression. If a value is specified, it will be added to each entry at the field defined by field. If an expression is specified, it will be evaluated for each entry and added at the field defined by field |
on_error |
send |
The behavior of the operator if it encounters an error. See on_error |
if |
An expression that, when set, will be evaluated to determine whether this operator should be used for the given entry. This allows you to do easy conditional parsing without branching logic with routers. |
Example usage:
Add a string to the record
- type: add
field: key2
value: val2| Input entry | Output entry |
{
"resource": { },
"labels": { },
"record": {
"key1": "val1",
}
} |
{
"resource": { },
"labels": { },
"record": {
"key1": "val1",
"key2": "val2"
}
} |
Add a value to the record using an expression
- type: add
field: key2
value: EXPR($.key1 + "_suffix")| Input entry | Output entry |
{
"resource": { },
"labels": { },
"record": {
"key1": "val1",
}
} |
{
"resource": { },
"labels": { },
"record": {
"key1": "val1",
"key2": "val1_suffix"
}
} |
Add an object to the record
- type: add
field: key2
value:
nestedkey: nestedvalue| Input entry | Output entry |
{
"resource": { },
"labels": { },
"record": {
"key1": "val1",
}
} |
{
"resource": { },
"labels": { },
"record": {
"key1": "val1",
"key2": {
"nestedkey":"nested value"
}
}
} |
Add a value to labels
- type: add
field: $labels.key2
value: val2| Input entry | Output entry |
{
"resource": { },
"labels": { },
"record": {
"key1": "val1",
}
} |
{
"resource": { },
"labels": {
"key2": "val2"
},
"record": {
"key1": "val1"
}
} |
Add a value to resource
- type: add
field: $resource.key2
value: val2| Input entry | Output entry |
{
"resource": { },
"labels": { },
"record": {
"key1": "val1",
}
} |
{
"resource": {
"key2": "val2"
},
"labels": { },
"record": {
"key1": "val1"
}
} |
Add a value to resource using an expression
- type: add
field: $resource.key2
value: EXPR($.key1 + "_suffix")| Input entry | Output entry |
{
"resource": { },
"labels": { },
"record": {
"key1": "val1",
}
} |
{
"resource": {
"key2": "val_suffix"
},
"labels": { },
"record": {
"key1": "val1",
}
} |