diff --git a/Makefile b/Makefile index c03bb89d8..e6f61dfd3 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,7 @@ markdown-links-lint: .PHONY: check-configuration-keys check-configuration-keys: - python -m unittest ./ci/check_configuration_keys_test.py + python3.11 -m unittest ./ci/check_configuration_keys_test.py ./ci/check_configuration_keys.py --values deploy/helm/sumologic/values.yaml --readme deploy/helm/sumologic/README.md .PHONY: check-dependencies diff --git a/deploy/helm/sumologic/README.md b/deploy/helm/sumologic/README.md index 7939fac4b..0f95e23db 100644 --- a/deploy/helm/sumologic/README.md +++ b/deploy/helm/sumologic/README.md @@ -148,7 +148,7 @@ The following table lists the configurable parameters of the Sumo Logic chart an | `sumologic.metrics.collector.otelcol.config.override` | Configuration for otelcol metrics collector, replaces defaults. See also https://github.com/SumoLogic/sumologic-otel-collector/blob/main/docs/configuration.md. | {} | | `sumologic.metrics.collector.otelcol.targetAllocator.resources` | Resource requests and limits for Metrics Collector Target Allocator. | {} | | `sumologic.metrics.dropHistogramBuckets` | Drop buckets from histogram and summary metrics, leaving only the sum and count components. | `true` | -| `sumologic.metrics.allowHistogramRegex` | Allowlist for Histogram metrics, including the buckets | `""` | +| `sumologic.metrics.allowHistogramRegex` | Allowlist for Histogram metrics, including the buckets | `"^$"` | | `sumologic.metrics.sourceType` | The type of the Sumo Logic source being used for metrics ingestion. Can be `http` or `otlp`. | `otlp` | | `sumologic.traces.enabled` | Set the enabled flag to true to enable tracing ingestion. _Tracing must be enabled for the account first. Please contact your Sumo representative for activation details_ | `true` | | `sumologic.traces.spans_per_request` | Maximum number of spans sent in single batch | `100` | diff --git a/deploy/helm/sumologic/values.yaml b/deploy/helm/sumologic/values.yaml index 0210015ce..5072c4f08 100644 --- a/deploy/helm/sumologic/values.yaml +++ b/deploy/helm/sumologic/values.yaml @@ -599,7 +599,7 @@ sumologic: ## - kubelet_runtime_operations_duration_seconds dropHistogramBuckets: true - # A regular expression to allow selected histogram metrics, including the buckets. + ## A regular expression to allow selected histogram metrics, including the buckets. allowHistogramRegex: "^$" ## A regular expression for namespaces. diff --git a/tests/helm/testdata/goldenfile/metadata_metrics_otc/allow_histograms.input.yaml b/tests/helm/testdata/goldenfile/metadata_metrics_otc/allow_histograms.input.yaml new file mode 100644 index 000000000..6d3942ee3 --- /dev/null +++ b/tests/helm/testdata/goldenfile/metadata_metrics_otc/allow_histograms.input.yaml @@ -0,0 +1,3 @@ +sumologic: + metrics: + allowHistogramRegex: "^(apiserver_request_duration_seconds)$" diff --git a/tests/helm/testdata/goldenfile/metadata_metrics_otc/allow_histograms.output.yaml b/tests/helm/testdata/goldenfile/metadata_metrics_otc/allow_histograms.output.yaml new file mode 100644 index 000000000..b68a1ea95 --- /dev/null +++ b/tests/helm/testdata/goldenfile/metadata_metrics_otc/allow_histograms.output.yaml @@ -0,0 +1,204 @@ +--- +# Source: sumologic/templates/metrics/otelcol/configmap.yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: release-name-sumologic-otelcol-metrics + namespace: default + labels: + app: release-name-sumologic-otelcol-metrics + chart: "sumologic-4.9.0" + release: "release-name" + heritage: "Helm" +data: + config.yaml: | + exporters: + sumologic/default: + client: k8s_4.9.0 + decompose_otlp_histograms: true + endpoint: ${SUMO_ENDPOINT_DEFAULT_OTLP_METRICS_SOURCE} + max_request_body_size: 16777216 + metric_format: otlp + sending_queue: + enabled: true + num_consumers: 10 + queue_size: 10000 + storage: file_storage + timeout: 30s + extensions: + file_storage: + compaction: + directory: /tmp + on_rebound: true + directory: /var/lib/storage/otc + timeout: 10s + health_check: {} + pprof: {} + processors: + batch: + send_batch_max_size: 2048 + send_batch_size: 1024 + timeout: 1s + filter/drop_unnecessary_metrics: + error_mode: ignore + metrics: + metric: + - resource.attributes["job"] != "pod-annotations" and IsMatch(name, "scrape_.*") + - (not IsMatch(name, "^(apiserver_request_duration_seconds)$")) and (type == + METRIC_DATA_TYPE_HISTOGRAM or type == METRIC_DATA_TYPE_EXPONENTIAL_HISTOGRAM + or type == METRIC_DATA_TYPE_SUMMARY or IsMatch(name, ".*_bucket")) + groupbyattrs: + keys: + - container + - namespace + - pod + - service + groupbyattrs/group_by_name: + keys: + - __name__ + - job + k8s_tagger: + extract: + delimiter: _ + labels: + - key: '*' + tag_name: pod_labels_%s + metadata: + - daemonSetName + - deploymentName + - nodeName + - replicaSetName + - serviceName + - statefulSetName + owner_lookup_enabled: true + passthrough: false + pod_association: + - from: build_hostname + memory_limiter: + check_interval: 5s + limit_percentage: 90 + spike_limit_percentage: 20 + metricstransform: + transforms: + action: update + include: ^prometheus_remote_write_(.*)$$ + match_type: regexp + new_name: $$1 + resource: + attributes: + - action: upsert + from_attribute: namespace + key: k8s.namespace.name + - action: delete + key: namespace + - action: upsert + from_attribute: pod + key: k8s.pod.name + - action: delete + key: pod + - action: upsert + from_attribute: container + key: k8s.container.name + - action: delete + key: container + - action: upsert + from_attribute: node + key: k8s.node.name + - action: delete + key: node + - action: upsert + from_attribute: service + key: prometheus_service + - action: delete + key: service + - action: upsert + from_attribute: service.name + key: job + - action: delete + key: service.name + - action: upsert + key: _origin + value: kubernetes + - action: upsert + key: cluster + value: kubernetes + resource/delete_source_metadata: + attributes: + - action: delete + key: _sourceCategory + - action: delete + key: _sourceHost + - action: delete + key: _sourceName + resource/remove_k8s_pod_pod_name: + attributes: + - action: delete + key: k8s.pod.pod_name + source: + collector: kubernetes + exclude: + k8s.namespace.name: "" + sumologic: + add_cloud_namespace: false + transform/remove_name: + error_mode: ignore + metric_statements: + - context: resource + statements: + - delete_key(attributes, "__name__") + transform/set_name: + error_mode: ignore + metric_statements: + - context: datapoint + statements: + - set(attributes["__name__"], metric.name) where IsMatch(metric.name, "^cloudprovider_.*") + receivers: + otlp: + protocols: + http: + endpoint: 0.0.0.0:4318 + telegraf: + agent_config: | + [agent] + interval = "30s" + flush_interval = "30s" + omit_hostname = true + [[inputs.http_listener_v2]] + # wait longer than prometheus + read_timeout = "30s" + write_timeout = "30s" + service_address = ":9888" + data_format = "prometheusremotewrite" + paths = [ + "/prometheus.metrics" + ] + service: + extensions: + - health_check + - file_storage + - pprof + pipelines: + metrics: + exporters: + - sumologic/default + processors: + - memory_limiter + - metricstransform + - groupbyattrs + - resource + - k8s_tagger + - source + - sumologic + - resource/remove_k8s_pod_pod_name + - resource/delete_source_metadata + - transform/set_name + - groupbyattrs/group_by_name + - transform/remove_name + - filter/drop_unnecessary_metrics + - batch + receivers: + - telegraf + - otlp + telemetry: + logs: + level: info diff --git a/tests/integration/helm_ot_histograms_test.go b/tests/integration/helm_ot_histograms_test.go new file mode 100644 index 000000000..8d2703a83 --- /dev/null +++ b/tests/integration/helm_ot_histograms_test.go @@ -0,0 +1,47 @@ +//go:build allversions +// +build allversions + +package integration + +import ( + "testing" + + "github.com/SumoLogic/sumologic-kubernetes-collection/tests/integration/internal" + "github.com/SumoLogic/sumologic-kubernetes-collection/tests/integration/internal/stepfuncs" +) + +func Test_Helm_OT_Histograms(t *testing.T) { + + expectedMetrics := internal.DefaultExpectedMetrics + histogramMetrics := internal.KubeApiHistogramMetrics + // we have tracing enabled, so check tracing-specific metrics + expectedMetrics = append(expectedMetrics, internal.TracingOtelcolMetrics...) + // we expect the _bucket metrics for the histogram + expectedMetrics = append(expectedMetrics, histogramMetrics...) + + installChecks := []featureCheck{ + CheckSumologicSecret(15), + CheckOtelcolMetadataLogsInstall, + CheckOtelcolMetadataMetricsInstall, + CheckOtelcolEventsInstall, + CheckOtelcolMetricsCollectorInstall, + CheckOtelcolLogsCollectorInstall, + CheckTracesInstall, + } + + featInstall := GetInstallFeature(installChecks) + + featMetrics := GetMetricsFeature(expectedMetrics, Otelcol) + + featTelegrafMetrics := GetTelegrafMetricsFeature(internal.DefaultExpectedNginxAnnotatedMetrics, Otelcol, true) + + featLogs := GetAllLogsFeature(stepfuncs.WaitUntilExpectedExactLogsPresent, true) + + featMultilineLogs := GetMultipleMultilineLogsFeature() + + featEvents := GetEventsFeature() + + featTraces := GetTracesFeature() + + testenv.Test(t, featInstall, featMetrics, featTelegrafMetrics, featLogs, featMultilineLogs, featEvents, featTraces) +} diff --git a/tests/integration/internal/constants.go b/tests/integration/internal/constants.go index 91bbb0ec5..55f2f2960 100644 --- a/tests/integration/internal/constants.go +++ b/tests/integration/internal/constants.go @@ -140,6 +140,9 @@ var ( "apiserver_request_duration_seconds_count", // not used by any App "apiserver_request_duration_seconds_sum", // not used by any App } + KubeApiHistogramMetrics = []string{ + "apiserver_request_duration_seconds_bucket", + } KubeEtcdMetrics = []string{ // used by Kubernetes - Control Plane "etcd_mvcc_db_total_size_in_bytes", // not used by any App "etcd_debugging_store_expires_total", diff --git a/tests/integration/values/values_helm_ot_histograms.yaml b/tests/integration/values/values_helm_ot_histograms.yaml new file mode 100644 index 000000000..6d3942ee3 --- /dev/null +++ b/tests/integration/values/values_helm_ot_histograms.yaml @@ -0,0 +1,3 @@ +sumologic: + metrics: + allowHistogramRegex: "^(apiserver_request_duration_seconds)$"