Skip to content

Commit 7915cb9

Browse files
add remaining inputs for our test usecase (#10785) (#10874)
(cherry picked from commit 6497eff) Co-authored-by: Lee E Hinman <[email protected]>
1 parent 5fb71ac commit 7915cb9

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
@@ -39,12 +39,28 @@ import (
3939
const OtelNamePrefix = "_agent-component/"
4040

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

4547
var (
46-
OtelSupportedOutputTypes = []string{"elasticsearch"}
47-
OtelSupportedInputTypes = []string{"filestream", "http/metrics", "beat/metrics", "system/metrics", "prometheus/metrics"}
48+
OtelSupportedOutputTypes = []string{"elasticsearch"}
49+
OtelSupportedFilebeatInputTypes = []string{
50+
"filestream",
51+
"journald",
52+
"log",
53+
"winlog",
54+
}
55+
OtelSupportedMetricbeatInputTypes = []string{
56+
"beat/metrics",
57+
"http/metrics",
58+
"kubernetes/metrics",
59+
"linux/metrics",
60+
"prometheus/metrics",
61+
"system/metrics",
62+
}
63+
OtelSupportedInputTypes = slices.Concat(OtelSupportedFilebeatInputTypes, OtelSupportedMetricbeatInputTypes)
4864
configTranslationFuncForExporter = map[otelcomponent.Type]exporterConfigTranslationFunc{
4965
otelcomponent.MustNewType("elasticsearch"): translateEsOutputToExporter,
5066
}
@@ -179,13 +195,11 @@ func getCollectorConfigForComponent(
179195
beatMonitoringConfigGetter BeatMonitoringConfigGetter,
180196
logger *logp.Logger,
181197
) (*confmap.Conf, error) {
182-
183198
exportersConfig, outputQueueConfig, extensionConfig, err := getExportersConfigForComponent(comp, logger)
184199
if err != nil {
185200
return nil, err
186201
}
187202
receiversConfig, err := getReceiversConfigForComponent(comp, info, outputQueueConfig, beatMonitoringConfigGetter)
188-
189203
if err != nil {
190204
return nil, err
191205
}
@@ -201,7 +215,7 @@ func getCollectorConfigForComponent(
201215
}
202216

203217
// we need to convert []string to []interface for this to work
204-
extensionKey := make([]interface{}, len(maps.Keys(extensionConfig)))
218+
extensionKey := make([]any, len(maps.Keys(extensionConfig)))
205219
for i, v := range maps.Keys(extensionConfig) {
206220
extensionKey[i] = v
207221
}
@@ -269,13 +283,13 @@ func getReceiversConfigForComponent(
269283
// adds additional context on logs emitted by beatreceivers to uniquely identify per component logs
270284
"logging": map[string]any{
271285
"with_fields": map[string]any{
272-
"component": map[string]interface{}{
286+
"component": map[string]any{
273287
"id": comp.ID,
274288
"binary": binaryName,
275289
"dataset": dataset,
276290
"type": comp.InputType,
277291
},
278-
"log": map[string]interface{}{
292+
"log": map[string]any{
279293
"source": comp.ID,
280294
},
281295
},

internal/pkg/otel/translate/otelconfig_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,10 +1190,10 @@ func TestVerifyComponentIsOtelSupported(t *testing.T) {
11901190
name: "unsupported input type",
11911191
component: &component.Component{
11921192
ID: "unsupported-input",
1193-
InputType: "log", // unsupported
1193+
InputType: "stdin", // unsupported
11941194
OutputType: "elasticsearch",
11951195
},
1196-
expectedError: "unsupported input type: log",
1196+
expectedError: "unsupported input type: stdin",
11971197
},
11981198
{
11991199
name: "unsupported configuration",

0 commit comments

Comments
 (0)