Skip to content

Commit

Permalink
Adding template and integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rnishtala-sumo committed Aug 9, 2024
1 parent b80e846 commit b249a08
Show file tree
Hide file tree
Showing 4 changed files with 254 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sumologic:
metrics:
allowHistogramRegex: "^(apiserver_request_duration_seconds)$"
Original file line number Diff line number Diff line change
@@ -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
44 changes: 44 additions & 0 deletions tests/integration/helm_ot_histograms_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//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
// we have tracing enabled, so check tracing-specific metrics
expectedMetrics = append(expectedMetrics, internal.TracingOtelcolMetrics...)

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)
}
3 changes: 3 additions & 0 deletions tests/integration/values/values_helm_ot_histograms.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sumologic:
metrics:
allowHistogramRegex: "^(apiserver_request_duration_seconds)$"

0 comments on commit b249a08

Please sign in to comment.