Skip to content

Commit 55c694b

Browse files
add remaining inputs for our test usecase (#10785) (#11522)
(cherry picked from commit 6497eff) Co-authored-by: Lee E Hinman <[email protected]>
1 parent 1557239 commit 55c694b

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

internal/pkg/otel/translate/otelconfig.go

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,28 @@ const (
4747
)
4848

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

5355
var (
54-
OtelSupportedOutputTypes = []string{"elasticsearch"}
55-
OtelSupportedInputTypes = []string{"filestream", "http/metrics", "beat/metrics", "system/metrics", "prometheus/metrics"}
56+
OtelSupportedOutputTypes = []string{"elasticsearch"}
57+
OtelSupportedFilebeatInputTypes = []string{
58+
"filestream",
59+
"journald",
60+
"log",
61+
"winlog",
62+
}
63+
OtelSupportedMetricbeatInputTypes = []string{
64+
"beat/metrics",
65+
"http/metrics",
66+
"kubernetes/metrics",
67+
"linux/metrics",
68+
"prometheus/metrics",
69+
"system/metrics",
70+
}
71+
OtelSupportedInputTypes = slices.Concat(OtelSupportedFilebeatInputTypes, OtelSupportedMetricbeatInputTypes)
5672
configTranslationFuncForExporter = map[otelcomponent.Type]exporterConfigTranslationFunc{
5773
otelcomponent.MustNewType("elasticsearch"): translateEsOutputToExporter,
5874
}
@@ -211,13 +227,11 @@ func getCollectorConfigForComponent(
211227
beatMonitoringConfigGetter BeatMonitoringConfigGetter,
212228
logger *logp.Logger,
213229
) (*confmap.Conf, error) {
214-
215230
exportersConfig, outputQueueConfig, extensionConfig, err := getExportersConfigForComponent(comp, logger)
216231
if err != nil {
217232
return nil, err
218233
}
219234
receiversConfig, err := getReceiversConfigForComponent(comp, info, outputQueueConfig, beatMonitoringConfigGetter)
220-
221235
if err != nil {
222236
return nil, err
223237
}
@@ -233,7 +247,7 @@ func getCollectorConfigForComponent(
233247
}
234248

235249
// we need to convert []string to []interface for this to work
236-
extensionKey := make([]interface{}, len(maps.Keys(extensionConfig)))
250+
extensionKey := make([]any, len(maps.Keys(extensionConfig)))
237251
for i, v := range maps.Keys(extensionConfig) {
238252
extensionKey[i] = v
239253
}
@@ -301,13 +315,13 @@ func getReceiversConfigForComponent(
301315
// adds additional context on logs emitted by beatreceivers to uniquely identify per component logs
302316
"logging": map[string]any{
303317
"with_fields": map[string]any{
304-
"component": map[string]interface{}{
318+
"component": map[string]any{
305319
"id": comp.ID,
306320
"binary": binaryName,
307321
"dataset": dataset,
308322
"type": comp.InputType,
309323
},
310-
"log": map[string]interface{}{
324+
"log": map[string]any{
311325
"source": comp.ID,
312326
},
313327
},

internal/pkg/otel/translate/otelconfig_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,10 +1194,10 @@ func TestVerifyComponentIsOtelSupported(t *testing.T) {
11941194
name: "unsupported input type",
11951195
component: &component.Component{
11961196
ID: "unsupported-input",
1197-
InputType: "log", // unsupported
1197+
InputType: "stdin", // unsupported
11981198
OutputType: "elasticsearch",
11991199
},
1200-
expectedError: "unsupported input type: log",
1200+
expectedError: "unsupported input type: stdin",
12011201
},
12021202
{
12031203
name: "unsupported configuration",

0 commit comments

Comments
 (0)