Skip to content

feat(agent): Add option to skip re-running processors after aggregators#14882

Merged
mstrandboge merged 1 commit intoinfluxdata:masterfrom
powersj:fix/7993
Feb 23, 2024
Merged

feat(agent): Add option to skip re-running processors after aggregators#14882
mstrandboge merged 1 commit intoinfluxdata:masterfrom
powersj:fix/7993

Conversation

@powersj
Copy link
Copy Markdown
Contributor

@powersj powersj commented Feb 22, 2024

Summary

By default, after an aggregator is run the processors are run again. This can be helpful for users of aggregators to apply similar rules, however, this can also be very, very unexpected. As this behavior can result in aggregated values from getting scaled or computed against a second time.

While users can use the metric selectors to possibly omit the second run, it is nice to have a flag to remove this behavior entirely when it is not needed.

This introduces the skip_processors_after_aggregators config option, false by default.

Using a config with a processor that multiplies a float field by 10 each time it is run, by default:

❯ ./telegraf --config config.toml --test
2024-02-22T16:56:48Z I! Loading config: config.toml
2024-02-22T16:56:48Z I! Starting Telegraf 1.30.0-c4069a4b brought to you by InfluxData the makers of InfluxDB
2024-02-22T16:56:48Z I! Available plugins: 241 inputs, 9 aggregators, 30 processors, 24 parsers, 61 outputs, 6 secret-stores
2024-02-22T16:56:48Z I! Loaded inputs: exec
2024-02-22T16:56:48Z I! Loaded aggregators: minmax
2024-02-22T16:56:48Z I! Loaded processors: starlark
2024-02-22T16:56:48Z I! Loaded secretstores: 
2024-02-22T16:56:48Z W! Outputs are not used in testing mode!
2024-02-22T16:56:48Z I! Tags enabled: host=ryzen
2024-02-22T16:56:48Z D! [agent] Initializing plugins
2024-02-22T16:56:48Z D! [agent] Starting service inputs
2024-02-22T16:56:48Z D! [aggregators.minmax] Updated aggregation range [2024-02-22 09:56:30 -0700 MST, 2024-02-22 09:57:00 -0700 MST]
2024-02-22T16:56:48Z D! [agent] Stopping service inputs
2024-02-22T16:56:48Z D! [agent] Input channel closed
2024-02-22T16:56:48Z D! [agent] Processor channel closed
2024-02-22T16:56:48Z D! [aggregators.minmax] Updated aggregation range [2024-02-22 09:57:00 -0700 MST, 2024-02-22 09:57:30 -0700 MST]
2024-02-22T16:56:48Z D! [agent] Aggregator channel closed
> metric,host=ryzen value=420 1708621009000000000
2024-02-22T16:56:48Z D! [agent] Processor channel closed
2024-02-22T16:56:48Z D! [agent] Stopped Successfully
> metric,host=ryzen value_max=4200,value_min=4200 1708621009000000000

When set to true, note how the value is no longer scaled again.

❯ ./telegraf --config config.toml --test
2024-02-22T16:56:43Z I! Loading config: config.toml
2024-02-22T16:56:43Z I! Starting Telegraf 1.30.0-c4069a4b brought to you by InfluxData the makers of InfluxDB
2024-02-22T16:56:43Z I! Available plugins: 241 inputs, 9 aggregators, 30 processors, 24 parsers, 61 outputs, 6 secret-stores
2024-02-22T16:56:43Z I! Loaded inputs: exec
2024-02-22T16:56:43Z I! Loaded aggregators: minmax
2024-02-22T16:56:43Z I! Loaded processors: starlark
2024-02-22T16:56:43Z I! Loaded secretstores: 
2024-02-22T16:56:43Z W! Outputs are not used in testing mode!
2024-02-22T16:56:43Z I! Tags enabled: host=ryzen
2024-02-22T16:56:43Z D! [agent] Initializing plugins
2024-02-22T16:56:43Z D! [agent] Starting service inputs
2024-02-22T16:56:43Z D! [aggregators.minmax] Updated aggregation range [2024-02-22 09:56:30 -0700 MST, 2024-02-22 09:57:00 -0700 MST]
2024-02-22T16:56:43Z D! [agent] Stopping service inputs
2024-02-22T16:56:43Z D! [agent] Input channel closed
2024-02-22T16:56:43Z D! [agent] Processor channel closed
2024-02-22T16:56:43Z D! [aggregators.minmax] Updated aggregation range [2024-02-22 09:57:00 -0700 MST, 2024-02-22 09:57:30 -0700 MST]
2024-02-22T16:56:43Z D! [agent] Aggregator channel closed
2024-02-22T16:56:43Z D! [agent] Stopped Successfully
> metric,host=ryzen value=420 1708621004000000000
> metric,host=ryzen value_max=420,value_min=420 1708621004000000000

Checklist

  • No AI generated code was used in this PR

Related issues

fixes: #7993

@telegraf-tiger telegraf-tiger bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Feb 22, 2024
@powersj powersj marked this pull request as ready for review February 22, 2024 17:24
@powersj powersj added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Feb 22, 2024
@telegraf-tiger
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome @powersj! Can you please also check that invalid config options of processors are handled correctly, i.e. they produce an error!? I remember that there is some special handling for those as they are parsed twice...

@powersj
Copy link
Copy Markdown
Contributor Author

powersj commented Feb 22, 2024

Awesome @powersj! Can you please also check that invalid config options of processors are handled correctly, i.e. they produce an error!? I remember that there is some special handling for those as they are parsed twice...

Do you off-hand recall what might have existing tests for parsing twice (e.g. agent? config? procesosrs themselves)?

@srebhan
Copy link
Copy Markdown
Member

srebhan commented Feb 23, 2024

Looked it up and it seems this is covered by the tests. Sorry for the noise!

@srebhan srebhan removed their assignment Feb 23, 2024
@mstrandboge mstrandboge merged commit f0656a4 into influxdata:master Feb 23, 2024
@github-actions github-actions bot added this to the v1.30.0 milestone Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aggregators should not re-run processors

3 participants