Skip to content

Commit

Permalink
Add journald receiver (#5160)
Browse files Browse the repository at this point in the history
Link to tracking Issue: #2332

Testing: Unit tests are included

Documentation: Journald receiver README.md is included
  • Loading branch information
luckyj5 authored Oct 13, 2021
1 parent 2c5fb78 commit fab94ea
Show file tree
Hide file tree
Showing 13 changed files with 2,152 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/otelcontribcol/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:latest as prep
FROM alpine:latest as prep
RUN apk --update add ca-certificates

ARG USER_UID=10001
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/influxdbreceiver v0.36.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver v0.36.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jmxreceiver v0.36.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/journaldreceiver v0.36.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver v0.36.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kafkametricsreceiver v0.36.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kafkareceiver v0.36.0
Expand Down Expand Up @@ -560,6 +561,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaege

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jmxreceiver => ./receiver/jmxreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/journaldreceiver => ./receiver/journaldreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zookeeperreceiver => ./receiver/zookeeperreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver => ./receiver/filelogreceiver
Expand Down
2 changes: 2 additions & 0 deletions internal/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/influxdbreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jmxreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/journaldreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kafkametricsreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kafkareceiver"
Expand Down Expand Up @@ -157,6 +158,7 @@ func Components() (component.Factories, error) {
influxdbreceiver.NewFactory(),
jaegerreceiver.NewFactory(),
jmxreceiver.NewFactory(),
journaldreceiver.NewFactory(),
kafkareceiver.NewFactory(),
kafkametricsreceiver.NewFactory(),
k8sclusterreceiver.NewFactory(),
Expand Down
2 changes: 1 addition & 1 deletion internal/components/receivers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestDefaultReceivers(t *testing.T) {
},
}

assert.Equal(t, len(tests)+28 /* not tested */, len(rcvrFactories))
assert.Equal(t, len(tests)+29 /* not tested */, len(rcvrFactories))
for _, tt := range tests {
t.Run(string(tt.receiver), func(t *testing.T) {
factory, ok := rcvrFactories[tt.receiver]
Expand Down
1 change: 1 addition & 0 deletions receiver/journaldreceiver/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
30 changes: 30 additions & 0 deletions receiver/journaldreceiver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## `Journald Receiver`

Parses Journald events from systemd journal using the [opentelemetry-log-collection](https://github.com/open-telemetry/opentelemetry-log-collection) library.
Journald receiver is dependent on `journalctl` binary to be present and must be in the $PATH of the agent.
Supported pipeline types: logs

> :construction: This receiver is in alpha and configuration fields are subject to change.
## Configuration

| Field | Default | Description |
| --- | --- | --- |
| `directory` | /run/log/journal or /run/journal | A directory containing journal files to read entries from. |
| `files` | | A list of journal files to read entries from |
| `start_at` | `end` | At startup, where to start reading logs from the file. Options are beginning or end |
| `units` | `[ssh, kubelet, docker, containerd]` | A list of units to read entries from |
| `prioriry` | `info` | Filter output by message priorities or priority ranges |

### Example Configurations
```yaml
receivers:
journald:
directory: /run/log/journal
units:
- ssh
- kubelet
- docker
- containerd
priority: info
```
15 changes: 15 additions & 0 deletions receiver/journaldreceiver/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2021 OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package journaldreceiver
51 changes: 51 additions & 0 deletions receiver/journaldreceiver/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
module github.com/open-telemetry/opentelemetry-collector-contrib/receiver/journaldreceiver

go 1.17

require (
github.com/open-telemetry/opentelemetry-collector-contrib/internal/stanza v0.0.0-00010101000000-000000000000
github.com/open-telemetry/opentelemetry-log-collection v0.21.0
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/collector v0.36.1-0.20211004155959-190f8fbb2b9a
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/antonmedv/expr v1.9.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/knadh/koanf v1.2.4 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/observiq/ctimefmt v1.0.0 // indirect
github.com/pelletier/go-toml v1.9.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.6.1 // indirect
github.com/spf13/cast v1.4.1 // indirect
go.opentelemetry.io/collector/model v0.36.1-0.20211004155959-190f8fbb2b9a // indirect
go.opentelemetry.io/otel v1.0.1 // indirect
go.opentelemetry.io/otel/metric v0.24.0 // indirect
go.opentelemetry.io/otel/trace v1.0.1 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.19.1 // indirect
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
golang.org/x/text v0.3.7 // indirect
gonum.org/v1/gonum v0.9.3 // indirect
google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08 // indirect
google.golang.org/grpc v1.41.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/stanza => ../../internal/stanza

replace github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage => ../../extension/storage
Loading

0 comments on commit fab94ea

Please sign in to comment.