Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
telegraf-nftables
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Due to inactivity, this project is scheduled to be deleted on 2035-04-24.
Why is this scheduled?
Show more breadcrumbs
vqgroup
telegraf-nftables
Commits
c483e16d
Commit
c483e16d
authored
9 years ago
by
Cameron Sparr
Browse files
Options
Downloads
Patches
Plain Diff
Add option to disable statsd name conversion
closes #467 closes #532
parent
40a5bad9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
plugins/inputs/statsd/statsd.go
+11
-3
11 additions, 3 deletions
plugins/inputs/statsd/statsd.go
plugins/inputs/statsd/statsd_test.go
+58
-0
58 additions, 0 deletions
plugins/inputs/statsd/statsd_test.go
with
70 additions
and
3 deletions
CHANGELOG.md
+
1
−
0
View file @
c483e16d
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
-
[
#512
](
https://github.com/influxdata/telegraf/pull/512
)
: Python 3 build script, add lsof dep to package. Thanks @Ormod!
-
[
#512
](
https://github.com/influxdata/telegraf/pull/512
)
: Python 3 build script, add lsof dep to package. Thanks @Ormod!
-
[
#475
](
https://github.com/influxdata/telegraf/pull/475
)
: Add response time to httpjson plugin. Thanks @titilambert!
-
[
#475
](
https://github.com/influxdata/telegraf/pull/475
)
: Add response time to httpjson plugin. Thanks @titilambert!
-
[
#519
](
https://github.com/influxdata/telegraf/pull/519
)
: Added a sensors input based on lm-sensors. Thanks @md14454!
-
[
#519
](
https://github.com/influxdata/telegraf/pull/519
)
: Added a sensors input based on lm-sensors. Thanks @md14454!
-
[
#467
](
https://github.com/influxdata/telegraf/issues/467
)
: Add option to disable statsd measurement name conversion.
### Bugfixes
### Bugfixes
-
[
#506
](
https://github.com/influxdb/telegraf/pull/506
)
: Ping input doesn't return response time metric when timeout. Thanks @titilambert!
-
[
#506
](
https://github.com/influxdb/telegraf/pull/506
)
: Ping input doesn't return response time metric when timeout. Thanks @titilambert!
...
...
This diff is collapsed.
Click to expand it.
plugins/inputs/statsd/statsd.go
+
11
−
3
View file @
c483e16d
...
@@ -35,6 +35,7 @@ type Statsd struct {
...
@@ -35,6 +35,7 @@ type Statsd struct {
DeleteCounters
bool
DeleteCounters
bool
DeleteSets
bool
DeleteSets
bool
DeleteTimings
bool
DeleteTimings
bool
ConvertNames
bool
sync
.
Mutex
sync
.
Mutex
...
@@ -63,6 +64,8 @@ func NewStatsd() *Statsd {
...
@@ -63,6 +64,8 @@ func NewStatsd() *Statsd {
s
.
sets
=
make
(
map
[
string
]
cachedset
)
s
.
sets
=
make
(
map
[
string
]
cachedset
)
s
.
timings
=
make
(
map
[
string
]
cachedtimings
)
s
.
timings
=
make
(
map
[
string
]
cachedtimings
)
s
.
ConvertNames
=
true
return
&
s
return
&
s
}
}
...
@@ -121,6 +124,9 @@ const sampleConfig = `
...
@@ -121,6 +124,9 @@ const sampleConfig = `
# Percentiles to calculate for timing & histogram stats
# Percentiles to calculate for timing & histogram stats
percentiles = [90]
percentiles = [90]
# convert measurement names, "." to "_" and "-" to "__"
convert_names = true
# templates = [
# templates = [
# "cpu.* measurement*"
# "cpu.* measurement*"
# ]
# ]
...
@@ -389,8 +395,10 @@ func (s *Statsd) parseName(bucket string) (string, map[string]string) {
...
@@ -389,8 +395,10 @@ func (s *Statsd) parseName(bucket string) (string, map[string]string) {
if
err
==
nil
{
if
err
==
nil
{
name
,
tags
,
_
,
_
=
p
.
ApplyTemplate
(
name
)
name
,
tags
,
_
,
_
=
p
.
ApplyTemplate
(
name
)
}
}
name
=
strings
.
Replace
(
name
,
"."
,
"_"
,
-
1
)
if
s
.
ConvertNames
{
name
=
strings
.
Replace
(
name
,
"-"
,
"__"
,
-
1
)
name
=
strings
.
Replace
(
name
,
"."
,
"_"
,
-
1
)
name
=
strings
.
Replace
(
name
,
"-"
,
"__"
,
-
1
)
}
return
name
,
tags
return
name
,
tags
}
}
...
@@ -491,6 +499,6 @@ func (s *Statsd) Stop() {
...
@@ -491,6 +499,6 @@ func (s *Statsd) Stop() {
func
init
()
{
func
init
()
{
inputs
.
Add
(
"statsd"
,
func
()
inputs
.
Input
{
inputs
.
Add
(
"statsd"
,
func
()
inputs
.
Input
{
return
&
Statsd
{}
return
&
Statsd
{
ConvertNames
:
true
}
})
})
}
}
This diff is collapsed.
Click to expand it.
plugins/inputs/statsd/statsd_test.go
+
58
−
0
View file @
c483e16d
...
@@ -303,6 +303,64 @@ func TestParse_Tags(t *testing.T) {
...
@@ -303,6 +303,64 @@ func TestParse_Tags(t *testing.T) {
}
}
}
}
// Test that statsd buckets are parsed to measurement names properly
func
TestParseName
(
t
*
testing
.
T
)
{
s
:=
NewStatsd
()
tests
:=
[]
struct
{
in_name
string
out_name
string
}{
{
"foobar"
,
"foobar"
,
},
{
"foo.bar"
,
"foo_bar"
,
},
{
"foo.bar-baz"
,
"foo_bar__baz"
,
},
}
for
_
,
test
:=
range
tests
{
name
,
_
:=
s
.
parseName
(
test
.
in_name
)
if
name
!=
test
.
out_name
{
t
.
Errorf
(
"Expected: %s, got %s"
,
test
.
out_name
,
name
)
}
}
// Test with ConvertNames = false
s
.
ConvertNames
=
false
tests
=
[]
struct
{
in_name
string
out_name
string
}{
{
"foobar"
,
"foobar"
,
},
{
"foo.bar"
,
"foo.bar"
,
},
{
"foo.bar-baz"
,
"foo.bar-baz"
,
},
}
for
_
,
test
:=
range
tests
{
name
,
_
:=
s
.
parseName
(
test
.
in_name
)
if
name
!=
test
.
out_name
{
t
.
Errorf
(
"Expected: %s, got %s"
,
test
.
out_name
,
name
)
}
}
}
// Test that measurements with the same name, but different tags, are treated
// Test that measurements with the same name, but different tags, are treated
// as different outputs
// as different outputs
func
TestParse_MeasurementsWithSameName
(
t
*
testing
.
T
)
{
func
TestParse_MeasurementsWithSameName
(
t
*
testing
.
T
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment