diff --git a/README.md b/README.md index 3bad61fd9..1230fbcf8 100755 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ TBD: throughput on production servers. ## Plugins -**Input**: [dmesg](plugin/input/dmesg/README.md), [fake](plugin/input/fake/README.md), [file](plugin/input/file/README.md), [http](plugin/input/http/README.md), [journalctl](plugin/input/journalctl/README.md), [k8s](plugin/input/k8s/README.md), [kafka](plugin/input/kafka/README.md) +**Input**: [dmesg](plugin/input/dmesg/README.md), [fake](plugin/input/fake/README.md), [file](plugin/input/file/README.md), [http](plugin/input/http/README.md), [journald](plugin/input/journald/README.md), [k8s](plugin/input/k8s/README.md), [kafka](plugin/input/kafka/README.md) **Action**: [add_file_name](plugin/action/add_file_name/README.md), [add_host](plugin/action/add_host/README.md), [convert_date](plugin/action/convert_date/README.md), [convert_log_level](plugin/action/convert_log_level/README.md), [debug](plugin/action/debug/README.md), [discard](plugin/action/discard/README.md), [flatten](plugin/action/flatten/README.md), [join](plugin/action/join/README.md), [join_template](plugin/action/join_template/README.md), [json_decode](plugin/action/json_decode/README.md), [json_encode](plugin/action/json_encode/README.md), [keep_fields](plugin/action/keep_fields/README.md), [mask](plugin/action/mask/README.md), [modify](plugin/action/modify/README.md), [parse_es](plugin/action/parse_es/README.md), [parse_re2](plugin/action/parse_re2/README.md), [remove_fields](plugin/action/remove_fields/README.md), [rename](plugin/action/rename/README.md), [set_time](plugin/action/set_time/README.md), [throttle](plugin/action/throttle/README.md) diff --git a/_sidebar.md b/_sidebar.md index 46663300a..ef24abb53 100644 --- a/_sidebar.md +++ b/_sidebar.md @@ -17,7 +17,7 @@ - [fake](plugin/input/fake/README.md) - [file](plugin/input/file/README.md) - [http](plugin/input/http/README.md) - - [journalctl](plugin/input/journalctl/README.md) + - [journald](plugin/input/journald/README.md) - [k8s](plugin/input/k8s/README.md) - [kafka](plugin/input/kafka/README.md) diff --git a/cmd/file.d/file.d.go b/cmd/file.d/file.d.go index 690c7fd68..c11c37688 100644 --- a/cmd/file.d/file.d.go +++ b/cmd/file.d/file.d.go @@ -38,7 +38,7 @@ import ( _ "github.com/ozontech/file.d/plugin/input/fake" _ "github.com/ozontech/file.d/plugin/input/file" _ "github.com/ozontech/file.d/plugin/input/http" - _ "github.com/ozontech/file.d/plugin/input/journalctl" + _ "github.com/ozontech/file.d/plugin/input/journald" _ "github.com/ozontech/file.d/plugin/input/k8s" _ "github.com/ozontech/file.d/plugin/input/kafka" _ "github.com/ozontech/file.d/plugin/output/clickhouse" diff --git a/cmd/file.d/file.d_test.go b/cmd/file.d/file.d_test.go index f1b462ee9..6715c6255 100644 --- a/cmd/file.d/file.d_test.go +++ b/cmd/file.d/file.d_test.go @@ -164,7 +164,7 @@ Plugins registered automatically after importing by init() function: Moving plugin in sub dir in plugin dir will quit registration quietly. To prevent this let's check that DefaultPluginRegistry contains all plugins. -Plugins "dmesg", "journalctl" linux based, they contain tag: //go:build linux. +Plugins "dmesg", "journald" linux based, they contain tag: //go:build linux. We don't check them. */ func TestThatPluginsAreImported(t *testing.T) { diff --git a/docs/installation.md b/docs/installation.md index 82eb65b35..d286c5d4f 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -6,7 +6,7 @@ Images are available on [GitHub container registry](https://github.com/ozontech/file.d/pkgs/container/file.d/versions?filters%5Bversion_type%5D=tagged). **Note**: -If you are using [journalctl](https://github.com/ozontech/file.d/tree/master/plugin/input/journalctl) input plugin, we +If you are using [journald](https://github.com/ozontech/file.d/tree/master/plugin/input/journald) input plugin, we recommend choosing the ubuntu version that matches the host machine version. For example, if the host machine with which you want to collect logs using journald has a version of Ubuntu 18.04, you diff --git a/e2e/start_work_test.go b/e2e/start_work_test.go index 0d9e08b7e..3f63974ec 100644 --- a/e2e/start_work_test.go +++ b/e2e/start_work_test.go @@ -39,7 +39,7 @@ import ( _ "github.com/ozontech/file.d/plugin/input/fake" _ "github.com/ozontech/file.d/plugin/input/file" _ "github.com/ozontech/file.d/plugin/input/http" - _ "github.com/ozontech/file.d/plugin/input/journalctl" + _ "github.com/ozontech/file.d/plugin/input/journald" _ "github.com/ozontech/file.d/plugin/input/k8s" _ "github.com/ozontech/file.d/plugin/input/kafka" _ "github.com/ozontech/file.d/plugin/output/clickhouse" diff --git a/plugin/README.md b/plugin/README.md index 68fa73004..110eb5c94 100755 --- a/plugin/README.md +++ b/plugin/README.md @@ -102,10 +102,10 @@ curl "localhost:9200/_bulk" -H 'Content-Type: application/json' -d \ ``` [More details...](plugin/input/http/README.md) -## journalctl +## journald Reads `journalctl` output. -[More details...](plugin/input/journalctl/README.md) +[More details...](plugin/input/journald/README.md) ## k8s It reads Kubernetes logs and also adds pod meta-information. Also, it joins split logs into a single event. diff --git a/plugin/input/README.md b/plugin/input/README.md index 988e0668f..5a60a763f 100755 --- a/plugin/input/README.md +++ b/plugin/input/README.md @@ -101,10 +101,10 @@ curl "localhost:9200/_bulk" -H 'Content-Type: application/json' -d \ ``` [More details...](plugin/input/http/README.md) -## journalctl +## journald Reads `journalctl` output. -[More details...](plugin/input/journalctl/README.md) +[More details...](plugin/input/journald/README.md) ## k8s It reads Kubernetes logs and also adds pod meta-information. Also, it joins split logs into a single event. diff --git a/plugin/input/journalctl/init.go b/plugin/input/journalctl/init.go deleted file mode 100644 index b60e18b8e..000000000 --- a/plugin/input/journalctl/init.go +++ /dev/null @@ -1,3 +0,0 @@ -package journalctl - -// this file used to import journalctl plugin without errors on the darwin platform diff --git a/plugin/input/journalctl/README.idoc.md b/plugin/input/journald/README.idoc.md similarity index 100% rename from plugin/input/journalctl/README.idoc.md rename to plugin/input/journald/README.idoc.md diff --git a/plugin/input/journalctl/README.md b/plugin/input/journald/README.md similarity index 100% rename from plugin/input/journalctl/README.md rename to plugin/input/journald/README.md diff --git a/plugin/input/journald/init.go b/plugin/input/journald/init.go new file mode 100644 index 000000000..89d3ac57e --- /dev/null +++ b/plugin/input/journald/init.go @@ -0,0 +1,3 @@ +package journald + +// this file used to import journald plugin without errors on the darwin platform diff --git a/plugin/input/journalctl/journalctl.go b/plugin/input/journald/journald.go similarity index 81% rename from plugin/input/journalctl/journalctl.go rename to plugin/input/journald/journald.go index 9e8a2ff45..6bbe498a4 100644 --- a/plugin/input/journalctl/journalctl.go +++ b/plugin/input/journald/journald.go @@ -1,6 +1,6 @@ //go:build linux -package journalctl +package journald import ( "strings" @@ -28,9 +28,9 @@ type Plugin struct { // plugin metrics - offsetErrorsMetric *prometheus.CounterVec - journalCtlStopErrorMetric *prometheus.CounterVec - readerErrorsMetric *prometheus.CounterVec + offsetErrorsMetric *prometheus.CounterVec + journalDStopErrorMetric *prometheus.CounterVec + readerErrorsMetric *prometheus.CounterVec } type Config struct { @@ -65,14 +65,14 @@ func (o *offsetInfo) set(cursor string) { } func (p *Plugin) Write(bytes []byte) (int, error) { - p.params.Controller.In(0, "journalctl", p.currentOffset, bytes, false) + p.params.Controller.In(0, "journald", p.currentOffset, bytes, false) p.currentOffset++ return len(bytes), nil } func init() { fd.DefaultPluginRegistry.RegisterInput(&pipeline.PluginStaticInfo{ - Type: "journalctl", + Type: "journald", Factory: Factory, }) } @@ -108,16 +108,16 @@ func (p *Plugin) Start(config pipeline.AnyConfig, params *pipeline.InputPluginPa } func (p *Plugin) registerMetrics(ctl *metric.Ctl) { - p.offsetErrorsMetric = ctl.RegisterCounter("input_journalctl_offset_errors", "Number of errors occurred when saving/loading offset") - p.journalCtlStopErrorMetric = ctl.RegisterCounter("input_journalctl_stop_errors", "Total journalctl stop errors") - p.readerErrorsMetric = ctl.RegisterCounter("input_journalctl_reader_errors", "Total reader errors") + p.offsetErrorsMetric = ctl.RegisterCounter("input_journald_offset_errors", "Number of errors occurred when saving/loading offset") + p.journalDStopErrorMetric = ctl.RegisterCounter("input_journald_stop_errors", "Total journald stop errors") + p.readerErrorsMetric = ctl.RegisterCounter("input_journald_reader_errors", "Total reader errors") } func (p *Plugin) Stop() { err := p.reader.stop() if err != nil { - p.journalCtlStopErrorMetric.WithLabelValues().Inc() - p.logger.Error("can't stop journalctl cmd", zap.Error(err)) + p.journalDStopErrorMetric.WithLabelValues().Inc() + p.logger.Error("can't stop journald cmd", zap.Error(err)) } offsets := *p.offInfo.Load() diff --git a/plugin/input/journalctl/journalctl_test.go b/plugin/input/journald/journald_test.go similarity index 99% rename from plugin/input/journalctl/journalctl_test.go rename to plugin/input/journald/journald_test.go index 923d157af..01c575314 100644 --- a/plugin/input/journalctl/journalctl_test.go +++ b/plugin/input/journald/journald_test.go @@ -1,6 +1,6 @@ //go:build linux -package journalctl +package journald import ( "path/filepath" diff --git a/plugin/input/journalctl/reader.go b/plugin/input/journald/reader.go similarity index 99% rename from plugin/input/journalctl/reader.go rename to plugin/input/journald/reader.go index 15f8722a8..de898299d 100644 --- a/plugin/input/journalctl/reader.go +++ b/plugin/input/journald/reader.go @@ -1,6 +1,6 @@ //go:build linux -package journalctl +package journald import ( "bufio"