forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(agent): Respect processor order in file (influxdata#13614)
- Loading branch information
Showing
14 changed files
with
219 additions
and
7 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,2 @@ | ||
new_metric_from_starlark,foo=bar baz=42i,timestamp="2023-07-13T12:53:54.197709713Z" 1689252834197709713 | ||
old_metric_from_mock,mood=good value=23i,timestamp="2023-07-13T13:10:34Z" 1689253834000000000 |
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 @@ | ||
old_metric_from_mock,mood=good value=23i 1689253834000000000 |
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,26 @@ | ||
# Test for using the appearance order in the file for processor order | ||
[[inputs.file]] | ||
files = ["testcases/processor-order-appearance/input.influx"] | ||
data_format = "influx" | ||
|
||
[[processors.starlark]] | ||
source = ''' | ||
def apply(metric): | ||
metrics = [] | ||
|
||
m = Metric("new_metric_from_starlark") | ||
m.tags["foo"] = "bar" | ||
m.fields["baz"] = 42 | ||
m.time = 1689252834197709713 | ||
metrics.append(m) | ||
metrics.append(metric) | ||
|
||
return metrics | ||
''' | ||
|
||
[[processors.date]] | ||
field_key = "timestamp" | ||
date_format = "2006-01-02T15:04:05.999999999Z" | ||
timezone = "UTC" | ||
|
||
|
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,2 @@ | ||
new_metric_from_starlark,foo=bar baz=42i,timestamp="2023-07-13T12:53:54.197709713Z" 1689252834197709713 | ||
old_metric_from_mock,mood=good value=23i,timestamp="2023-07-13T13:10:34Z" 1689253834000000000 |
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 @@ | ||
old_metric_from_mock,mood=good value=23i 1689253834000000000 |
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,27 @@ | ||
# Test for specifying an explicit processor order | ||
[[inputs.file]] | ||
files = ["testcases/processor-order-explicit/input.influx"] | ||
data_format = "influx" | ||
|
||
|
||
[[processors.date]] | ||
field_key = "timestamp" | ||
date_format = "2006-01-02T15:04:05.999999999Z" | ||
timezone = "UTC" | ||
order = 2 | ||
|
||
[[processors.starlark]] | ||
source = ''' | ||
def apply(metric): | ||
metrics = [] | ||
|
||
m = Metric("new_metric_from_starlark") | ||
m.tags["foo"] = "bar" | ||
m.fields["baz"] = 42 | ||
m.time = 1689252834197709713 | ||
metrics.append(m) | ||
metrics.append(metric) | ||
|
||
return metrics | ||
''' | ||
order = 1 |
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,2 @@ | ||
new_metric_from_starlark,foo=bar baz=42i,timestamp="2023-07-13T12:53:54.197709713Z" 1689252834197709713 | ||
old_metric_from_mock,mood=good value=23i,timestamp="2023-07-13T13:10:34Z" 1689253834000000000 |
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 @@ | ||
old_metric_from_mock,mood=good value=23i 1689253834000000000 |
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,25 @@ | ||
# Test for using the appearance order in the file for processor order | ||
[[inputs.file]] | ||
files = ["testcases/processor-order-appearance/input.influx"] | ||
data_format = "influx" | ||
|
||
[[processors.starlark]] | ||
source = ''' | ||
def apply(metric): | ||
metrics = [] | ||
|
||
m = Metric("new_metric_from_starlark") | ||
m.tags["foo"] = "bar" | ||
m.fields["baz"] = 42 | ||
m.time = 1689252834197709713 | ||
metrics.append(m) | ||
metrics.append(metric) | ||
|
||
return metrics | ||
''' | ||
|
||
[[processors.date]] | ||
field_key = "timestamp" | ||
date_format = "2006-01-02T15:04:05.999999999Z" | ||
timezone = "UTC" | ||
order = 1 |
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,2 @@ | ||
new_metric_from_starlark,foo=bar baz=42i 1689252834197709713 | ||
old_metric_from_mock,mood=good value=23i,timestamp="2023-07-13T13:10:34Z" 1689253834000000000 |
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 @@ | ||
old_metric_from_mock,mood=good value=23i 1689253834000000000 |
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,26 @@ | ||
# Test for using the appearance order in the file for processor order. | ||
# This will not add the "timestamp" field as the starlark processor runs _after_ | ||
# the date processor. | ||
[[inputs.file]] | ||
files = ["testcases/processor-order-no-starlark/input.influx"] | ||
data_format = "influx" | ||
|
||
[[processors.date]] | ||
field_key = "timestamp" | ||
date_format = "2006-01-02T15:04:05.999999999Z" | ||
timezone = "UTC" | ||
|
||
[[processors.starlark]] | ||
source = ''' | ||
def apply(metric): | ||
metrics = [] | ||
|
||
m = Metric("new_metric_from_starlark") | ||
m.tags["foo"] = "bar" | ||
m.fields["baz"] = 42 | ||
m.time = 1689252834197709713 | ||
metrics.append(m) | ||
metrics.append(metric) | ||
|
||
return metrics | ||
''' |