Compare commits

...

5 Commits

Author SHA1 Message Date
Daniel Nelson
9253f6fecb Telegraf 1.6.0 2018-04-16 12:15:24 -07:00
Daniel Nelson
754a95713b Set 1.6 release date in changelog
(cherry picked from commit 04ab9a4fe4)
2018-04-16 12:14:11 -07:00
Daniel Nelson
8596a5c573 Fix HashID conflicts in pathological cases
Use "\n" as delimiter as it cannot occur in the series name.

(cherry picked from commit e4009234e9)
2018-04-12 18:12:41 -07:00
Daniel Nelson
19873298b8 Update changelog
(cherry picked from commit 10c7324d74)
2018-04-10 18:18:40 -07:00
Daniel Nelson
787fca496f Allow grok pattern to contain newlines (#4005)
(cherry picked from commit 55cfc383f3)
2018-04-10 18:16:59 -07:00
5 changed files with 44 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
## v1.6 [unreleased]
## v1.6 [2018-04-16]
### Release Notes
@@ -107,6 +107,7 @@
- [#3754](https://github.com/influxdata/telegraf/issues/3754): Fix precision truncation when no timestamp included.
- [#3655](https://github.com/influxdata/telegraf/issues/3655): Fix SNMPv3 connection with Cisco ASA 5515 in snmp input.
- [#3981](https://github.com/influxdata/telegraf/pull/3981): Export all vars defined in /etc/default/telegraf.
- [#4004](https://github.com/influxdata/telegraf/issues/4004): Allow grok pattern to contain newlines.
## v1.5.3 [2018-03-14]

View File

@@ -232,9 +232,12 @@ func (m *metric) IsAggregate() bool {
func (m *metric) HashID() uint64 {
h := fnv.New64a()
h.Write([]byte(m.name))
h.Write([]byte("\n"))
for _, tag := range m.tags {
h.Write([]byte(tag.Key))
h.Write([]byte("\n"))
h.Write([]byte(tag.Value))
h.Write([]byte("\n"))
}
return h.Sum64()
}

View File

@@ -267,6 +267,32 @@ func TestHashID_Consistency(t *testing.T) {
assert.Equal(t, m2.HashID(), m3.HashID())
}
func TestHashID_Delimiting(t *testing.T) {
m1, _ := New(
"cpu",
map[string]string{
"a": "x",
"b": "y",
"c": "z",
},
map[string]interface{}{
"value": float64(1),
},
time.Now(),
)
m2, _ := New(
"cpu",
map[string]string{
"a": "xbycz",
},
map[string]interface{}{
"value": float64(1),
},
time.Now(),
)
assert.NotEqual(t, m1.HashID(), m2.HashID())
}
func TestSetName(t *testing.T) {
m := baseMetric()
m.SetName("foo")

View File

@@ -132,6 +132,7 @@ func (p *Parser) Compile() error {
// "custom patterns"
p.namedPatterns = make([]string, 0, len(p.Patterns))
for i, pattern := range p.Patterns {
pattern = strings.TrimSpace(pattern)
if pattern == "" {
continue
}

View File

@@ -958,3 +958,15 @@ func TestTimezoneLocalCompileFileAndParse(t *testing.T) {
assert.Equal(t, map[string]string{}, metricB.Tags())
assert.Equal(t, time.Date(2016, time.June, 4, 12, 41, 45, 0, time.Local).UnixNano(), metricB.Time().UnixNano())
}
func TestNewlineInPatterns(t *testing.T) {
p := &Parser{
Patterns: []string{`
%{SYSLOGTIMESTAMP:timestamp}
`},
}
require.NoError(t, p.Compile())
m, err := p.ParseLine("Apr 10 05:11:57")
require.NoError(t, err)
require.NotNil(t, m)
}