forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show how to return a custom error with the Starlark processor (influx…
- Loading branch information
Showing
3 changed files
with
59 additions
and
2 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,13 @@ | ||
# Example of the way to return a custom error thanks to the built-in function fail | ||
# Returning an error will drop the current metric. Consider using logging instead if you want to keep the metric. | ||
# | ||
# Example Input: | ||
# fail value=1 1465839830100400201 | ||
# | ||
# Example Output Error: | ||
# fail: The field value should be greater than 1 | ||
|
||
def apply(metric): | ||
if metric.fields["value"] <= 1: | ||
return fail("The field value should be greater than 1") | ||
return metric |