Skip to content
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

Add Redis Sentinel Input Plugin #5978

Closed
wants to merge 12 commits into from

Conversation

adamflott
Copy link
Contributor

Fixed PR #5487

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

@adamflott
Copy link
Contributor Author

If you'd like me to add more tests for the other measurements I can do that, wanted to get an initial review before I spent more time on it.

@adamflott
Copy link
Contributor Author

@danielnelson Any update? We'd like to start pulling my PR changes into mainline

Copy link
Contributor

@glinton glinton left a comment

Choose a reason for hiding this comment

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

Thanks

etc/telegraf.conf Outdated Show resolved Hide resolved
plugins/inputs/redis_sentinel/README.md Show resolved Hide resolved
plugins/inputs/redis_sentinel/README.md Outdated Show resolved Hide resolved
plugins/inputs/redis_sentinel/redis_sentinel.go Outdated Show resolved Hide resolved
plugins/inputs/redis_sentinel/redis_sentinel.go Outdated Show resolved Hide resolved
plugins/inputs/redis_sentinel/redis_sentinel.go Outdated Show resolved Hide resolved
plugins/inputs/redis_sentinel/redis_sentinel.go Outdated Show resolved Hide resolved
plugins/inputs/redis_sentinel/redis_sentinel_test.go Outdated Show resolved Hide resolved
plugins/inputs/redis_sentinel/redis_sentinel_test.go Outdated Show resolved Hide resolved
@adamflott
Copy link
Contributor Author

@glinton will address tomorrow, thanks for the review!

@joeymiller
Copy link

Any update on merge? Excited to see this work.

@adamflott
Copy link
Contributor Author

Any update on merge? Excited to see this work.

Soon. Personal and work life have taken a priority to this.

@adamflott
Copy link
Contributor Author

adamflott commented Sep 13, 2019

Still trying to figure out why this the tests are failing, the output isn't terribly useful.

	accumulator.go:341: 
			Error Trace:	accumulator.go:341
			            				redis_sentinel_test.go:87
			Error:      	unknown measurement redis_sentinel with tags map[host:redis.net]
			Test:       	TestRedisSentinelParseInfo

@danielnelson
Copy link
Contributor

I recommend using testutil.MustMetric and testutil.RequireMetricsEqual for testing metrics instead of the acc.AssertContainsTaggedFields method. The output is a bit more helpful.

Here is an example of use, you can ignore the metric time using the testutil.IgnoreTime:

https://github.com/influxdata/telegraf/blob/master/plugins/processors/pivot/pivot_test.go

Adam Flott and others added 4 commits September 24, 2019 11:28
Use `uptime_ns` per upstream request and get tests passing
Record all errors with accumulator AddError()
- Add tests against `sentinel {masters,sentinels,replicas}`
- Convert `info all` test to use testutil.RequireMetricsEqual
- Change has-quorum to int (from bool)
@adamflott
Copy link
Contributor Author

Everything (code, tests, documentation) should be in now, please re-review. I'd love to get this in for 1.13 time

plugins/inputs/redis_sentinel/redis_sentinel_test.go Outdated Show resolved Hide resolved

- fields:
- config-epoch (int)
- down-after-milliseconds (int)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would down_after_ns be feasable (convert ms to ns as well)?


- fields:
- config-epoch (int)
- down-after-milliseconds (int)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would down_after_ns be feasable (convert ms to ns as well)?

plugins/inputs/redis_sentinel/README.md Outdated Show resolved Hide resolved
plugins/inputs/redis_sentinel/redis_sentinel.go Outdated Show resolved Hide resolved
Correct README uptime -> uptime_ns
Per project standards change all metric names to snake case
@adamflott adamflott requested a review from glinton October 8, 2019 19:12
Ensure compatibility with Go < 1.12
@adamflott
Copy link
Contributor Author

Any updates?

The keys coming out did not have their dashes properly replaced with underscores
Copy link
Contributor

@glinton glinton left a comment

Choose a reason for hiding this comment

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

Sorry for the delays in re-reviewing the requested changes. It looks like you've addressed them all. Thanks.

@adamflott
Copy link
Contributor Author

Sorry for the delays in re-reviewing the requested changes. It looks like you've addressed them all. Thanks.

Can I assume this plugin will not be a part of 1.13?

@danielnelson
Copy link
Contributor

Yes, sorry. Let's put it down for 1.14 though for sure.

@danielnelson danielnelson added this to the 1.14.0 milestone Dec 3, 2019
@adamflott
Copy link
Contributor Author

@danielnelson ready to merge? Don't wanna miss 1.14 :)

@danielnelson
Copy link
Contributor

The Influxdata team is team building out in Phoenix this week, but I'll try to review on Friday once I'm back home.


const measurementMasters = "redis_sentinel_masters"
const measurementSentinel = "redis_sentinel"
const measurementSentinels = "redis_sentinels"
Copy link
Contributor

Choose a reason for hiding this comment

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

redis_sentinel_sentinels

const measurementMasters = "redis_sentinel_masters"
const measurementSentinel = "redis_sentinel"
const measurementSentinels = "redis_sentinels"
const measurementReplicas = "redis_replicas"
Copy link
Contributor

Choose a reason for hiding this comment

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

redis_sentinel_replicas

Comment on lines +88 to +91
func (r *RedisSentinel) init(acc telegraf.Accumulator) error {
if r.initialized {
return nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename this function func (r *RedisSentinel) Init() error {, you can remove the initialized boolean.


for i, serv := range r.Servers {
if !strings.HasPrefix(serv, "tcp://") && !strings.HasPrefix(serv, "unix://") {
log.Printf("W! [inputs.redis_sentinel]: server URL found without scheme; please update your configuration file")
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't add in this support for addresses with a scheme, this is in the normal redis plugin only for backwards compatibility. If the address doesn't begin with tcp or unix return an error instead.


u, err := url.Parse(serv)
if err != nil {
acc.AddError(fmt.Errorf("Unable to parse to address %q: %v", serv, err))
Copy link
Contributor

Choose a reason for hiding this comment

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

Return an error here, which will cause the failure to be fatal. Since we are removing the warning on line 106, do this first and it will ease checking the scheme.

- fields:
- down_after_milliseconds (int)
- flags (string)
- ip (string)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does ip differ from sentinel_ip? I think we should skip it as a field.

- link_pending_commands (int)
- link_refcount (int)
- name (string)
- port (int)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is port the same as sentinel_port? If so let's skip this as well.

- total_connections_received (int)
- total_net_input_bytes (int)
- total_net_output_bytes (int)
- uptime_ns (int, seconds)
Copy link
Contributor

Choose a reason for hiding this comment

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

List units as nanoseconds.

- replica_port
- source

- fields:
Copy link
Contributor

Choose a reason for hiding this comment

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

Like with the sentinels, I think we should remove the port, ip, and runid fields.

// ------------------------------------------------------------

// Check other Replicas
replicasCmd := redis.NewSliceCmd("sentinel", "replicas", m["name"])
Copy link
Contributor

Choose a reason for hiding this comment

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

I found that in versions of Redis < 5, this command is called sentinel slaves <master-group-name>. If we make this call with the older name, the plugin will work with at least back to Redis 3.0, and it continues to work current version.

@sjwang90
Copy link
Contributor

Hi @adamflott, if you have a chance to take a look at @danielnelson's comments we are seeing if we can get this in to 1.14. Thanks!

@sjwang90
Copy link
Contributor

sjwang90 commented Mar 9, 2020

Hey @adamflott! Just a heads up we're a week out from finalizing our 1.14 release candidate if you have time to finish this plugin. We can help wrap things up as well if we have time. Just let us know, thanks!

@sjwang90 sjwang90 removed this from the 1.14.0 milestone Mar 13, 2020
@debu99
Copy link
Contributor

debu99 commented Jun 14, 2020

any progress?

@sjwang90
Copy link
Contributor

There's a last few fixes for this plugin @adamflott. If you'd like anyone to take this over just let us know.

This plugin can also be used faster as an external plugin that can be used with execd to run seamlessly with Telegraf. Telegraf users would be able to use the plugin sooner by having it as an external plugin since it wouldn't have to go through the typical review process.

@sjwang90 sjwang90 added external plugin Plugins that would be ideal external plugin and expedite being able to use plugin w/ Telegraf plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Jan 12, 2021
@adamflott
Copy link
Contributor Author

@sjwang90 I have dropped the ball on this, but would like to finish it out since my project that uses this will finally be going live. Give me a few weeks to get the code changes in.

@srebhan srebhan self-assigned this Feb 19, 2021
@srebhan
Copy link
Member

srebhan commented Apr 28, 2021

Hey @adamflott any news on this?

@srebhan srebhan added the waiting for response waiting for response from contributor label Apr 28, 2021
@adamflott
Copy link
Contributor Author

Hey @adamflott any news on this?

Due to my $work no longer taking interest in Redis, I too have lost interest.

@sjwang90
Copy link
Contributor

sjwang90 commented May 7, 2021

Thanks for letting us know @adamflott. We'll see if anyone else in the community is willing to take over your PR

@srebhan srebhan added help wanted Request for community participation, code, contribution and removed waiting for response waiting for response from contributor labels May 18, 2021
@spideyfusion
Copy link
Contributor

Continues in #10042

@sjwang90
Copy link
Contributor

sjwang90 commented Nov 2, 2021

Thanks @spideyfusion! Going to close this PR.

@sjwang90 sjwang90 closed this Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/redis external plugin Plugins that would be ideal external plugin and expedite being able to use plugin w/ Telegraf help wanted Request for community participation, code, contribution new plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants