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.
Starlark script for renaming prometheus remote write metrics (influxd…
- Loading branch information
1 parent
78d67ba
commit 885bf27
Showing
3 changed files
with
23 additions
and
4 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
16 changes: 16 additions & 0 deletions
16
plugins/processors/starlark/testdata/rename_prometheus_remote_write.star
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,16 @@ | ||
# Specifically for prometheus remote write - renames the measurement name to the fieldname. Renames the fieldname to value. | ||
# Assumes there is only one field as is the case for prometheus remote write. | ||
# | ||
# Example Input: | ||
# prometheus_remote_write,instance=localhost:9090,job=prometheus,quantile=0.99 go_gc_duration_seconds=4.63 1614889298859000000 | ||
# | ||
# Example Output: | ||
# go_gc_duration_seconds,instance=localhost:9090,job=prometheus,quantile=0.99 value=4.63 1614889299000000000 | ||
|
||
def apply(metric): | ||
if metric.name == "prometheus_remote_write": | ||
for k, v in metric.fields.items(): | ||
metric.name = k | ||
metric.fields["value"] = v | ||
metric.fields.pop(k) | ||
return metric |