Add logic starlark example (#7864)
This commit is contained in:
parent
de313fcde6
commit
903a065a0d
|
|
@ -152,6 +152,9 @@ Attempting to modify the global scope will fail with an error.
|
||||||
- [ratio](/plugins/processors/starlark/testdata/ratio.star)
|
- [ratio](/plugins/processors/starlark/testdata/ratio.star)
|
||||||
- [rename](/plugins/processors/starlark/testdata/rename.star)
|
- [rename](/plugins/processors/starlark/testdata/rename.star)
|
||||||
- [scale](/plugins/processors/starlark/testdata/scale.star)
|
- [scale](/plugins/processors/starlark/testdata/scale.star)
|
||||||
|
- [number logic](/plugins/processors/starlark/testdata/number_logic.star)
|
||||||
|
|
||||||
|
Open a [PR](https://github.com/influxdata/telegraf/compare) to add any other useful Starlark examples.
|
||||||
|
|
||||||
[specification]: https://github.com/google/starlark-go/blob/master/doc/spec.md
|
[specification]: https://github.com/google/starlark-go/blob/master/doc/spec.md
|
||||||
[string]: https://github.com/google/starlark-go/blob/master/doc/spec.md#strings
|
[string]: https://github.com/google/starlark-go/blob/master/doc/spec.md#strings
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Set any 'status' field between 1 and 6 to a value of 0
|
||||||
|
|
||||||
|
def apply(metric):
|
||||||
|
v = metric.fields.get('status')
|
||||||
|
if v == None:
|
||||||
|
return metric
|
||||||
|
if 1 < v and v < 6:
|
||||||
|
metric.fields['status'] = 0
|
||||||
|
return metric
|
||||||
Loading…
Reference in New Issue