-
Notifications
You must be signed in to change notification settings - Fork 875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Add option to exclude consumer from Stream metrics #906
Feature: Add option to exclude consumer from Stream metrics #906
Conversation
There was a problem hiding this 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!
Looks good, minor suggestions re: naming to make it more clear what you're excluding (metrics) but I think you're going in the right direction.
README.md
Outdated
@@ -148,6 +148,7 @@ Prometheus uses file watches and all changes to the json file are applied immedi | |||
| check-single-keys | REDIS_EXPORTER_CHECK_SINGLE_KEYS | Comma separated list of keys to export value and length/size, eg: `db3=user_count` will export key `user_count` from db `3`. db defaults to `0` if omitted. The keys specified with this flag will be looked up directly without any glob pattern matching. Use this option if you don't need glob pattern matching; it is faster than `check-keys`. | | |||
| check-streams | REDIS_EXPORTER_CHECK_STREAMS | Comma separated list of stream-patterns to export info about streams, groups and consumers. Syntax is the same as `check-keys`. | | |||
| check-single-streams | REDIS_EXPORTER_CHECK_SINGLE_STREAMS | Comma separated list of streams to export info about streams, groups and consumers. The streams specified with this flag will be looked up directly without any glob pattern matching. Use this option if you don't need glob pattern matching; it is faster than `check-streams`. | | |||
| streams-exclude-consumer | REDIS_EXPORTER_STREAMS_EXCLUDE_CONSUMER | Don't collect per consumer metrics for streams (decreases amount of metrics and cardinality). | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REDIS_EXPORTER_STREAMS_EXCLUDE_CONSUMER -> REDIS_EXPORTER_STREAMS_EXCLUDE_CONSUMER_METRICS ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, sure.
My only concern was that it would be quite long, but not too much I think)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, committed changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently tests are failing, but I don't see exact reason.
In the end of output only:
FAIL
coverage: 90.0% of statements
FAIL github.com/oliver006/redis_exporter/exporter 22.273s
FAIL
And before something looks like errors, but nothing says FAIL
=== RUN TestParseKeyArg/invalid_args_with_args_separator_skipped
time="2024-05-20T17:54:09Z" level=error msg="parseKeyArg(): Empty value parsed in pair '=', skip"
=== RUN TestParseKeyArg/empty_args_with_comma_separators_skipped
=== RUN TestParseKeyArg/multiple_invalid_args_skipped
time="2024-05-20T17:54:09Z" level=error msg="parseKeyArg(): Empty value parsed in pair '=', skip"
time="2024-05-20T17:54:09Z" level=error msg="parseKeyArg(): Empty value parsed in pair '=', skip"
=== RUN TestParseKeyArg/empty_key_with_args_separator_skipped
time="2024-05-20T17:54:09Z" level=error msg="parseKeyArg(): Empty value parsed in pair '0=', skip"
=== RUN TestParseKeyArg/empty_database_with_args_separator_skipped
time="2024-05-20T17:54:09Z" level=error msg="parseKeyArg(): Empty value parsed in pair '=my-key', skip"
=== RUN TestParseKeyArg/string_database_index
keys_test.go:265: Expected failure for test: string_database_index, got err: Invalid database index for db "wrong": strconv.Atoi: parsing "wrong": invalid syntax
=== RUN TestParseKeyArg/prefixed_string_database_index
keys_test.go:265: Expected failure for test: prefixed_string_database_index, got err: Invalid database index for db "wrong": strconv.Atoi: parsing "wrong": invalid syntax
=== RUN TestParseKeyArg/wrong_args_count
keys_test.go:265: Expected failure for test: wrong_args_count, got err: invalid key list argument: wrong=wrong=wrong
=== RUN TestParseKeyArg/wrong_args
keys_test.go:265: Expected failure for test: wrong_args, got err: invalid key list argument: wrong=wrong=1
=== RUN TestParseKeyArg/negative_database_index
keys_test.go:265: Expected failure for test: negative_database_index, got err: Invalid database index for db "-1": %!s(<nil>)
exporter/exporter.go
Outdated
@@ -55,6 +55,7 @@ type Options struct { | |||
CheckSingleKeys string | |||
CheckStreams string | |||
CheckSingleStreams string | |||
StreamsExcludeConsumer bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, add Metrics
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Try rebasing your PR, I pushed a fix to master last week to fix an issue with an outdated Redis docker container. |
Pull Request Test Coverage Report for Build 352Details
💛 - Coveralls |
That helped, thank you. Though coverage decreased, I will check later today to add tests. |
Added tests for new option, but coverage still decreases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR looks good, minor comment re: the README but otherwise looks good
README.md
Outdated
@@ -148,6 +148,7 @@ Prometheus uses file watches and all changes to the json file are applied immedi | |||
| check-single-keys | REDIS_EXPORTER_CHECK_SINGLE_KEYS | Comma separated list of keys to export value and length/size, eg: `db3=user_count` will export key `user_count` from db `3`. db defaults to `0` if omitted. The keys specified with this flag will be looked up directly without any glob pattern matching. Use this option if you don't need glob pattern matching; it is faster than `check-keys`. | | |||
| check-streams | REDIS_EXPORTER_CHECK_STREAMS | Comma separated list of stream-patterns to export info about streams, groups and consumers. Syntax is the same as `check-keys`. | | |||
| check-single-streams | REDIS_EXPORTER_CHECK_SINGLE_STREAMS | Comma separated list of streams to export info about streams, groups and consumers. The streams specified with this flag will be looked up directly without any glob pattern matching. Use this option if you don't need glob pattern matching; it is faster than `check-streams`. | | |||
| streams-exclude-consumer | REDIS_EXPORTER_STREAMS_EXCLUDE_CONSUMER_METRICS | Don't collect per consumer metrics for streams (decreases amount of metrics and cardinality). | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
streams-exclude-consumer
--> streams-exclude-consumer-metrics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for noticing. Missed update here.
Now should be good.
checkKeyGroups = flag.String("check-key-groups", getEnv("REDIS_EXPORTER_CHECK_KEY_GROUPS", ""), "Comma separated list of lua regex for grouping keys") | ||
checkStreams = flag.String("check-streams", getEnv("REDIS_EXPORTER_CHECK_STREAMS", ""), "Comma separated list of stream-patterns to export info about streams, groups and consumers, searched for with SCAN") | ||
checkSingleStreams = flag.String("check-single-streams", getEnv("REDIS_EXPORTER_CHECK_SINGLE_STREAMS", ""), "Comma separated list of single streams to export info about streams, groups and consumers") | ||
streamsExcludeConsumerMetrics = flag.Bool("streams-exclude-consumer-metrics", getEnvBool("REDIS_EXPORTER_STREAMS_EXCLUDE_CONSUMER_METRICS", false), "Don't collect per consumer metrics for streams (decreases cardinality)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
streams-exclude-consumer-metrics
- here you got it right :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now, thanks for the PR!
@oliver006 when you have time, could you please merge this PR if all looks good now and release a new version? |
Thanks for the nudge. |
Yep, probably can check it later today. |
…6#906) * Feature: Add option to exclude consumer from Stream metrics
Released v1.60.0 which includes this and your other PRs - nice work, thanks for all your contributions! |
Thank you! |
Tested it manually, looks like working properly, PTAL.
Probably need to add more tests, can check it later.
Amount of metrics on test redis:
REDIS_EXPORTER_CHECK_STREAMS=*
- 680Fixes: #902