add example input/outputs to starlark examples (#7980)
* 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
This commit is contained in:
parent
389c5380ed
commit
901e63e37d
|
|
@ -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):
|
def apply(metric):
|
||||||
v = metric.fields.get('status')
|
v = metric.fields.get('status')
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,11 @@
|
||||||
# Compute the ratio of two integer fields.
|
# 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):
|
def apply(metric):
|
||||||
used = float(metric.fields['used'])
|
used = float(metric.fields['used'])
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
# Rename any tags using the mapping in the renames dict.
|
# 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 = {
|
renames = {
|
||||||
'lower': 'min',
|
'lower': 'min',
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
# Multiply any float fields by 10
|
# 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):
|
def apply(metric):
|
||||||
for k, v in metric.fields.items():
|
for k, v in metric.fields.items():
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue