-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converter automatic logging processor (#6711)
* add otel conversion to otelcol.exporter.logging Signed-off-by: erikbaranowski <[email protected]> * reorganize static builder code and stub out automatic_logging for traces handling Signed-off-by: erikbaranowski <[email protected]> * wire up default otelcol.exporter.logging to replace the automatic_logging processor Signed-off-by: erikbaranowski <[email protected]> --------- Signed-off-by: erikbaranowski <[email protected]>
- Loading branch information
1 parent
e4aaea4
commit c80c234
Showing
15 changed files
with
648 additions
and
434 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
internal/converter/internal/otelcolconvert/converter_loggingexporter.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package otelcolconvert | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/grafana/agent/internal/component/otelcol/exporter/logging" | ||
"github.com/grafana/agent/internal/converter/diag" | ||
"github.com/grafana/agent/internal/converter/internal/common" | ||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/exporter/loggingexporter" | ||
"go.uber.org/zap/zapcore" | ||
) | ||
|
||
func init() { | ||
converters = append(converters, loggingExporterConverter{}) | ||
} | ||
|
||
type loggingExporterConverter struct{} | ||
|
||
func (loggingExporterConverter) Factory() component.Factory { | ||
return loggingexporter.NewFactory() | ||
} | ||
|
||
func (loggingExporterConverter) InputComponentName() string { | ||
return "otelcol.exporter.logging" | ||
} | ||
|
||
func (loggingExporterConverter) ConvertAndAppend(state *state, id component.InstanceID, cfg component.Config) diag.Diagnostics { | ||
var diags diag.Diagnostics | ||
|
||
label := state.FlowComponentLabel() | ||
args := toOtelcolExporterLogging(cfg.(*loggingexporter.Config)) | ||
block := common.NewBlockWithOverrideFn([]string{"otelcol", "exporter", "logging"}, label, args, nil) | ||
|
||
diags.Add( | ||
diag.SeverityLevelInfo, | ||
fmt.Sprintf("Converted %s into %s", stringifyInstanceID(id), stringifyBlock(block)), | ||
) | ||
|
||
diags.AddAll(common.ValidateSupported(common.NotEquals, | ||
cfg.(*loggingexporter.Config).LogLevel, | ||
zapcore.InfoLevel, | ||
"otelcol logging exporter loglevel", | ||
"use verbosity instead since loglevel is deprecated")) | ||
|
||
state.Body().AppendBlock(block) | ||
return diags | ||
} | ||
|
||
func toOtelcolExporterLogging(cfg *loggingexporter.Config) *logging.Arguments { | ||
return &logging.Arguments{ | ||
Verbosity: cfg.Verbosity, | ||
SamplingInitial: cfg.SamplingInitial, | ||
SamplingThereafter: cfg.SamplingThereafter, | ||
DebugMetrics: common.DefaultValue[logging.Arguments]().DebugMetrics, | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
internal/converter/internal/otelcolconvert/testdata/logging.diags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(Error) The converter does not support converting the provided otelcol logging exporter loglevel config: use verbosity instead since loglevel is deprecated |
23 changes: 23 additions & 0 deletions
23
internal/converter/internal/otelcolconvert/testdata/logging.river
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
otelcol.receiver.otlp "default" { | ||
grpc { } | ||
|
||
http { } | ||
|
||
output { | ||
metrics = [otelcol.exporter.logging.default.input, otelcol.exporter.logging.default_2.input] | ||
logs = [otelcol.exporter.logging.default.input, otelcol.exporter.logging.default_2.input] | ||
traces = [otelcol.exporter.logging.default.input, otelcol.exporter.logging.default_2.input] | ||
} | ||
} | ||
|
||
otelcol.exporter.logging "default" { | ||
verbosity = "Detailed" | ||
sampling_initial = 5 | ||
sampling_thereafter = 200 | ||
} | ||
|
||
otelcol.exporter.logging "default_2" { | ||
verbosity = "Detailed" | ||
sampling_initial = 5 | ||
sampling_thereafter = 200 | ||
} |
30 changes: 30 additions & 0 deletions
30
internal/converter/internal/otelcolconvert/testdata/logging.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
http: | ||
|
||
exporters: | ||
logging: | ||
verbosity: detailed | ||
sampling_initial: 5 | ||
sampling_thereafter: 200 | ||
logging/2: | ||
sampling_initial: 5 | ||
sampling_thereafter: 200 | ||
loglevel: debug | ||
|
||
service: | ||
pipelines: | ||
metrics: | ||
receivers: [otlp] | ||
processors: [] | ||
exporters: [logging,logging/2] | ||
logs: | ||
receivers: [otlp] | ||
processors: [] | ||
exporters: [logging,logging/2] | ||
traces: | ||
receivers: [otlp] | ||
processors: [] | ||
exporters: [logging,logging/2] |
Oops, something went wrong.