apiVersion: operator.victoriametrics.com/v1beta1
kind: VMPodScrape
metadata:
  name: "db-{{ .InstanceID }}-schema-manager"
  namespace: "{{ .Namespace }}"
  labels:
    scrape-by: "{{ .LabelScrapeBy }}"
    db-instance-id: "{{ .InstanceID }}"
    component-level: sharedpool
spec:
  selector:
    matchLabels:
      app.kubernetes.io/component: schema-manager
  namespaceSelector:
    matchNames:
    - "{{ .Namespace }}"
  podMetricsEndpoints:
  - port: status
    scheme: https
    interval: 15s
    tlsConfig:
      insecureSkipVerify: true
    relabelConfigs:
    - action: replace
      replacement: "{{ .SharedPoolID }}"
      targetLabel: sharedpool_id
    - action: replace
      replacement: "{{ .SharedPoolID }}"
      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
      sourceLabels:
      - __meta_kubernetes_pod_label_app_kubernetes_io_component
      targetLabel: component
  - port: api
    scheme: https
    interval: 15s
    tlsConfig:
      insecureSkipVerify: true
    relabelConfigs:
    - action: replace
      replacement: "{{ .SharedPoolID }}"
      targetLabel: sharedpool_id
    - action: replace
      replacement: "{{ .SharedPoolID }}"
      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
      sourceLabels:
      - __meta_kubernetes_pod_label_app_kubernetes_io_component
      targetLabel: component
