{{- if and (eq .Values.controller "traefik") .Values.traefik.logs.metrics }} apiVersion: v1 kind: ConfigMap metadata: name: traefik-vector data: vector.yaml: | api: enabled: true address: "0.0.0.0:8686" {{- if .Values.traefik.logs.geoip.enabled }} enrichment_tables: geoip: type: "geoip" path: "/usr/share/GeoIP/geoip-db.mmdb" locale: "en" {{- end }} sources: otlp: type: opentelemetry grpc: address: 127.0.0.1:4317 http: address: 127.0.0.1:4318 transforms: {{- with .Values.traefik.logs.additionalTransforms }} {{- toYaml . | nindent 6 }} {{- end }} {{ $input := "otlp.logs" }} {{- if .Values.traefik.logs.geoip.enabled }} geolookup: inputs: - "otlp.logs" type: "remap" source: | if ip_cidr_contains!([ "10.0.0.0/8", "100.64.0.0/10", "172.16.0.0/12", "192.168.0.0/16", "fc00::/7", ], .attributes.ClientHost) { .geoip = { "latitude": 0.0, "longitude": 0.0, "continent_code": "internal", "country_code": "internal", "country_name": "internal" } } else { .geoip, .err = get_enrichment_table_record("geoip", {"ip": .attributes.ClientHost}, [ "latitude", "longitude", "continent_code", "country_code", "country_name" ]) if .err != null { log(.err, level: "error") } if !exists(.geoip.continent_code) { .geoip = { "latitude": 0.0, "longitude": 0.0, "continent_code": "unknown", "country_code": "unknown", "country_name": "unknown" } } } del(.err) {{ $input = "geolookup"}} {{- end }} metrics: inputs: - {{ $input }} type: log_to_metric metrics: - namespace: "traefik_logs" name: "access" field: "attributes.RequestHost" type: counter tags: {{` host: "{{ attributes.RequestHost }}" entryPoint: "{{ attributes.entryPointName }}" `}} {{- if .Values.traefik.logs.geoip.enabled }} {{` latitude: "{{ geoip.latitude }}" longitude: "{{ geoip.longitude }}" continent_code: "{{ geoip.continent_code }}" country_code: "{{ geoip.country_code }}" country_name: "{{ geoip.country_name }}" `}} {{- end }} {{- with .Values.traefik.logs.additionalMetrics }} {{- toYaml . | nindent 10 }} {{- end }} sinks: {{- if .Values.logs.access }} console: inputs: - {{ $input }} type: console encoding: codec: logfmt {{- end }} {{- with .Values.traefik.logs.additionalSinks }} {{- toYaml . | nindent 6 }} {{- end }} prometheus: inputs: - metrics type: prometheus_exporter address: "[::]:9116" {{- end }}