diff --git a/plugins/inputs/varnish/README.md b/plugins/inputs/varnish/README.md index 8949fe6dbd37a..6afb38f72cab1 100644 --- a/plugins/inputs/varnish/README.md +++ b/plugins/inputs/varnish/README.md @@ -21,11 +21,14 @@ This plugin gathers stats from [Varnish HTTP Cache](https://varnish-cache.org/) ## Optional name for the varnish instance (or working directory) to query ## Usually appened after -n in varnish cli # instance_name = instanceName + + ## Timeout for varnishstat command + # timeout = "1s" ``` ### Measurements & Fields: -This is the full list of stats provided by varnish. Stats will be grouped by their capitalized prefix (eg MAIN, +This is the full list of stats provided by varnish. Stats will be grouped by their capitalized prefix (eg MAIN, MEMPOOL, etc). In the output, the prefix will be used as a tag, and removed from field names. - varnish @@ -326,7 +329,7 @@ MEMPOOL, etc). In the output, the prefix will be used as a tag, and removed from ### Tags: -As indicated above, the prefix of a varnish stat will be used as it's 'section' tag. So section tag may have one of +As indicated above, the prefix of a varnish stat will be used as it's 'section' tag. So section tag may have one of the following values: - section: - MAIN @@ -335,8 +338,8 @@ the following values: - SMA - VBE - LCK - - + + ### Permissions: diff --git a/plugins/inputs/varnish/varnish_test.go b/plugins/inputs/varnish/varnish_test.go index 465e9e8dd5a50..9eb98c4511ef8 100644 --- a/plugins/inputs/varnish/varnish_test.go +++ b/plugins/inputs/varnish/varnish_test.go @@ -12,8 +12,8 @@ import ( "github.com/stretchr/testify/assert" ) -func fakeVarnishStat(output string, useSudo bool, InstanceName string) func(string, bool, string) (*bytes.Buffer, error) { - return func(string, bool, string) (*bytes.Buffer, error) { +func fakeVarnishStat(output string, useSudo bool, InstanceName string, Timeout string) func(string, bool, string, string) (*bytes.Buffer, error) { + return func(string, bool, string, string) (*bytes.Buffer, error) { return bytes.NewBuffer([]byte(output)), nil } } @@ -21,7 +21,7 @@ func fakeVarnishStat(output string, useSudo bool, InstanceName string) func(stri func TestGather(t *testing.T) { acc := &testutil.Accumulator{} v := &Varnish{ - run: fakeVarnishStat(smOutput, false, ""), + run: fakeVarnishStat(smOutput, false, "", "5s"), Stats: []string{"*"}, } v.Gather(acc) @@ -37,7 +37,7 @@ func TestGather(t *testing.T) { func TestParseFullOutput(t *testing.T) { acc := &testutil.Accumulator{} v := &Varnish{ - run: fakeVarnishStat(fullOutput, true, ""), + run: fakeVarnishStat(fullOutput, true, "", "5s"), Stats: []string{"*"}, } err := v.Gather(acc) @@ -52,7 +52,7 @@ func TestParseFullOutput(t *testing.T) { func TestFilterSomeStats(t *testing.T) { acc := &testutil.Accumulator{} v := &Varnish{ - run: fakeVarnishStat(fullOutput, false, ""), + run: fakeVarnishStat(fullOutput, false, "", "5s"), Stats: []string{"MGT.*", "VBE.*"}, } err := v.Gather(acc) @@ -75,7 +75,7 @@ func TestFieldConfig(t *testing.T) { for fieldCfg, expected := range expect { acc := &testutil.Accumulator{} v := &Varnish{ - run: fakeVarnishStat(fullOutput, true, ""), + run: fakeVarnishStat(fullOutput, true, "", "5s"), Stats: strings.Split(fieldCfg, ","), } err := v.Gather(acc) diff --git a/plugins/parsers/grok/parser_test.go b/plugins/parsers/grok/parser_test.go index e3426b0fcb85a..2a612431b376d 100644 --- a/plugins/parsers/grok/parser_test.go +++ b/plugins/parsers/grok/parser_test.go @@ -915,17 +915,17 @@ func TestSyslogTimestamp(t *testing.T) { { name: "two digit day of month", line: "Sep 25 09:01:55 value=42", - expected: time.Date(2018, time.September, 25, 9, 1, 55, 0, time.UTC), + expected: time.Date(2019, time.September, 25, 9, 1, 55, 0, time.UTC), }, { name: "one digit day of month single space", line: "Sep 2 09:01:55 value=42", - expected: time.Date(2018, time.September, 2, 9, 1, 55, 0, time.UTC), + expected: time.Date(2019, time.September, 2, 9, 1, 55, 0, time.UTC), }, { name: "one digit day of month double space", line: "Sep 2 09:01:55 value=42", - expected: time.Date(2018, time.September, 2, 9, 1, 55, 0, time.UTC), + expected: time.Date(2019, time.September, 2, 9, 1, 55, 0, time.UTC), }, } for _, tt := range tests { @@ -950,11 +950,11 @@ func TestReplaceTimestampComma(t *testing.T) { } require.NoError(t, p.Compile()) - m, err := p.ParseLine("2018-02-21 13:10:34,555 successfulMatches=1") + m, err := p.ParseLine("2019-02-21 13:10:34,555 successfulMatches=1") require.NoError(t, err) require.NotNil(t, m) - require.Equal(t, 2018, m.Time().Year()) + require.Equal(t, 2019, m.Time().Year()) require.Equal(t, 13, m.Time().Hour()) require.Equal(t, 34, m.Time().Second()) // Convert nanosecond to millisecond for compare @@ -1023,5 +1023,5 @@ func TestEmptyYearInTimestamp(t *testing.T) { m, err := p.ParseLine("Nov 6 13:57:03 generic iTunes[6504]: objc[6504]: Object descriptor was null.") require.NoError(t, err) require.NotNil(t, m) - require.Equal(t, 2018, m.Time().Year()) + require.Equal(t, 2019, m.Time().Year()) }