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

Chained if conditions for relabeling not supported in vmagent CRD #730

Closed
towolf opened this issue Aug 24, 2023 · 5 comments
Closed

Chained if conditions for relabeling not supported in vmagent CRD #730

towolf opened this issue Aug 24, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@towolf
Copy link

towolf commented Aug 24, 2023

Describe the bug

In the code for IfExpression it states that two modes are supported, a single string matcher and a chained mode with an array of conditions which are combined with OR:

https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/lib/promrelabel/if_expression.go#L13-L23

However the CRD for vmagent does not support this:
image

We would like to use a chained config to avoid a gnarly regex matcher, like this:

          inlineUrlRelabelConfig:
            - if:
                # Limit metrics sent to the central obs cluster to this set (keep)
                - '{job=~"(kube-etcd|agones.+|node-exporter|apiserver)"}'
                # Also pass on the metrics from recording rules created by
                # kube-prometheus-stack and vmstack to make the multi-cluster k-p-s
                # dashboards work
                - '{__name__=~"(cluster:namespace|cluster:node_cpu|cluster_quantile:|code_resource:|instance:|instance_device:|namespace_cpu:|namespace_memory:|namespace_workload_pod:|node_namespace_pod_container).+"}'
              action: keep

This means, the single if contains two matchers in an array which should be combined with OR.

To Reproduce

Add a relabel config like this to the vmagent CR:

if:
 - 'foo{bar="baz"}'
 - '{x=~"y"}'

Version

image: docker.io/victoriametrics/vmagent:v1.93.0

Logs

Error: cannot patch "vmstack" with kind VMAgent: VMAgent.operator.victoriametrics.com "vmstack" is invalid: [spec.remoteWrite[1].inlineUrlRelabelConfig[0].if: Invalid value: "array": spec.remoteWrite[1].inlineUrlRelabelConfig[0].if in body must be of type string: "array", spec.remoteWrite[1].inlineUrlRelabelConfig[1].if: Invalid value: "array": spec.remoteWrite[1].inlineUrlRelabelConfig[1].if in body must be of type string: "array"]

Screenshots

No response

Used command-line flags

No response

Additional information

No response

@towolf towolf added the bug Something isn't working label Aug 24, 2023
@zekker6 zekker6 transferred this issue from VictoriaMetrics/VictoriaMetrics Aug 24, 2023
@zekker6
Copy link
Contributor

zekker6 commented Aug 24, 2023

@towolf Thank you for the report!
I've transferred this issue to operator repository as it is related to the operator, but not vmagent itself.

@towolf
Copy link
Author

towolf commented Aug 24, 2023

The docs seem to be here, but in the Operator this is not supported, seemingly:

The if option may contain more than one filter

@Amper
Copy link
Contributor

Amper commented Aug 30, 2023

Released at v0.37.0

@Amper Amper closed this as completed Aug 30, 2023
@towolf
Copy link
Author

towolf commented Aug 30, 2023

Hi @Amper it's really cool, that you already tackled this, thank you very much!

When working with the CRDs we noticed that the same problem holds for regex:. This can also be a string or an array.

Is this covered by your fix or should I open another issue for this?

@Amper
Copy link
Contributor

Amper commented Aug 30, 2023

@towolf, yes, you should open another issue for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants