diff --git a/cmd/stanza/init_common.go b/cmd/stanza/init_common.go index b77a8bebc..0599d2d2b 100644 --- a/cmd/stanza/init_common.go +++ b/cmd/stanza/init_common.go @@ -27,6 +27,7 @@ import ( _ "github.com/observiq/stanza/operator/builtin/transformer/hostmetadata" _ "github.com/observiq/stanza/operator/builtin/transformer/k8smetadata" _ "github.com/observiq/stanza/operator/builtin/transformer/metadata" + _ "github.com/observiq/stanza/operator/builtin/transformer/move" _ "github.com/observiq/stanza/operator/builtin/transformer/noop" _ "github.com/observiq/stanza/operator/builtin/transformer/ratelimit" _ "github.com/observiq/stanza/operator/builtin/transformer/recombine" diff --git a/docs/operators/move.md b/docs/operators/move.md new file mode 100644 index 000000000..fc82080b1 --- /dev/null +++ b/docs/operators/move.md @@ -0,0 +1,283 @@ +## `move` operator + +The `move` operator moves (or renames) a field from one location to another. + +It's configured by passing 'to' and 'from' fields. + +### Configuration Fields + +| Field | Default | Description | +| --- | --- | --- | +| `id` | `move` | A unique identifier for the operator | +| `output` | Next in pipeline | The connected operator(s) that will receive all outbound entries | +| `from` | required | The [field](/docs/types/field.md) to move the value out of. +| `to` | required | The [field](/docs/types/field.md) to move the value into. +| `on_error` | `send` | The behavior of the operator if it encounters an error. See [on_error](/docs/types/on_error.md) | +| `if` | | An [expression](/docs/types/expression.md) 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: + +Rename value +```yaml +- type: move + from: key1 + to: key3 +``` + +
Input Entry | Output Entry |
+ +```json +{ + "resource": { }, + "labels": { }, + "record": { + "key1": "val1", + "key2": "val2" + } +} +``` + + | ++ +```json +{ + "resource": { }, + "labels": { }, + "record": { + "key3": "val1", + "key2": "val2" + } +} +``` + + | +
Input Entry | Output Entry |
+ +```json +{ + "resource": { }, + "labels": { }, + "record": { + "uuid": "091edc50-d91a-460d-83cd-089a62937738" + } +} +``` + + | ++ +```json +{ + "resource": { + "uuid": "091edc50-d91a-460d-83cd-089a62937738" + }, + "labels": { }, + "record": { } +} +``` + + | +
Input Entry | Output Entry |
+ +```json +{ + "resource": { }, + "labels": { }, + "record": { + "ip": "8.8.8.8" + } +} +``` + + | ++ +```json +{ + "resource": { }, + "labels": { + "ip": "8.8.8.8" + }, + "record": { } +} +``` + + | +
Input Entry | Output Entry |
+ +```json +{ + "resource": { }, + "labels": { }, + "record": { + "log": "The log line" + } +} +``` + + | ++ +```json +{ + "resource": { }, + "labels": { }, + "record": "The log line" +} +``` + + | +
Input Entry | Output Entry |
+ +```json +{ + "resource": { }, + "labels": { }, + "record": { + "wrapper": { + "key1": "val1", + "key2": "val2", + "key3": "val3" + } + } +} +} +``` + + | ++ +```json +{ + "resource": { }, + "labels": { }, + "record": { + "key1": "val1", + "key2": "val2", + "key3": "val3" + } +} +``` + + | +
Input Entry | Output Entry |
+ +```json +{ + "resource": { }, + "labels": { }, + "record": { + "wrapper": { + "key1": "val1", + "key2": "val2", + "key3": "val3" + }, + "key4": "val1", + "key5": "val2", + "key6": "val3" + } +} +``` + + | ++ +```json +{ + "resource": { }, + "labels": { }, + "record": { + "key1": "val1", + "key2": "val2", + "key3": "val3", + "key4": "val1", + "key5": "val2", + "key6": "val3" + } +} +``` + + | +