Skip to content

Commit

Permalink
feat!: use OTLP sources by default
Browse files Browse the repository at this point in the history
  • Loading branch information
swiatekm committed Sep 25, 2023
1 parent 8b109d2 commit ddf1206
Show file tree
Hide file tree
Showing 36 changed files with 304 additions and 453 deletions.
1 change: 1 addition & 0 deletions .changelog/3297.changed.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
feat!: use OTLP sources by default
10 changes: 5 additions & 5 deletions deploy/helm/sumologic/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ sumologic:
pvcLabels: {}
# storageClass:

sourceType: http
sourceType: otlp

### Logs configuration
## Set the enabled flag to false for disabling logs ingestion altogether.
Expand Down Expand Up @@ -435,7 +435,7 @@ sumologic:
## https://help.sumologic.com/docs/manage/fields/#manage-fields
additionalFields: []

sourceType: http
sourceType: otlp

### Metrics configuration
## Set the enabled flag to false for disabling metrics ingestion altogether.
Expand Down Expand Up @@ -666,7 +666,7 @@ sumologic:

## The type of source we send to in Sumo. The possible values are http and otlp.
## Consult the documentation for more information.
sourceType: http
sourceType: otlp

### Traces configuration
## Set the enabled flag to false to disable traces ingestion.
Expand All @@ -675,7 +675,7 @@ sumologic:
## How many spans per request should be send to receiver
spans_per_request: 100

sourceType: http
sourceType: otlp

## Configure metrics-server
## ref: https://github.com/bitnami/charts/blob/master/bitnami/metrics-server/values.yaml
Expand Down Expand Up @@ -1583,7 +1583,7 @@ tracesSampler:
# logging:
# loglevel: debug
otlphttp:
traces_endpoint: ${SUMO_ENDPOINT_DEFAULT_TRACES_SOURCE}
traces_endpoint: ${SUMO_ENDPOINT_DEFAULT_OTLP_TRACES_SOURCE}/v1/traces
compression: gzip
service:
extensions: [health_check, memory_ballast, pprof]
Expand Down
40 changes: 20 additions & 20 deletions docs/otlp-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,22 @@ Historically, agents used by this Chart sent logs and metrics data to a [generic
The data needed to be converted to the formats the generic HTTP source supports before being sent.

Recently, we've added support for directly sending data using the OTLP protocol to Sumo Logic. This is achieved using the [OTLP
source][otlp_source]. This document explains how to use this new source with the Helm Chart.
source][otlp_source]. These sources are now used by default unless configured otherwise.

## Enabling the OTLP source
## Benefits

Sending data directly via OTLP is more efficient, as we skip the conversion step. OTLP is also a binary-encoded format, which improves the
efficiency further.

### Logs

As a structured log format, OTLP frees us from the need to parse metadata out of the log body on the Sumo side. This makes the following
features work without additional manual configuration:

- multiline parsing for the `text` log format
- correct timestamps for the `text` log format

## Switching back to HTTP sources

### For logs

Expand All @@ -16,7 +29,7 @@ Add the following to your configuration:
```yaml
sumologic:
logs:
sourceType: otlp
sourceType: http
```
### For metrics
Expand All @@ -26,7 +39,7 @@ Add the following to your configuration:
```yaml
sumologic:
metricss:
sourceType: otlp
sourceType: http
```
### For traces
Expand All @@ -36,39 +49,26 @@ Add the following to your configuration:
```yaml
sumologic:
traces:
sourceType: otlp
sourceType: http

tracesSampler:
config:
exporters:
otlphttp:
traces_endpoint: ${SUMO_ENDPOINT_DEFAULT_OTLP_TRACES_SOURCE}
traces_endpoint: ${SUMO_ENDPOINT_DEFAULT_TRACES_SOURCE}/v1/traces
```
### For events
```yaml
sumologic:
events:
sourceType: otlp
sourceType: http
```
**Note:** The source is automatically created during Chart installation. This setting simply makes the Chart start sending data to it. If
you normally have setup disabled, you need to either enable it after enabling the otlp source, or create the source manually.
## Benefits
Sending data directly via OTLP is more efficient, as we skip the conversion step. OTLP is also a binary-encoded format, which improves the
efficiency further.
### Logs
As a structured log format, OTLP frees us from the need to parse metadata out of the log body on the Sumo side. This makes the following
features work without additional manual configuration:
- multiline parsing for the `text` log format
- correct timestamps for the `text` log format

[http_source]: https://help.sumologic.com/docs/send-data/hosted-collectors/http-source/logs-metrics/
[otlp_source]: https://help.sumologic.com/docs/send-data/hosted-collectors/http-source/otlp/
[v3]: https://github.com/SumoLogic/sumologic-kubernetes-collection/releases/tag/v3.0.0
Expand Down
38 changes: 37 additions & 1 deletion docs/v4-migration-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [OpenTelemetry Collector](#opentelemetry-collector)
- [Drop Prometheus recording rule metrics](#drop-prometheus-recording-rule-metrics)
- [OpenTelemetry Collector for metrics collection](#opentelemetry-collector-for-metrics-collection)
- [Use OTLP sources by default](#use-otlp-sources-by-default)
- [How to upgrade](#how-to-upgrade)
- [Requirements](#requirements)
- [Metrics migration](#metrics-migration)
Expand Down Expand Up @@ -46,6 +47,13 @@ be a transparent change without any need for manual configuration changes. OpenT
metrics as Prometheus did previously, and will support the same mechanisms for collecting custom application metrics. Any exceptions will be
called out in the migration guide below.

### Use OTLP sources by default

This Helm Chart automatically creates the necessary Collector and Sources in Sumo. Up until this point, these were generic HTTP sources
accepting data in different formats. As Sumo now has native support for the OTLP protocol used by Open Telemetry, we've decided to switch to
using these new sources by default. This is a completely transparent change **unless** you use the `_sourceName` or `_source` fields in your
Sumo queries.

## How to upgrade

### Requirements
Expand Down Expand Up @@ -119,7 +127,35 @@ In addition the following changes has been done:

### Switch to OTLP sources

:construction:
> [!NOTE] Both source types will be created by the setup job. The settings discussed here affect which source is actually used.
**When?**: You use the `_sourceName` or `_source` fields in your Sumo queries.

The only solution is to change the queries in question. In general, it's an antipattern to write queries against specific sources, instead
of semantic attributes of the data.

You can switch back to the default v3 behaviour by setting:

```yaml
sumologic:
logs:
sourceType: http

metrics:
sourceType: http

traces:
sourceType: http

events:
sourceType: http

tracesSampler:
config:
exporters:
otlphttp:
traces_endpoint: ${SUMO_ENDPOINT_DEFAULT_TRACES_SOURCE}/v1/traces
```
### Running the helm upgrade
Expand Down
5 changes: 3 additions & 2 deletions tests/helm/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ sumologic:
err := yaml.Unmarshal([]byte(otelConfigYaml), &otelConfig)
require.NoError(t, err)

require.ElementsMatch(t, []string{"sumologic/containers"}, keys(otelConfig.Exporters))
require.ElementsMatch(t, []string{"sumologic"}, keys(otelConfig.Exporters))
require.ElementsMatch(t, []string{"logs/otlp/containers"}, keys(otelConfig.Service.Pipelines))
for processorName := range otelConfig.Processors {
require.NotContains(t, processorName, "systemd")
Expand Down Expand Up @@ -126,7 +126,7 @@ sumologic:
require.Contains(t, containersPipeline.Processors, "filter/include-host")
}

func TestMetadataLogFormat(t *testing.T) {
func TestMetadataLogFormatHTTP(t *testing.T) {
t.Parallel()
templatePath := "templates/logs/otelcol/configmap.yaml"

Expand Down Expand Up @@ -174,6 +174,7 @@ sumologic:
logs:
container:
format: %s
sourceType: http
`
valuesYaml := fmt.Sprintf(valuesYamlTemplate, testCase.logFormat)
otelConfigYaml := GetOtelConfigYaml(t, valuesYaml, templatePath)
Expand Down
55 changes: 52 additions & 3 deletions tests/helm/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ func TestMetadataMetricsOtelConfigExtraProcessors(t *testing.T) {
"transform/remove_name",
"filter/drop_unnecessary_metrics",
"batch",
"routing",
}

require.Equal(t, expectedPipelineValue, otelConfig.Service.Pipelines.Metrics.Processors)
Expand Down Expand Up @@ -180,12 +179,62 @@ sumologic:
assert.Equal(t, otelConfig.Exporters.Default.Endpoint, "${SUMO_ENDPOINT_DEFAULT_OTLP_METRICS_SOURCE}")
assert.Len(t, otelConfig.Exporters.Rest, 0)
assert.NotContains(t, otelConfig.Processors, "routing")
assert.NotContains(t, otelConfig.Processors, "transform/prepare_routing")
assert.NotContains(t, otelConfig.Service.Pipelines.Metrics.Processors, "routing")
assert.NotContains(t, otelConfig.Service.Pipelines.Metrics.Processors, "transform/prepare_routing")
assert.Equal(t, otelConfig.Service.Pipelines.Metrics.Exporters, []string{"sumologic/default"})
}

func TestMetadataSourceTypeHTTP(t *testing.T) {
t.Parallel()
templatePath := "templates/metrics/otelcol/configmap.yaml"

type OtelConfig struct {
Exporters map[string]struct {
MetricFormat string `yaml:"metric_format"`
Endpoint string
} `yaml:"exporters"`
Processors map[string]interface{}
Service struct {
Pipelines struct {
Metrics struct {
Processors []string `yaml:"processors"`
Exporters []string `yaml:"exporters"`
}
}
}
}

var otelConfig OtelConfig
valuesYaml := `
sumologic:
metrics:
sourceType: http
`
otelConfigYaml := GetOtelConfigYaml(t, valuesYaml, templatePath)
err := yaml.Unmarshal([]byte(otelConfigYaml), &otelConfig)
require.NoError(t, err)

require.Contains(t, otelConfig.Exporters, "sumologic/default")
defaultExporter := otelConfig.Exporters["sumologic/default"]
assert.Equal(t, "prometheus", defaultExporter.MetricFormat)
assert.Equal(t, "${SUMO_ENDPOINT_DEFAULT_METRICS_SOURCE}", defaultExporter.Endpoint)
assert.Contains(t, otelConfig.Processors, "routing")
assert.Contains(t, otelConfig.Service.Pipelines.Metrics.Processors, "routing")
assert.Equal(
t,
[]string{
"sumologic/default",
"sumologic/apiserver",
"sumologic/control_plane",
"sumologic/controller",
"sumologic/kubelet",
"sumologic/node",
"sumologic/scheduler",
"sumologic/state",
},
otelConfig.Service.Pipelines.Metrics.Exporters,
)
}

func TestNoPrometheusServiceMonitors(t *testing.T) {
t.Parallel()
allTemplatePaths := []string{
Expand Down
4 changes: 2 additions & 2 deletions tests/helm/testdata/goldenfile/events_otc/basic.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ data:
exporters:
sumologic:
clear_logs_timestamp: false
endpoint: ${SUMO_ENDPOINT_DEFAULT_EVENTS_SOURCE}
log_format: json
endpoint: ${SUMO_ENDPOINT_DEFAULT_OTLP_EVENTS_SOURCE}
log_format: otlp
sending_queue:
enabled: true
storage: file_storage
Expand Down
4 changes: 2 additions & 2 deletions tests/helm/testdata/goldenfile/events_otc/options.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ data:
exporters:
sumologic:
clear_logs_timestamp: false
endpoint: ${SUMO_ENDPOINT_DEFAULT_EVENTS_SOURCE}
log_format: json
endpoint: ${SUMO_ENDPOINT_DEFAULT_OTLP_EVENTS_SOURCE}
log_format: otlp
sending_queue:
enabled: true
extensions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ spec:
secretKeyRef:
name: sumologic
key: endpoint-events
- name: SUMO_ENDPOINT_DEFAULT_OTLP_EVENTS_SOURCE
valueFrom:
secretKeyRef:
name: sumologic
key: endpoint-events-otlp

- name: NO_PROXY
value: kubernetes.default.svc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sumologic:
events:
sourceType: otlp
sourceType: http
podAnnotations:
sumoAnnotation: sumoValue
podLabels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ spec:
secretKeyRef:
name: sumologic
key: endpoint-events
- name: SUMO_ENDPOINT_DEFAULT_OTLP_EVENTS_SOURCE
valueFrom:
secretKeyRef:
name: sumologic
key: endpoint-events-otlp

- name: NO_PROXY
value: kubernetes.default.svc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ spec:
secretKeyRef:
name: sumologic
key: endpoint-events
- name: SUMO_ENDPOINT_DEFAULT_OTLP_EVENTS_SOURCE
valueFrom:
secretKeyRef:
name: sumologic
key: endpoint-events-otlp

- name: HTTP_PROXY
value: http://proxy.internal
Expand Down
Loading

0 comments on commit ddf1206

Please sign in to comment.