Crates.io | fiddler |
lib.rs | fiddler |
version | 0.3.1 |
source | src |
created_at | 2024-03-31 00:08:22.653501 |
updated_at | 2024-04-15 04:05:04.124882 |
description | Data Stream processor written in rust |
homepage | |
repository | |
max_upload_size | |
id | 1191370 |
size | 124,269 |
input:
stdin: {}
pipeline:
max_in_flight: 10
processors:
- python:
string: true
code: |
import json
msg = json.loads(root)
msg['Python'] = 'rocks'
root = json.dumps(msg)
output:
switch:
- check:
condition: '\"Hello World\" > `5`'
output:
validate:
expected: []
- stdout: {}
The main inline message manipulation is provided by Python, and requires the Python shared library.
To install the Python shared library on Ubuntu:
sudo apt install python3-dev
To install the Python shared library on RPM based distributions (e.g. Fedora, Red Hat, SuSE), install the python3-devel
package.
Any third party packages utilized in Python will have to be installed on the OS running fiddler.
The message format in and out is simple, the source of the event is stored in the local variable named root
; and the output taken from executing the code is expected to be named root
. By default root
is bytes of the message, unless the argument string: true
is proved, in which case root
is converted to a string.
Conditional execution of steps for processing, or selection of outputs can be obtained through the use of check
and switch
plugins. For processing, it looks like:
- switch:
- check:
condition: '\"Hello World\" <= `5`'
processors:
- python:
string: true
code: |
import json
new_string = f\"python: {root}\"
root = new_string
- echo: {}
- label: my_cool_mapping
echo: {}
cargo install fiddler
fiddler run -c <path_to_config_file> [ -c ... ]
fiddler lint -c <path_to_config_file> [ -c ... ]
Tests are expected in the format of <filename>_test.yaml
. I.e. if you have a configuration input.yaml
. The expected filename is input_test.yaml
. The test file syntax is as follows:
- name: name_of_test
inputs:
- list of expected input strings
expected_outputs:
- list of expected output strings
Tests can be run as fiddler-cli test -c <path_to_configuration>.yaml
Build with Cargo cargo build --release --features all
input:
file:
filename: tests/data/input.txt
codec: ToEnd
filename
: string
: path to file to be readcodec
: string
: Possible Values: ToEnd
: Read entire file in one message. Lines
: Read file line by lineinput:
stdin: {}
processors:
- lines: {}
processors:
- noop: {}
processors:
- python:
string: true
code: |
import json
msg = json.loads(root)
msg['Python'] = 'rocks'
root = json.dumps(msg)
string
: bool
: whether or not the message contents are passed as a string or bytes (default)code
: string
: python code to executeprocessors:
- check:
condition: '\"Hello World\" <= `5`'
processors:
- python:
string: true
code: |
import json
new_string = f\"python: {root}\"
root = new_string
condition
: string
: jmespath expression to evaluate if processors are runprocessors
: list
: list of processors to run if condition is metprocessors:
- switch:
- check:
condition: '\"Hello World\" <= `5`'
processors:
- python:
string: true
code: |
import json
new_string = f\"python: {root}\"
root = new_string
- echo: {}
- echo: {}
array
: array of processors to run, typically used with the check
processor. once a processor is successful, no other processors are ranoutput:
stdout: {}
output:
check:
condition: '\"Hello World\" > `5`'
output:
stdout: {}
condition
: string
: jmespath expression to evaluate if processors are runoutput
: object
: output to use if check is trueoutput:
switch:
- check:
condition: '\"Hello World\" > `5`'
output:
validate:
expected: []
array
: array of outputs, typically used with the check
output.output:
elasticsearch:
url: http://example.com:9200
username: user
password: password
cloud_id: some_cloud_id
index: example
url
: if not using elasticsearch cloud, specify the url of the es cluster. i.e. http://127.0.0.1:9200username
: username for authenticationpassword
: password for authenticationcloud_id
: if using elasticsearch cloud, specify the cloud_idindex
: index to insert events intoNote: Variables can be collected from the environment, so when providing password, you may set it to password: "{{ ElasticSearchPassword }}"
and ElasticSearchPassword will be pulled from the environment variables and provided to the configuration.
Contributions are welcome and encouraged! Contributions come in many forms. You could:
Note that unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in fiddler by you shall be licensed under the Apache License, Version 2.0, without any additional terms or conditions.