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

support sharding for probe #5735

Merged

Conversation

steven05jiang
Copy link
Contributor

@steven05jiang steven05jiang commented Jul 11, 2023

Description

fix #5176.
By adding a sharding relabeling rule, prometheus operator will shard targets in the probe across the prometheus cluster.

Type of change

What type of changes does your code introduce to the Prometheus operator? Put an x in the box that apply.

  • CHANGE (fix or feature that would cause existing functionality to not work as expected)
  • FEATURE (non-breaking change which adds functionality)
  • BUGFIX (non-breaking change which fixes an issue)
  • ENHANCEMENT (non-breaking change which improves existing functionality)
  • NONE (if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)

Changelog entry

Please put a one-line changelog entry below. This will be copied to the changelog file during the release process.

support sharding for probe.

Copy link

@soasme soasme left a comment

Choose a reason for hiding this comment

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

The fix looks good to me.

Copy link
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

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

Hello 👋 , sorry for taking this long to review... this one is a bit out of my comfort zone 😅

@@ -957,6 +957,7 @@ func (cg *ConfigGenerator) generateProbeConfig(
// Add configured relabelings.
xc := labeler.GetRelabelingConfigs(m.TypeMeta, m.ObjectMeta, m.Spec.Targets.StaticConfig.RelabelConfigs)
relabelings = append(relabelings, generateRelabelConfig(xc)...)
relabelings = generateAddressShardingRelabelingRulesForProbes(relabelings, shards)
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to configure sharing on every occasion? Or only when sharding is enabled in Prometheus?

Copy link
Contributor

Choose a reason for hiding this comment

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

For simplicity, we add the sharding relabel config in all cases (e.g. whether the number of shards is greater than 1 or not).
Can we move this line and the next one outside of the switch case since it applies to all cases (static an ingress targets)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for the suggestion. this is the change e4ded8d

@@ -909,6 +909,7 @@ func (cg *ConfigGenerator) generateProbeConfig(
},
}...)
}
relabelings = generateAddressShardingRelabelingRulesForProbes(relabelings, shards)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd keep it as the last relabeling config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

since the relabeling config is appended separately for ingress (here) and static config (here), I may need to move the appending call out of the switch block if we want to consolidate the sharding config. would you like me to do it?

Copy link
Contributor

Choose a reason for hiding this comment

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

@steven05jiang yes I think that it makes sense to do so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

please review the change a634807. Thanks.

@pull-request-size pull-request-size bot added size/M and removed size/L labels Aug 7, 2023
Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

one small nit otherwise lgtm!


if m.Spec.Targets.StaticConfig != nil || m.Spec.Targets.Ingress != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think that the if statement is required

Suggested change
if m.Spec.Targets.StaticConfig != nil || m.Spec.Targets.Ingress != nil {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just wanted to confirm before removing it - after removing the condition, it will add relabeling configs (job name and sharding) to empty_probe, prober_spec, and module_config in this test. while I'm not familiar with all use cases of probe, would it raise any compatibility issue in this case? Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a good remark. The operator already takes care of filtering out probes without static/ingress targets here. But even if the check doesn't work, it shouldn't be a problem to include the relabeling configs.

Copy link
Contributor

Choose a reason for hiding this comment

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

tl;dr: my recommendation should be ok and updating the tests is fine ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. This is the update ffb2a35

@pull-request-size pull-request-size bot added size/L and removed size/M labels Aug 8, 2023
Copy link
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

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

good job @steven05jiang and @simonpasquier!

sorry for not being very useful here 😅

Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

Thanks!

@simonpasquier simonpasquier merged commit 2f756fa into prometheus-operator:main Aug 9, 2023
16 checks passed
@steven05jiang
Copy link
Contributor Author

Thanks all for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support _param_target based sharding for Probes
4 participants