apiVersion: operator.victoriametrics.com/v1beta1
kind: VMPodScrape
metadata:
  name: "{{ .Name }}"
  namespace: "{{ .Namespace }}"
  labels:
    scrape-by: "{{ .LabelScrapeBy }}"
    component-level: tidbgroup
spec:
  selector:
    matchLabels:
      app: cassandra-proxy
      tags.tidbcloud.com/cluster: "{{ .ClusterID }}"
  namespaceSelector:
    matchNames:
    - "{{ .Namespace }}"
  podMetricsEndpoints:
  - targetPort: 6060
    scheme: http
    interval: 15s
    relabelConfigs:
    - action: replace
      replacement: "{{ .TenantID }}"
      targetLabel: tenant_id
    - action: replace
      replacement: "{{ .ClusterID }}"
      targetLabel: cluster_id
    - action: replace
      replacement: "{{ .ClusterID }}"
      targetLabel: tidb_cluster_id
    - action: replace
      replacement: "{{ .VMAccountID }}"
      targetLabel: vm_account_id
    - action: replace
      replacement: "{{ .VMProjectID }}"
      targetLabel: vm_project_id
    - action: keep
      regex: "true"
      sourceLabels:
      - __meta_kubernetes_pod_annotation_prometheus_io_scrape
    - action: replace
      regex: (.+)
      sourceLabels:
      - __meta_kubernetes_pod_annotation_prometheus_io_path
      targetLabel: __metrics_path__
    - action: replace
      sourceLabels:
      - __meta_kubernetes_namespace
      targetLabel: namespace
    - action: replace
      sourceLabels:
      - __meta_kubernetes_pod_name
      targetLabel: pod_name
    - action: replace
      sourceLabels:
      - __meta_kubernetes_pod_name
      targetLabel: instance
    - action: replace
      replacement: cassandra-proxy
      targetLabel: component
