role: Stateless-Aggregator
image:
  repository: "{{ .ImageRepo }}"
  tag: "{{ .ImageTag }}"
resources: {{ .Resources }}
containerPorts:
  - name: prom-exporter
    containerPort: 9599
    protocol: TCP
  # - name: api
  #   containerPort: 8686
  #   protocol: TCP
# readinessProbe:
#   httpGet:
#     path: /health
#     port: api
# livenessProbe:
#   httpGet:
#     path: /health
#     port: api
#   initialDelaySeconds: 30
#   periodSeconds: 30
#   failureThreshold: 10
#   timeoutSeconds: 10
dnsPolicy: ClusterFirst
podPriorityClassName: "{{ .PriorityClassName }}"
extraVolumes:
- name: cluster-tls
  secret:
    secretName: db-cluster-client-secret
extraVolumeMounts:
- name: cluster-tls
  mountPath: /var/lib/cluster-assets-tls
  readOnly: true
podLabels:
  app: tidb-vector
affinity:
  podAntiAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
      - labelSelector:
          matchExpressions:
            - key: app
              operator: In
              values:
                - tidb-vector
        topologyKey: kubernetes.io/hostname
customConfig:
  data_dir: /vector-data-dir
  api:
    enabled: false
  sources:
    self_metrics:
      type: internal_metrics
    topsql:
      type: topsql
      pd_address: db-pd:2379
      tls:
        ca_path: "/var/lib/cluster-assets-tls/ca.crt"
        crt_path: "/var/lib/cluster-assets-tls/tls.crt"
        key_path: "/var/lib/cluster-assets-tls/tls.key"
      top_n: 10
    conprof:
      type: conprof
      pd_address: db-pd:2379
      tls:
        ca_path: "/var/lib/cluster-assets-tls/ca.crt"
        crt_path: "/var/lib/cluster-assets-tls/tls.crt"
        key_path: "/var/lib/cluster-assets-tls/tls.key"
      enable_tikv_heap_profile: true
    keyviz:
      type: keyviz
      pd_address: db-pd:2379
      tls:
        ca_path: "/var/lib/cluster-assets-tls/ca.crt"
        crt_path: "/var/lib/cluster-assets-tls/tls.crt"
        key_path: "/var/lib/cluster-assets-tls/tls.key"
  transforms:
    topsql_add_meta:
      type: remap
      inputs: ["topsql"]
      source: |
        .labels.provider = "{{ .Vendor }}"
        .labels.region = "{{ .Region }}"
        .labels.k8s_cluster_name = "{{ .ClusterName }}"
        .labels.k8s_namespace = "tidb{{ .ClusterID }}"
        .labels.project_id = "{{ .ProjectID }}"
        .labels.tenant_id = "{{ .TenantID }}"
        .labels.cluster_id = "{{ .ClusterID }}"
    conprof_add_meta:
      type: remap
      inputs: ["conprof"]
      source: |
        .key_prefix = join!(["0", "{{ .TenantID }}", "{{ .ProjectID }}", "{{ .ClusterID }}", "profiles", .filename], separator: "/")
    keyviz_add_meta:
      type: remap
      inputs: ["keyviz"]
      source: |
        .key_prefix = join!(["0", "{{ .TenantID }}", "{{ .ProjectID }}", "{{ .ClusterID }}", "regions", .filename], separator: "/")
  sinks:
    self_metrics_sink:
      type: prometheus_exporter
      inputs: ["self_metrics"]
      address: "0.0.0.0:9599"
    topsql_vm:
      type: vm_import
      inputs: ["topsql_add_meta"]
      endpoint: "{{ .VMImportURL }}"
      batch:
        max_events: 1000
        max_bytes: 1048576 # 1MiB
        timeout_secs: 1
      buffer:
        type: disk
        max_size: 536870912 # 512MiB
        when_full: drop_newest
    conprof_s3:
      type: aws_s3
      inputs: ["conprof_add_meta"]
      encoding:
        codec: raw_message
      region: "{{ .Region }}"
      bucket: "{{ .Bucket }}"
      key_prefix: {{ "'{{ `{{ key_prefix }}` }}'" }}
      filename_time_format: ""
      filename_append_uuid: false
      batch:
        max_bytes: 1 # DO NOT BATCH
        max_events: 1
        timeout_secs: 1
      auth:
        assume_role: "{{ .RoleARN }}"
    keyviz_s3:
      type: aws_s3
      inputs: ["keyviz_add_meta"]
      encoding:
        codec: raw_message
      region: "{{ .Region }}"
      bucket: "{{ .Bucket }}"
      key_prefix: {{ "'{{ `{{ key_prefix }}` }}'" }}
      filename_time_format: ""
      filename_append_uuid: false
      batch:
        max_bytes: 1 # DO NOT BATCH
        max_events: 1
        timeout_secs: 1
      auth:
        assume_role: "{{ .RoleARN }}"
