# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#
{{- if .Values.opentelemetry.enabled }}

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: otel-collector-config
data:
  config.yaml: |
    receivers:
      prometheus:
        config:
          scrape_configs:
            {{- include "opentelemetry-config-apisix" . | indent 12 }}
            {{- include "opentelemetry-config-istiod-monitor" . | indent 12 }}
            {{- include "opentelemetry-config-kubernetes-monitor" . | indent 12 }}
            {{- include "opentelemetry-config-mysql-monitor" . | indent 12 }}
            {{- include "opentelemetry-config-postgresql-monitor" . | indent 12 }}
            {{- include "opentelemetry-config-so11y" . | indent 12 }}
            {{- include "opentelemetry-config-vm" . | indent 12 }}
            {{- include "opentelemetry-config-elasticsearch-monitor" . | indent 12 }}
            {{- include "opentelemetry-config-rabbitmq-monitor" . | indent 12 }}
            {{- include "opentelemetry-config-mongodb-monitor" . | indent 12 }}

    exporters:
      otlp:
        endpoint: "{{ include "skywalking.oap.address.grpc" . }}"
        tls:
          insecure: true
      logging:
        verbosity: detailed

    extensions:
      # The health_check extension is mandatory for this chart.
      # Without the health_check extension the collector will fail the readiness and liveliness probes.
      # The health_check extension can be modified, but should never be removed.
      health_check: {}

    service:
      pipelines:
        metrics:
          receivers: [ prometheus ]
          exporters: [ otlp,logging ]
      extensions:
        - health_check

{{- end }}
