Skip to content

Comments

feat(outputs.redistimeseries): Add option to expire values#18337

Merged
skartikey merged 5 commits intoinfluxdata:masterfrom
trgwii:outputs_redistimeseries_expire
Feb 24, 2026
Merged

feat(outputs.redistimeseries): Add option to expire values#18337
skartikey merged 5 commits intoinfluxdata:masterfrom
trgwii:outputs_redistimeseries_expire

Conversation

@trgwii
Copy link
Contributor

@trgwii trgwii commented Feb 11, 2026

Summary

Sending metrics to redis in addition to a database seems like a great way to boost performance, since one can offload querying to redis. In some cases it's important to be able to detect on the output side whether or not data collection / transferral is "down", so we might want to set expiry to a relatively short value, such that the value is gone if there were no metrics reported for a while. This can enable observers of the data to easily notice that something went wrong without having to check service statuses or logs or similar.

Checklist

Related issues

resolves #18336

@telegraf-tiger
Copy link
Contributor

Thanks so much for the pull request!
🤝 ✒️ Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla

@trgwii
Copy link
Contributor Author

trgwii commented Feb 11, 2026

!signed-cla

@trgwii trgwii force-pushed the outputs_redistimeseries_expire branch from 771ae54 to 09182ea Compare February 11, 2026 08:06
@trgwii trgwii changed the title Add option to expire values feat(outputs.redistimeseries): Add option to expire values Feb 11, 2026
@telegraf-tiger telegraf-tiger bot added feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins labels Feb 11, 2026
@trgwii trgwii force-pushed the outputs_redistimeseries_expire branch from 09182ea to a94ca4b Compare February 11, 2026 08:18
@trgwii trgwii force-pushed the outputs_redistimeseries_expire branch from a94ca4b to 134d6b6 Compare February 11, 2026 11:39
@mstrandboge mstrandboge self-assigned this Feb 18, 2026
Copy link
Member

@mstrandboge mstrandboge left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I have a couple minor comments

@trgwii trgwii force-pushed the outputs_redistimeseries_expire branch from d0965d8 to 061f31f Compare February 19, 2026 08:04
@trgwii
Copy link
Contributor Author

trgwii commented Feb 19, 2026

Looks like all CI runs are failing the test-integration check right now:
https://app.circleci.com/pipelines/github/influxdata/telegraf

@mstrandboge
Copy link
Member

Looks like all CI runs are failing the test-integration check right now: https://app.circleci.com/pipelines/github/influxdata/telegraf

Yes, this is unrelated to your PR so it won't affect merging

Copy link
Member

@mstrandboge mstrandboge left a comment

Choose a reason for hiding this comment

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

Thanks!

@mstrandboge mstrandboge assigned skartikey and srebhan and unassigned mstrandboge Feb 19, 2026
@mstrandboge mstrandboge 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 19, 2026
Copy link
Contributor

@skartikey skartikey left a comment

Choose a reason for hiding this comment

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

The PR adds a feature but no tests. At minimum, a new testcase directory (e.g., testcases/expire/) should be added to exercise the expire path. The existing TestCases framework already supports loading configs from directories, so adding a test config with expire = "60s" and verifying the key has a TTL set would be straightforward.

- Add a testcase for expiry, modify redistimeseries_test.go to append "; expires" to the end of each line with a TTL set
- Switch from always using a pipeline to only doing it when expire is enabled
- Update sample configuration to reflect the default of no expiry and clarify the description
@trgwii
Copy link
Contributor Author

trgwii commented Feb 20, 2026

The PR adds a feature but no tests. At minimum, a new testcase directory (e.g., testcases/expire/) should be added to exercise the expire path. The existing TestCases framework already supports loading configs from directories, so adding a test config with expire = "60s" and verifying the key has a TTL set would be straightforward.

I have created a testcase, and also slightly modified redistimeseries_test.go. Please let me know if you would like this implemented in a different way, but this seemed like the most obvious way to communicate whether or not a specific key has TTL set without introducing flakiness like matching on "how many seconds until expiry".

@trgwii
Copy link
Contributor Author

trgwii commented Feb 20, 2026

The CI managed to pass redistimeseries before crashing!

ok      github.com/influxdata/telegraf/plugins/outputs/redistimeseries  9.305s

Copy link
Contributor

@skartikey skartikey left a comment

Choose a reason for hiding this comment

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

@trgwii Thanks for the PR! A couple of comments for you to take a look at.

No validation for Expire value

File: redistimeseries.go (no Init() method)

A zero duration would cause Redis to delete the key immediately after writing, effectively making the plugin useless. A negative duration would result in a Redis error. There is currently no Init() method to validate this configuration.

Consider adding:

func (r *RedisTimeSeries) Init() error {
    if r.Expire != nil && time.Duration(*r.Expire) <= 0 {
        return errors.New("expire must be a positive duration")
    }
    return nil
}

Low severity since Redis would error on negative values and zero does not crash, but it can lead to a hard-to-debug configuration issue.

- Include Init() function to validate that the expire configuration option is > 0 if set
- Include more descriptive explanation on the exact behavior on the expire option
@trgwii
Copy link
Contributor Author

trgwii commented Feb 24, 2026

@skartikey All suggestions directly applied, thanks!

…sion

- Use "expire the key" instead of "drop the metric" in sample.conf and README since Redis operates on keys, not metrics
- Use TTL > 0 instead of != -1 for more precise TTL detection in tests
- Distinguish pipeline error message from direct write error message
@telegraf-tiger
Copy link
Contributor

Copy link
Contributor

@skartikey skartikey left a comment

Choose a reason for hiding this comment

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

@trgwii Thanks for the contribution!

@skartikey skartikey merged commit 585fbff into influxdata:master Feb 24, 2026
26 of 27 checks passed
@github-actions github-actions bot added this to the v1.38.0 milestone Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins 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.

[outputs.redistimeseries] Allow expiring values

4 participants