From ac2288393302e03d097360eb439bd9239510d4f0 Mon Sep 17 00:00:00 2001 From: maier Date: Mon, 15 Jun 2020 12:35:44 -0400 Subject: [PATCH 1/3] fix: do not skip config if log file not currently available let tail wait for it --- internal/configs/configs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/configs/configs.go b/internal/configs/configs.go index 90c5b60..22bdb33 100644 --- a/internal/configs/configs.go +++ b/internal/configs/configs.go @@ -103,7 +103,7 @@ func Load() ([]*Config, error) { Err(err). Str("log", logcfg.LogFile). Msg("access") - continue + // continue } if logcfg.ID == "" { // ID not explicitly set, use the base of the config file name From f2bd2cdd5189f5ba23286f7b0fa017a93c38f64a Mon Sep 17 00:00:00 2001 From: maier Date: Mon, 15 Jun 2020 12:37:32 -0400 Subject: [PATCH 2/3] upd: switch to nxadm updated tail upd: switch to poll for better handling of deleted log file --- go.mod | 5 ++--- go.sum | 7 +++---- internal/watcher/watcher.go | 9 +++++++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 8b2eb72..ca544a4 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,9 @@ go 1.14 require ( github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d github.com/circonus-labs/circonus-gometrics/v3 v3.0.1 - github.com/hpcloud/tail v1.0.0 + // github.com/hpcloud/tail v1.0.0 github.com/maier/go-appstats v0.2.0 + github.com/nxadm/tail v1.4.4 github.com/pelletier/go-toml v1.8.0 github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.19.0 @@ -17,7 +18,5 @@ require ( github.com/stretchr/testify v1.6.0 // indirect golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 - gopkg.in/fsnotify.v1 v1.4.7 // indirect - gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v2 v2.3.0 ) diff --git a/go.sum b/go.sum index 9f572e0..35b70a1 100644 --- a/go.sum +++ b/go.sum @@ -115,8 +115,6 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= -github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= @@ -156,6 +154,8 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= @@ -301,6 +301,7 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0 h1:HyfiK1WMnHj5FXFXatD+Qs1A/xC2Run6RzeW1SyHxpc= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 h1:OjiUf46hAmXblsZdnoSXsEUSKU8r1UEzcL5RVZ4gO9Y= golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= @@ -357,8 +358,6 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= diff --git a/internal/watcher/watcher.go b/internal/watcher/watcher.go index 5ae3266..bb9ab55 100644 --- a/internal/watcher/watcher.go +++ b/internal/watcher/watcher.go @@ -19,8 +19,11 @@ import ( "github.com/circonus-labs/circonus-logwatch/internal/config" "github.com/circonus-labs/circonus-logwatch/internal/configs" "github.com/circonus-labs/circonus-logwatch/internal/metrics" - "github.com/hpcloud/tail" + + // "github.com/hpcloud/tail" "github.com/maier/go-appstats" + + "github.com/nxadm/tail" "github.com/pkg/errors" "github.com/rs/zerolog" "github.com/rs/zerolog/log" @@ -121,6 +124,7 @@ func (w *Watcher) process() error { cfg := tail.Config{ Follow: true, ReOpen: true, + Poll: true, MustExist: false, Location: &tail.SeekInfo{ Offset: 0, @@ -203,7 +207,8 @@ START_TAIL: } w.metricLines <- ml // NOTE: do not 'break' on match, a single log - // line may generate multiple metrics, matching multiple config rules. + // line may generate multiple metrics by + // matching multiple config rules. } } } From d1ad424cb194777fc352358d59450519244d7106 Mon Sep 17 00:00:00 2001 From: maier Date: Mon, 15 Jun 2020 13:59:59 -0400 Subject: [PATCH 3/3] v1.0.0-beta.2 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9f74a7..266c222 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# v1.0.0-beta.2 + +* fix: do not skip config if log file not currently available let tail wait for the log +* fix: do not exit if only one config with a missing log file +* upd: switch to nxadm/tail updated tail (hpcloud/tail is not currently being updated/maintained) +* upd: switch to tail poll for better handling of deleted log files + # v1.0.0-beta.1 * UPDATE - stream tag only release