-
Notifications
You must be signed in to change notification settings - Fork 153
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
Possible bug in ServiceMonitor → VMServiceScrape conversion (regex field incorrectly interpreted as array) #1219
Comments
Update: |
Hello, did you try to update Operator defines relabelConfigs:
description: RelabelConfigs to apply to samples during service discovery.
items:
description: |-
RelabelConfig allows dynamic rewriting of the label set
More info: https://docs.victoriametrics.com/#relabeling
properties:
action:
description: Action to perform based on regex matching. Default
is 'replace'
type: string
if:
description: 'If represents metricsQL match expression (or list
of expressions): ''{__name__=~"foo_.*"}'''
x-kubernetes-preserve-unknown-fields: true |
Previously, StringOrArray object was always marshalled as Array (slice). It could cause issue with outdated versions of Operator CRDs at prometheus converter. If `RelabelingConfigs` definition doesn't have `Preserve-Unknown-Fields` property at CRD defintion, object was marshalled as array it produced `Invalid value` error. This commit adds fast path for single element array and encodes it as a string. Related issue: #1219 Signed-off-by: f41gh7 <[email protected]>
Upcoming release of operator will contain a fix for this case. But currently, it's possible to update CRDs and resolve issue. |
Hello, I did not update any CRDs when switching between the old and new versions of the VictoriaMetrics Operator. On the older version, the exact same ServiceMonitor spec works correctly, but on the new version I’m getting an error about regex being interpreted as an array. |
After v0.43.0 release definition of Related issue: #740 |
Issue was fixed at v0.52.0 release |
We are experiencing an issue with the VictoriaMetrics Operator converting a Prometheus Operator ServiceMonitor resource into a VMServiceScrape. Our environment details:
• Kubernetes version: 1.29
• VictoriaMetrics Operator version: :v0.51.3
• Installation method: Helm
Description of the problem
We have a ServiceMonitor resource that includes metricRelabelings and relabelings with regex and replacement fields. When the VictoriaMetrics Operator attempts to convert this ServiceMonitor into a VMServiceScrape, we receive the following error in the operator logs:
{"level":"error","ts":"2025-01-14T19:43:42Z","logger":"controller.PrometheusConverter","msg":"cannot update VMServiceScrape","vmservicescrape":"karpenter","namespace":"kube-system","error":"VMServiceScrape.operator.victoriametrics.com \"karpenter\" is invalid: [spec.endpoints[0].relabelConfigs[0].regex: Invalid value: \"array\": spec.endpoints[0].relabelConfigs[0].regex in body must be of type string: \"array\", spec.endpoints[0].metricRelabelConfigs[0].regex: Invalid value: \"array\": spec.endpoints[0].metricRelabelConfigs[0].regex in body must be of type string: \"array\"]"}
It appears that the operator interprets the regex field as an array, even though in our YAML we have tried putting it as a string
Steps to reproduce
1. Install Prometheus Operator and VictoriaMetrics Operator in the same cluster.
2. Deploy the following ServiceMonitor (simplified example):
Questions / Requests
The text was updated successfully, but these errors were encountered: