Skip to content

Commit 29e6107

Browse files
confgenerator : Add otel logging support for systemd_journald receiver. (#1872)
1 parent b362e1d commit 29e6107

File tree

18 files changed

+1535
-8
lines changed

18 files changed

+1535
-8
lines changed

confgenerator/logging_receivers.go

+54
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,60 @@ func (r LoggingReceiverSystemd) Components(ctx context.Context, tag string) []fl
682682
return input
683683
}
684684

685+
func (r LoggingReceiverSystemd) Pipelines(ctx context.Context) ([]otel.ReceiverPipeline, error) {
686+
receiver_config := map[string]any{
687+
"start_at": "beginning",
688+
"priority": "debug",
689+
}
690+
691+
modify_fields_processors, err := LoggingProcessorModifyFields{
692+
Fields: map[string]*ModifyField{
693+
`severity`: {
694+
CopyFrom: "jsonPayload.PRIORITY",
695+
MapValues: map[string]string{
696+
"7": "DEBUG",
697+
"6": "INFO",
698+
"5": "NOTICE",
699+
"4": "WARNING",
700+
"3": "ERROR",
701+
"2": "CRITICAL",
702+
"1": "ALERT",
703+
"0": "EMERGENCY",
704+
},
705+
MapValuesExclusive: true,
706+
},
707+
`sourceLocation.file`: {
708+
CopyFrom: "jsonPayload.CODE_FILE",
709+
},
710+
`sourceLocation.func`: {
711+
CopyFrom: "jsonPayload.CODE_FUNC",
712+
},
713+
`sourceLocation.line`: {
714+
CopyFrom: "jsonPayload.CODE_LINE",
715+
Type: "integer",
716+
},
717+
},
718+
}.Processors(ctx)
719+
720+
if err != nil {
721+
return nil, err
722+
}
723+
724+
return []otel.ReceiverPipeline{{
725+
Receiver: otel.Component{
726+
Type: "journald",
727+
Config: receiver_config,
728+
},
729+
Processors: map[string][]otel.Component{
730+
"logs": modify_fields_processors,
731+
},
732+
733+
ExporterTypes: map[string]otel.ExporterType{
734+
"logs": otel.OTel,
735+
},
736+
}}, nil
737+
}
738+
685739
func init() {
686740
LoggingReceiverTypes.RegisterType(func() LoggingReceiver { return &LoggingReceiverSystemd{} }, platform.Linux)
687741
}

confgenerator/testdata/goldens/all-quoted_map_keys/golden/linux-gpu/features.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
- module: logging
1414
feature: service:otel_logging
1515
key: otel_logging_supported_config
16-
value: "false"
16+
value: "true"
1717
- module: logging
1818
feature: receivers:systemd_journald
1919
key: "[0].enabled"

confgenerator/testdata/goldens/all-quoted_map_keys/golden/linux/features.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
- module: logging
1414
feature: service:otel_logging
1515
key: otel_logging_supported_config
16-
value: "false"
16+
value: "true"
1717
- module: logging
1818
feature: receivers:systemd_journald
1919
key: "[0].enabled"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
otel_logging
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
- module: logging
2+
feature: service:pipelines
3+
key: default_pipeline_overridden
4+
value: "false"
5+
- module: metrics
6+
feature: service:pipelines
7+
key: default_pipeline_overridden
8+
value: "false"
9+
- module: global
10+
feature: default:self_log
11+
key: default_self_log_file_collection
12+
value: "true"
13+
- module: logging
14+
feature: service:otel_logging
15+
key: otel_logging_supported_config
16+
value: "true"
17+
- module: logging
18+
feature: receivers:systemd_journald
19+
key: "[0].enabled"
20+
value: "true"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@SET buffers_dir=/var/lib/google-cloud-ops-agent/fluent-bit/buffers
2+
@SET logs_dir=/var/log/google-cloud-ops-agent
3+
4+
[SERVICE]
5+
Daemon off
6+
Flush 1
7+
Log_Level info
8+
dns.resolver legacy
9+
storage.backlog.mem_limit 50M
10+
storage.checksum off
11+
storage.max_chunks_up 128
12+
storage.metrics on
13+
storage.sync normal
14+
15+
[INPUT]
16+
Name fluentbit_metrics
17+
Scrape_Interval 60
18+
Scrape_On_Start True
19+
20+
[OUTPUT]
21+
Match *
22+
Name prometheus_exporter
23+
host 0.0.0.0
24+
port 20202

confgenerator/testdata/goldens/logging-otel-receiver_systemd/golden/linux-gpu/fluent_bit_parser.conf

Whitespace-only changes.

0 commit comments

Comments
 (0)