diff --git a/.changelog/3526.changed.txt b/.changelog/3526.changed.txt new file mode 100644 index 0000000000..38798befcd --- /dev/null +++ b/.changelog/3526.changed.txt @@ -0,0 +1 @@ +feat(tracessampler): move tracessampler config map from values.yaml \ No newline at end of file diff --git a/deploy/helm/sumologic/README.md b/deploy/helm/sumologic/README.md index fe141fd8a4..1bc0318f7d 100644 --- a/deploy/helm/sumologic/README.md +++ b/deploy/helm/sumologic/README.md @@ -359,15 +359,12 @@ The following table lists the configurable parameters of the Sumo Logic chart an | `tracesGateway.deployment.resources` | Resources for traces-gateway statefulset. | `{"limits": {"memory": "2Gi", "cpu": "1000m"}, "requests": {"memory": "196Mi", "cpu": "50m"}}` | | `tracesGateway.deployment.startupProbe` | Startup probe configuration for the traces-gateway container. | `{"periodSeconds": 5, "timeoutSeconds": 3, "failureThreshold": 60}` | | `tracesGateway.deployment.tolerations` | Tolerations for traces-gateway statefulset. | `[]` | +| `tracesSampler.config.merge` | Configuration for traces-sampler collector, merged with defaults. | {} | +| `tracesSampler.config.override` | Configuration for log collector otelcol, replaces defaults. | {} | | `tracesSampler.deployment.replicas` | Set the number of OpenTelemetry Collector replicas. | `1` | | `tracesSampler.deployment.nodeSelector` | Node selector for otelcol deployment. [See help.sumologic.com/docs/send-data/kubernetes/best-practices for more information.](https://help.sumologic.com/docs/send-data/kubernetes/best-practices/) | `{}` | | `tracesSampler.deployment.priorityClassName` | Priority class name for OpenTelemetry Collector log pods. | `Nil` | | `tracesSampler.logLevelFilter` | Do not send traces-sampler logs if `true`. | `false` | -| `tracesSampler.config.processors.batch.send_batch_size` | Sets the preferred size of batch. | `256` | -| `tracesSampler.config.processors.batch.send_batch_max_size` | Sets the maximum allowed size of a batch. Use with caution, setting too large value might cause 413 Payload Too Large errors. | `512` | -| `tracesSampler.config.processors.memory_limiter.limit_percentage` | Sets the maximum amount of memory, in %, targeted to be allocated by the process heap. | `75` | -| `tracesSampler.config.processors.memory_limiter.spike_limit_percentage` | Sets the maximum spike expected between the measurements of memory usage, in %. | `20` | -| `tracesSampler.config` | Configuration for traces-sampler. | See [values.yaml] | | `tracesSampler.deployment.extraEnvVars` | Additional environment variables for traces-sampler pods. | `{}` | | `tracesSampler.deployment.extraVolumeMounts` | Additional volume mounts for traces-sampler pods. | `{}` | | `tracesSampler.deployment.extraVolumes` | Additional volumes for traces-sampler pods. | `{}` | @@ -482,6 +479,8 @@ The following table lists the configurable parameters of the Sumo Logic chart an | `pvcCleaner.job.podAnnotations` | Additional annotations for for the pvcCleaner container. | `{}` | | `pvcCleaner.job.schedule` | Schedule for cronJobs | `*/15 * * * *` | | `pvcCleaner.job.securityContext` | The securityContext configuration for the pvcCleaner. | `{"runAsUser": 1000}` | +| `debug.instrumentation.tracesSampler.print` | Set to `true` to print logs processed by log collector on standard output. | `false` | +| `debug.instrumentation.tracesSampler.stopLogsIngestion` | Set to `true` to prevent sending log collector logs to Sumo Logic. It prevents increasing ingestion and costs in case of huge amount of traces-sampler logs. | `false` | | `debug.logs.collector.print` | Set to `true` to print logs processed by log collector on standard output. | `false` | | `debug.logs.collector.stopLogsIngestion` | Set to `true` to prevent sending log collector logs to Sumo Logic. It prevents increasing ingestion and costs in case of huge amount of log collector logs. | `false` | | `debug.logs.metadata.forwardToSumologicMock` | Set to `true` to forward logs processed by metadata statefulset also to Sumo Logic Mock. | `false` | diff --git a/deploy/helm/sumologic/conf/instrumentation/traces.sampler.conf.yaml b/deploy/helm/sumologic/conf/instrumentation/traces.sampler.conf.yaml index 5b3ce14e79..4e46a6da1f 100644 --- a/deploy/helm/sumologic/conf/instrumentation/traces.sampler.conf.yaml +++ b/deploy/helm/sumologic/conf/instrumentation/traces.sampler.conf.yaml @@ -1 +1,76 @@ -{{- tpl (toYaml .Values.tracesSampler.config | replace ": '{{" ": {{" | replace "}}'" "}}") . | nindent 2 }} +{{ if .Values.sumologic.traces.enabled }} +exporters: +{{- if eq .Values.debug.instrumentation.tracesSampler.print true }} + debug: + verbosity: detailed +{{- end }} + ## Following generates verbose logs with span content, useful to verify what + ## metadata is being tagged. To enable, uncomment and add "logging" to exporters below. + ## There are two levels that could be used: `debug` and `info` with the former + ## being much more verbose and including (sampled) spans content + # logging: + # loglevel: debug + otlphttp: +{{- if eq .Values.sumologic.traces.sourceType "http" }} + traces_endpoint: ${SUMO_ENDPOINT_DEFAULT_TRACES_SOURCE} +{{- else }} + endpoint: ${SUMO_ENDPOINT_DEFAULT_OTLP_TRACES_SOURCE} +{{- end}} + compression: gzip +receivers: + otlp: + protocols: + grpc: + endpoint: "0.0.0.0:4317" + http: + endpoint: "0.0.0.0:4318" +processors: + ## The memory_limiter processor is used to prevent out of memory situations on the collector. + memory_limiter: + ## check_interval is the time between measurements of memory usage for the + ## purposes of avoiding going over the limits. Defaults to zero, so no + ## checks will be performed. Values below 1 second are not recommended since + ## it can result in unnecessary CPU consumption. + check_interval: 5s + + ## Maximum amount of memory, in %, targeted to be allocated by the process heap. + ## Note that typically the total memory usage of process will be about 50MiB higher + ## than this value. + limit_percentage: 75 + + ## Maximum spike expected between the measurements of memory usage, in %. + spike_limit_percentage: 20 + + ## Smart cascading filtering rules with preset limits. + ## Please see https://github.com/SumoLogic/sumologic-otel-collector/tree/v0.92.0-sumo-0/pkg/processor/cascadingfilterprocessor + ## for details. + cascading_filter: + ## Max number of traces for which decisions are kept in memory + num_traces: 200000 + + ## The batch processor accepts spans and places them into batches grouped by node and resource + batch: + ## Number of spans after which a batch will be sent regardless of time + send_batch_size: 256 + ## Never more than this many spans are being sent in a batch + send_batch_max_size: 512 + ## Time duration after which a batch will be sent regardless of size + timeout: 5s + +extensions: + health_check: {} + memory_ballast: + ## Memory Ballast size should be max 1/3 to 1/2 of memory. + size_mib: 683 + pprof: {} +service: + extensions: [health_check, memory_ballast, pprof] + pipelines: + traces: + receivers: [otlp] + processors: [memory_limiter, cascading_filter, batch] + exporters: [otlphttp] + telemetry: + logs: + level: {{ .Values.tracesSampler.logLevel }} +{{- end }} diff --git a/deploy/helm/sumologic/conf/logs/collector/otelcol/config.yaml b/deploy/helm/sumologic/conf/logs/collector/otelcol/config.yaml index 2d06556c5a..f6e6a3e004 100644 --- a/deploy/helm/sumologic/conf/logs/collector/otelcol/config.yaml +++ b/deploy/helm/sumologic/conf/logs/collector/otelcol/config.yaml @@ -70,6 +70,9 @@ receivers: {{ if eq .Values.debug.metrics.collector.stopLogsIngestion true }} {{ include "metrics.collector.files.list" . }} {{ end }} + {{ if eq .Values.debug.instrumentation.tracesSampler.stopLogsIngestion true }} + {{ include "tracesSampler.collector.files.list" . }} + {{ end }} {{ if lt (int (include "kubernetes.minor" .)) 24 }} ## sets fingerprint_size to 17kb in order to match the longest possible docker line (which by default is 16kb) diff --git a/deploy/helm/sumologic/templates/_helpers/_common.tpl b/deploy/helm/sumologic/templates/_helpers/_common.tpl index c83c374cf6..32fd6eaa58 100644 --- a/deploy/helm/sumologic/templates/_helpers/_common.tpl +++ b/deploy/helm/sumologic/templates/_helpers/_common.tpl @@ -610,3 +610,43 @@ Example usage: {{- define "sumologic.sumologic-mock.name.roles.serviceaccount" -}} {{- template "sumologic.fullname" . }} {{- end -}} + +{{- define "useDefaultConfig" }} +{{/* +This function checks if any keys other than 'merge' and 'override' exist in a given map. +It takes a map as an argument and returns true if extra keys are found, else false. + +Example usage: +{{ $useValuesYamlConfig := include "useDefaultConfig" .Values.tracesSampler.config | trim }} +*/}} +{{- $map := . -}} +{{- $extraKeysExist := false -}} +{{- range $key, $_ := $map }} + {{- if and (ne $key "merge") (ne $key "override") }} + {{- $extraKeysExist = true -}} + {{- end }} +{{- end }} +{{- if $extraKeysExist }} +true +{{- else }} +false +{{- end }} +{{- end }} + +{{- define "removeMergeAndOverrideKeys" -}} +{{/* +This function removes keys 'merge' and 'override' in a given map. +It takes a map as an argument and returns new map without 'merge' and 'override' keys. + +Example usage: +{{ $finalConfig = include "removeMergeAndOverrideKeys" .Values.tracesSampler.config }} +*/}} +{{- $originalMap := . -}} +{{- $newMap := dict -}} +{{- range $key, $value := $originalMap -}} + {{- if and (ne $key "merge") (ne $key "override") -}} + {{- $_ := set $newMap $key $value -}} + {{- end -}} +{{- end -}} +{{ toYaml $newMap }} +{{- end -}} diff --git a/deploy/helm/sumologic/templates/_helpers/_traces.tpl b/deploy/helm/sumologic/templates/_helpers/_traces.tpl index d364c0b44d..af9b277fcb 100644 --- a/deploy/helm/sumologic/templates/_helpers/_traces.tpl +++ b/deploy/helm/sumologic/templates/_helpers/_traces.tpl @@ -316,3 +316,7 @@ Example Usage: {{- template "kubernetes.defaultTolerations" . -}} {{- end -}} {{- end -}} + +{{- define "tracesSampler.collector.files.list" -}} +- /var/log/pods/{{ template "sumologic.namespace" . }}_{{ template "sumologic.metadata.name.tracessampler" . }}*/*/*.log +{{- end -}} diff --git a/deploy/helm/sumologic/templates/instrumentation/traces-sampler/configmap.yaml b/deploy/helm/sumologic/templates/instrumentation/traces-sampler/configmap.yaml index 0ab82f3bfa..13fcc760b3 100644 --- a/deploy/helm/sumologic/templates/instrumentation/traces-sampler/configmap.yaml +++ b/deploy/helm/sumologic/templates/instrumentation/traces-sampler/configmap.yaml @@ -1,5 +1,19 @@ {{ $tracesEnabled := .Values.sumologic.traces.enabled }} {{- if $tracesEnabled }} +{{ $baseConfig := (tpl (.Files.Get "conf/instrumentation/traces.sampler.conf.yaml") .) | fromYaml }} +{{ $mergeConfig := .Values.tracesSampler.config.merge }} +{{ $overrideConfig := .Values.tracesSampler.config.override }} +{{ $finalConfig := "" }} +{{ if $overrideConfig }} +{{ $finalConfig = $overrideConfig }} +{{ else }} +{{ $finalConfig = mergeOverwrite $baseConfig $mergeConfig }} +{{ end }} +{{ $valuesYamlConfig := .Values.tracesSampler.config }} +{{ $useValuesYamlConfig := include "useDefaultConfig" $valuesYamlConfig | trim }} +{{ if eq $useValuesYamlConfig "true" }} +{{ $finalConfig = include "removeMergeAndOverrideKeys" .Values.tracesSampler.config }} +{{ end }} apiVersion: v1 kind: ConfigMap metadata: @@ -9,5 +23,10 @@ metadata: app: {{ template "sumologic.labels.app.tracessampler.configmap" . }} {{- include "sumologic.labels.common" . | nindent 4 }} data: - {{- (tpl (.Files.Glob "conf/instrumentation/traces.sampler.conf.yaml").AsConfig .) | nindent 2 }} + traces.sampler.conf.yaml: | + {{- if eq $useValuesYamlConfig "true" }} + {{- $finalConfig | nindent 4 }} + {{- else }} + {{- $finalConfig | toYaml | nindent 4 }} + {{- end }} {{- end }} diff --git a/deploy/helm/sumologic/values.yaml b/deploy/helm/sumologic/values.yaml index 4539cd7372..81f04f4c8f 100644 --- a/deploy/helm/sumologic/values.yaml +++ b/deploy/helm/sumologic/values.yaml @@ -1586,71 +1586,28 @@ tracesSampler: ## To enable collecting all logs, set to false logLevelFilter: false - ## Collector configuration - config: - receivers: - otlp: - protocols: - grpc: - endpoint: "0.0.0.0:4317" - http: - endpoint: "0.0.0.0:4318" - processors: - ## The memory_limiter processor is used to prevent out of memory situations on the collector. - memory_limiter: - ## check_interval is the time between measurements of memory usage for the - ## purposes of avoiding going over the limits. Defaults to zero, so no - ## checks will be performed. Values below 1 second are not recommended since - ## it can result in unnecessary CPU consumption. - check_interval: 5s - - ## Maximum amount of memory, in %, targeted to be allocated by the process heap. - ## Note that typically the total memory usage of process will be about 50MiB higher - ## than this value. - limit_percentage: 75 - - ## Maximum spike expected between the measurements of memory usage, in %. - spike_limit_percentage: 20 - - ## Smart cascading filtering rules with preset limits. - ## Please see https://github.com/SumoLogic/sumologic-otel-collector/tree/v0.92.0-sumo-0/pkg/processor/cascadingfilterprocessor - ## for details. - cascading_filter: - ## Max number of traces for which decisions are kept in memory - num_traces: 200000 - - ## The batch processor accepts spans and places them into batches grouped by node and resource - batch: - ## Number of spans after which a batch will be sent regardless of time - send_batch_size: 256 - ## Never more than this many spans are being sent in a batch - send_batch_max_size: 512 - ## Time duration after which a batch will be sent regardless of size - timeout: 5s + ## Log Level + logLevel: info - extensions: - health_check: {} - memory_ballast: - ## Memory Ballast size should be max 1/3 to 1/2 of memory. - size_mib: 683 - pprof: {} - exporters: - ## Following generates verbose logs with span content, useful to verify what - ## metadata is being tagged. To enable, uncomment and add "logging" to exporters below. - ## There are two levels that could be used: `debug` and `info` with the former - ## being much more verbose and including (sampled) spans content - # logging: - # loglevel: debug - otlphttp: - traces_endpoint: ${SUMO_ENDPOINT_DEFAULT_OTLP_TRACES_SOURCE}/v1/traces - compression: gzip - service: - extensions: [health_check, memory_ballast, pprof] - pipelines: - traces: - receivers: [otlp] - processors: [memory_limiter, cascading_filter, batch] - exporters: [otlphttp] + ## Customize the Opentelemetry Collector configuration beyond the exposed options + config: + ## Directly alter the OT configuration. The value of this key should be a dictionary, that will + ## be directly merged with the generated configuration, overriding existing values. + ## For example: + # override: + # processors: + # batch: + # send_batch_size: 512 + ## will change the batch size of the pipeline. + ## + ## WARNING: This field is not subject to backwards-compatibility guarantees offered by the rest + ## of this chart. It involves implementation details that may change even in minor versions. + ## Use with caution, and consider opening an issue, so your customization can be added in a safer way. + merge: {} + ## Completely override existing config and replace it with the contents of this value. + ## The value of this key should be a dictionary, that will replace the normal configuration. + ## This is an advanced feature, use with caution, and review the generated configuration first. + override: {} metadata: ## Configure image for Opentelemetry Collector (for logs and metrics) @@ -2598,3 +2555,8 @@ debug: collector: print: false stopLogsIngestion: false + + instrumentation: + tracesSampler: + print: false + stopLogsIngestion: false diff --git a/tests/helm/testdata/goldenfile/logs_otc/debug.input.yaml b/tests/helm/testdata/goldenfile/logs_otc/debug.input.yaml index fcaadaf50c..14680fa2dc 100644 --- a/tests/helm/testdata/goldenfile/logs_otc/debug.input.yaml +++ b/tests/helm/testdata/goldenfile/logs_otc/debug.input.yaml @@ -15,3 +15,6 @@ debug: stopLogsIngestion: true metadata: stopLogsIngestion: true + instrumentation: + tracesSampler: + stopLogsIngestion: true diff --git a/tests/helm/testdata/goldenfile/logs_otc/debug.output.yaml b/tests/helm/testdata/goldenfile/logs_otc/debug.output.yaml index e9c3567c18..f85e43bd76 100644 --- a/tests/helm/testdata/goldenfile/logs_otc/debug.output.yaml +++ b/tests/helm/testdata/goldenfile/logs_otc/debug.output.yaml @@ -63,6 +63,7 @@ data: - /var/log/pods/sumologic_RELEASE-NAME-sumologic-otelcol-logs-collector*/*/*.log - /var/log/pods/sumologic_RELEASE-NAME-sumologic-otelcol-metrics*/*/*.log - /var/log/pods/sumologic_RELEASE-NAME-sumologic-metrics*/*/*.log + - /var/log/pods/sumologic_RELEASE-NAME-sumologic-traces-sampler*/*/*.log include: - /var/log/pods/*/*/*.log include_file_name: false diff --git a/tests/helm/testdata/goldenfile/traces-sampler/simple.output.yaml b/tests/helm/testdata/goldenfile/traces-sampler/simple.output.yaml index ffca5a12c3..8d56cb4b03 100644 --- a/tests/helm/testdata/goldenfile/traces-sampler/simple.output.yaml +++ b/tests/helm/testdata/goldenfile/traces-sampler/simple.output.yaml @@ -15,7 +15,7 @@ data: exporters: otlphttp: compression: gzip - traces_endpoint: ${SUMO_ENDPOINT_DEFAULT_OTLP_TRACES_SOURCE}/v1/traces + endpoint: ${SUMO_ENDPOINT_DEFAULT_OTLP_TRACES_SOURCE} extensions: health_check: {} memory_ballast: @@ -54,3 +54,6 @@ data: - batch receivers: - otlp + telemetry: + logs: + level: info diff --git a/tests/integration/values/values_helm_http_source.yaml b/tests/integration/values/values_helm_http_source.yaml index 030b28cd9b..18c7c260be 100644 --- a/tests/integration/values/values_helm_http_source.yaml +++ b/tests/integration/values/values_helm_http_source.yaml @@ -8,8 +8,11 @@ sumologic: traces: sourceType: http +## Adding /v1/traces just for testing purposes. +## Sumo HTTP Traces endpoint doesn't require "/v1/traces" path. tracesSampler: config: - exporters: - otlphttp: - traces_endpoint: ${SUMO_ENDPOINT_DEFAULT_TRACES_SOURCE}/v1/traces + merge: + exporters: + otlphttp: + traces_endpoint: ${SUMO_ENDPOINT_DEFAULT_TRACES_SOURCE}/v1/traces