operator icon indicating copy to clipboard operation
operator copied to clipboard

VMOperator: Filter namespaces by labels

Open aslafy-z opened this issue 2 years ago • 5 comments
trafficstars

Is your feature request related to a problem? Please describe

I'd like to adopt VictoriaMetrics from Kube-Prometheus-Stack, one of my need is to convert Prometheus-Operator objects to VictoriaMetrics ones within a fixed list of namespaces.

Describe the solution you'd like

Add a namespace selector with labels to the VM Operator to restrict objects to convert

Describe alternatives you've considered

No response

Additional information

No response

aslafy-z avatar Nov 07 '23 10:11 aslafy-z

Hello! I will convert this to operator repo since it's about operator)

one of my need is to convert Prometheus-Operator objects to VictoriaMetrics ones within a fixed list of namespaces.

For now, vm operator only support single namespace or all namespaces. Related to https://github.com/VictoriaMetrics/operator/issues/557

Haleygo avatar Nov 08 '23 06:11 Haleygo

Must be fixed at v0.42.0 release

It supports comma separated values for WATCH_NAMESPACE env variable.

f41gh7 avatar Mar 06 '24 09:03 f41gh7

I don't believe that filtering by labels make sense, since kubernetes API doesn't support that for object requests.

f41gh7 avatar Mar 06 '24 09:03 f41gh7

In multitenant clusters, I only want to scrape my clients, or a set of client namespaced objects for conversion. I don't know my client namespace exact names (only the prefixes) but I for sure know that their namespace have a specific label. How am I supposed to do this? Thank you

aslafy-z avatar Mar 06 '24 11:03 aslafy-z

In multitenant clusters, I only want to scrape my clients, or a set of client namespaced objects for conversion. I don't know my client namespace exact names (only the prefixes) but I for sure know that their namespace have a specific label. How am I supposed to do this? Thank you

I think, it's possible with namespace selectors for vmagent.

apiVersion: operator.victoriametrics.com/v1beta1
kind: VMAgent
metadata:
  name: only-tenants-match
spec:
  serviceScrapeSelector: {}
  serviceScrapeNamespaceSelector:
    matchExpressions:
      - operator: In
        key: my-namespace-common-tenant-label
        values: ["tenant-1","tenant-2","tenant-3"]

It must select scrape objects from namespaces that has a common label my-namespace-common-tenant-label and it's value in defined set of values.

It shouldn't be a problem to assign label to the namespace as part of monitoring "contract".

I'd suggest to create vmagent with predefined configuration by cluster admins.

f41gh7 avatar Mar 06 '24 11:03 f41gh7