Skip to content

Commit

Permalink
add example input/outputs to starlark examples (#7980)
Browse files Browse the repository at this point in the history
* add sample input/outputs to starlark examples

* update ratio.star with example input/outputs

* Update rename.star

* update scale.star with input/output examples

* fix spacing

* fix spacing
  • Loading branch information
sjwang90 authored Aug 19, 2020
1 parent 389c538 commit 901e63e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
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

0 comments on commit 901e63e

Please sign in to comment.