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

Adding custom CRD for Prometheus Adapter rules #662

Open
creativie opened this issue May 24, 2024 · 2 comments
Open

Adding custom CRD for Prometheus Adapter rules #662

creativie opened this issue May 24, 2024 · 2 comments
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@creativie
Copy link

Hi

It would be very convenient to use a custom CRD to fill the configuration with rules.

For example, two "PrometheusAdapterRule" CRDs

apiVersion: monitoring.coreos.com/v1alpha1
kind: PrometheusAdapterRule
metadata:
  name: example-1
spec:
  rules:
  - seriesQuery: '{__name__=~"^container_.*",container!="POD",namespace!="",pod!=""}'
    resources:
      overrides:
        namespace: {resource: "namespace"}
        pod: {resource: "pod"}
    name:
      matches: "^container_(.*)_seconds_total$"
    metricsQuery: "sum(rate(<<.Series>>{<<.LabelMatchers>>,container!="POD"}[2m])) by (<<.GroupBy>>)"

and

apiVersion: monitoring.coreos.com/v1alpha1
kind: PrometheusAdapterRule
metadata:
  name: example-2
spec:
  rules:
  - seriesQuery: 'cheddar{sharp="true"}'
    name: {as: "cheesy_goodness"}
    resources:
      overrides:
        brand: {group: "cheese.io", resource: "brand"}
    metricsQuery: 'count(cheddar{sharp="true"})'

generates configuration file for Prometheus Adapter like this

rules:
  # example-1
  - seriesQuery: '{__name__=~"^container_.*",container!="POD",namespace!="",pod!=""}'
    resources:
      overrides:
        namespace: {resource: "namespace"}
        pod: {resource: "pod"}
    name:
      matches: "^container_(.*)_seconds_total$"
    metricsQuery: "sum(rate(<<.Series>>{<<.LabelMatchers>>,container!="POD"}[2m])) by (<<.GroupBy>>)"
  # example-2
  - seriesQuery: 'cheddar{sharp="true"}'
    name: {as: "cheesy_goodness"}
    resources:
      overrides:
        brand: {group: "cheese.io", resource: "brand"}
    metricsQuery: 'count(cheddar{sharp="true"})'
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label May 24, 2024
@dgrisonnet
Copy link
Member

/assign
/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 8, 2024
@dgrisonnet dgrisonnet added kind/feature Categorizes issue or PR as related to a new feature. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. and removed triage/accepted Indicates an issue or PR is ready to be actively worked on. labels Aug 8, 2024
@logicalhan
Copy link

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests

4 participants