Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions internal/pkg/otel/translate/otelconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,28 @@ import (
const OtelNamePrefix = "_agent-component/"

// BeatMonitoringConfigGetter is a function that returns the monitoring configuration for a beat receiver.
type BeatMonitoringConfigGetter func(unitID, binary string) map[string]any
type exporterConfigTranslationFunc func(*config.C, *logp.Logger) (map[string]any, error)
type (
BeatMonitoringConfigGetter func(unitID, binary string) map[string]any
exporterConfigTranslationFunc func(*config.C, *logp.Logger) (map[string]any, error)
)

var (
OtelSupportedOutputTypes = []string{"elasticsearch"}
OtelSupportedInputTypes = []string{"filestream", "http/metrics", "beat/metrics", "system/metrics", "prometheus/metrics"}
OtelSupportedOutputTypes = []string{"elasticsearch"}
OtelSupportedFilebeatInputTypes = []string{
"filestream",
"journald",
"log",
"winlog",
}
OtelSupportedMetricbeatInputTypes = []string{
"beat/metrics",
"http/metrics",
"kubernetes/metrics",
"linux/metrics",
"prometheus/metrics",
"system/metrics",
}
OtelSupportedInputTypes = slices.Concat(OtelSupportedFilebeatInputTypes, OtelSupportedMetricbeatInputTypes)
configTranslationFuncForExporter = map[otelcomponent.Type]exporterConfigTranslationFunc{
otelcomponent.MustNewType("elasticsearch"): translateEsOutputToExporter,
}
Expand Down Expand Up @@ -179,13 +195,11 @@ func getCollectorConfigForComponent(
beatMonitoringConfigGetter BeatMonitoringConfigGetter,
logger *logp.Logger,
) (*confmap.Conf, error) {

exportersConfig, outputQueueConfig, extensionConfig, err := getExportersConfigForComponent(comp, logger)
if err != nil {
return nil, err
}
receiversConfig, err := getReceiversConfigForComponent(comp, info, outputQueueConfig, beatMonitoringConfigGetter)

if err != nil {
return nil, err
}
Expand All @@ -201,7 +215,7 @@ func getCollectorConfigForComponent(
}

// we need to convert []string to []interface for this to work
extensionKey := make([]interface{}, len(maps.Keys(extensionConfig)))
extensionKey := make([]any, len(maps.Keys(extensionConfig)))
for i, v := range maps.Keys(extensionConfig) {
extensionKey[i] = v
}
Expand Down Expand Up @@ -269,13 +283,13 @@ func getReceiversConfigForComponent(
// adds additional context on logs emitted by beatreceivers to uniquely identify per component logs
"logging": map[string]any{
"with_fields": map[string]any{
"component": map[string]interface{}{
"component": map[string]any{
"id": comp.ID,
"binary": binaryName,
"dataset": dataset,
"type": comp.InputType,
},
"log": map[string]interface{}{
"log": map[string]any{
"source": comp.ID,
},
},
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/otel/translate/otelconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1190,10 +1190,10 @@ func TestVerifyComponentIsOtelSupported(t *testing.T) {
name: "unsupported input type",
component: &component.Component{
ID: "unsupported-input",
InputType: "log", // unsupported
InputType: "stdin", // unsupported
OutputType: "elasticsearch",
},
expectedError: "unsupported input type: log",
expectedError: "unsupported input type: stdin",
},
{
name: "unsupported configuration",
Expand Down