# otel-pipeline-chart/charts/vector/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "vector.fullname" . }}-config
  labels:
    {{- include "vector.labels" . | nindent 4 }}
data:
  vector.yaml: |
    data_dir: /var/lib/vector
    api:
      enabled: true
      address: 0.0.0.0:8686
      playground: false
    sources:
      metrics_in:
        type: "opentelemetry"
        grpc:
          address: 0.0.0.0:4317
        http:
          address: 0.0.0.0:4318
    {{- if eq .Values.downstream_type "datadog" }}
    transforms:
      datadog_transformation:
        type: "remap"
        drop_on_abort: true
        reroute_dropped: true
        inputs: ["metrics_in.metrics"]
        source: |
          .tags.host = "tidbcloud.com"
          if exists(.tags."resource.instance_id") {
            .tags.instance_id = .tags."resource.instance_id"
          } else if exists(.tags."resource.cluster_id") {
            .tags.cluster_id = .tags."resource.cluster_id"
          }
    {{- end }}
    {{- if eq .Values.downstream_type "newrelic" }}
    transforms:
      newrelic_transformation:
        type: "remap"
        drop_on_abort: true
        reroute_dropped: true
        inputs: ["metrics_in.metrics"]
        source: |
          if exists(.tags."resource.instance_id") {
            .tags.instance_id = .tags."resource.instance_id"
          } else if exists(.tags."resource.cluster_id") {
            .tags.cluster_id = .tags."resource.cluster_id"
          }
          if .name == "tidb_cloud.node_cpu_seconds_total" { abort }
    {{- end }}
    sinks:
      sink:{{ toYaml .Values.sink | nindent 8 }}
