Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add example input/outputs to starlark examples #7980

Merged
merged 6 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion plugins/processors/starlark/testdata/number_logic.star
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Set any 'status' field between 1 and 6 to a value of 0
# Set a logic function to transform a numerical value to another numerical value
# Example: Set any 'status' field between 1 and 6 to a value of 0
#
# Example Input:
# lb, http_method=GET status=5 1465839830100400201
# Example Output:
# lb, http_method=GET status=0 1465839830100400201


def apply(metric):
v = metric.fields.get('status')
Expand Down
7 changes: 7 additions & 0 deletions plugins/processors/starlark/testdata/ratio.star
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Compute the ratio of two integer fields.
#
# Example: A new field 'usage' from an existing fields 'used' and 'total'
#
# Example Input:
# memory, host=hostname used=11038756864.4948,total=17179869184.1221 1597255082000000000
# Example Output:
# memory, host=hostname used=11038756864.4948,total=17179869184.1221,usage=64.254021647 1597255082000000000

def apply(metric):
used = float(metric.fields['used'])
Expand Down
5 changes: 5 additions & 0 deletions plugins/processors/starlark/testdata/rename.star
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Rename any tags using the mapping in the renames dict.
#
# Example Input:
# measurement, host=hostname lower=0,upper=100 1597255410000000000
# Example Output:
# measurement, host=hostname min=0,max=100 1597255410000000000

renames = {
'lower': 'min',
Expand Down
5 changes: 5 additions & 0 deletions plugins/processors/starlark/testdata/scale.star
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Multiply any float fields by 10
#
# Example Input:
# modbus,host=hostname Current=1.22,Energy=0,Frequency=60i,Power=0,Voltage=123.9000015258789 1554079521000000000
# Example Output:
# modbus,host=hostname Current=12.2,Energy=0,Frequency=60i,Power=0,Voltage=1239.000015258789 1554079521000000000

def apply(metric):
for k, v in metric.fields.items():
Expand Down