forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the math module to the Starlark Processor (influxdata#9042)
- Loading branch information
Showing
3 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Example showing how the math module can be used to compute the value of a field. | ||
# | ||
# Example Input: | ||
# math value=10000i 1465839830100400201 | ||
# | ||
# Example Output: | ||
# math result=4 1465839830100400201 | ||
|
||
load('math.star', 'math') | ||
# loads all the functions and constants defined in the math module | ||
|
||
def apply(metric): | ||
metric.fields["result"] = math.log(metric.fields.pop('value'), 10) | ||
return metric |