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 kubernetes_role argument for prometheus.operator.servicemonitors #2008

Closed
wants to merge 4 commits into from

Conversation

yoyosir
Copy link

@yoyosir yoyosir commented Oct 30, 2024

PR Description

This PR adds support for endpointslice role in prometheus.operator.servicemonitors. Before this PR, the role defaults to endpoints. So there was no way to have servicemonitor to scrape an endpointslice in alloy.

Example config in alloy after this PR.

prometheus.operator.servicemonitors "servicemonitors_endpointslice" {
  forward_to = [prometheus.relabel.servicemonitors_filter.receiver]
  selector {
    match_expression {
      key      = "kubernetes-scrape-role"
      operator = "In"
      values   = ["endpointslice"]
    }
  }
  clustering {
      enabled = true
  }

  kubernetes_role = "endpointslice"
}

prometheus.operator.servicemonitors "servicemonitors" {
  forward_to = [prometheus.relabel.servicemonitors_filter.receiver]
  selector {
    match_expression {
      key      = "kubernetes-scrape-role"
      operator = "NotIn"
      values   = ["endpointslice"]
    }
  }

  clustering {
      enabled = true
  }

}

Which issue(s) this PR fixes

Fixes #1714

Notes to the Reviewer

PR Checklist

  • CHANGELOG.md updated
  • Documentation added
  • Tests updated
  • Config converters updated

@CLAassistant
Copy link

CLAassistant commented Oct 30, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ yoyosir
❌ Zheng Yong


Zheng Yong seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@yoyosir yoyosir marked this pull request as ready for review November 1, 2024 14:26
@yoyosir yoyosir requested a review from a team as a code owner November 1, 2024 14:26
Copy link
Contributor

@thampiotr thampiotr left a comment

Choose a reason for hiding this comment

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

Thanks! I believe that your GitHub user is different to the one used to create Git commits and because of that the CLA signing is not passing. Could you try making sure you use the email associated with your GitHub account? This can be done without exposing your actual email address.

@@ -24,6 +24,8 @@ type Arguments struct {
// Namespaces to search for monitor resources. Empty implies All namespaces
Namespaces []string `alloy:"namespaces,attr,optional"`

KubernetesRole string `alloy:"kubernetes_role,attr,optional"`
Copy link
Contributor

Choose a reason for hiding this comment

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

@thampiotr thampiotr self-assigned this Nov 1, 2024
@yoyosir
Copy link
Author

yoyosir commented Nov 1, 2024

Thanks for the review @thampiotr ! Just realized my previous changelog and docs were not updated. Updated those. I'll change the other monitors that use this argument.

One question: Since my previous commit email cannot be changed, should I close this and open up a new PR instead?

@yoyosir
Copy link
Author

yoyosir commented Nov 1, 2024

Actually one more question. I noticed for probes and podmonitors it seems more proper to have the role fixed to ingress and pod respectively. I'll leave the decision to you on whether I should enable the role override for
https://github.com/grafana/alloy/blob/main/docs/sources/reference/components/prometheus/prometheus.operator.podmonitors.md
https://github.com/grafana/alloy/blob/main/docs/sources/reference/components/prometheus/prometheus.operator.probes.md

@yoyosir
Copy link
Author

yoyosir commented Nov 3, 2024

@thampiotr I created a new one #2023 seems the CLA is passing there.

@thampiotr
Copy link
Contributor

Actually one more question. I noticed for probes and podmonitors it seems more proper to have the role fixed to ingress and pod respectively. I'll leave the decision to you on whether I should enable the role override for https://github.com/grafana/alloy/blob/main/docs/sources/reference/components/prometheus/prometheus.operator.podmonitors.md https://github.com/grafana/alloy/blob/main/docs/sources/reference/components/prometheus/prometheus.operator.probes.md

Let's leave them as they are and only change servicemonitors for now.

@thampiotr
Copy link
Contributor

@thampiotr I created a new one #2023 seems the CLA is passing there.

Cool, let's move conversation there.

@thampiotr thampiotr closed this Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support endpointslices.discovery.k8s.io for prometheus.operator.servicemonitors
3 participants