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
b7d29ca0
Commit
b7d29ca0
authored
8 years ago
by
Patrick Hemmer
Committed by
Cameron Sparr
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
allow changing jolokia delimiter (#2255)
parent
947e1909
No related branches found
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/jolokia/jolokia.go
+18
-9
18 additions, 9 deletions
plugins/inputs/jolokia/jolokia.go
plugins/inputs/jolokia/jolokia_test.go
+4
-3
4 additions, 3 deletions
plugins/inputs/jolokia/jolokia_test.go
with
23 additions
and
12 deletions
CHANGELOG.md
+
1
−
0
View file @
b7d29ca0
...
@@ -44,6 +44,7 @@ plugins, not just statsd.
...
@@ -44,6 +44,7 @@ plugins, not just statsd.
-
[
#1942
](
https://github.com/influxdata/telegraf/pull/1942
)
: Change Amazon Kinesis output plugin to use the built-in serializer plugins.
-
[
#1942
](
https://github.com/influxdata/telegraf/pull/1942
)
: Change Amazon Kinesis output plugin to use the built-in serializer plugins.
-
[
#1980
](
https://github.com/influxdata/telegraf/issues/1980
)
: Hide username/password from elasticsearch error log messages.
-
[
#1980
](
https://github.com/influxdata/telegraf/issues/1980
)
: Hide username/password from elasticsearch error log messages.
-
[
#2097
](
https://github.com/influxdata/telegraf/issues/2097
)
: Configurable HTTP timeouts in Jolokia plugin
-
[
#2097
](
https://github.com/influxdata/telegraf/issues/2097
)
: Configurable HTTP timeouts in Jolokia plugin
-
[
#2255
](
https://github.com/influxdata/telegraf/pull/2255
)
: Allow changing jolokia attribute delimiter
### Bugfixes
### Bugfixes
...
...
This diff is collapsed.
Click to expand it.
plugins/inputs/jolokia/jolokia.go
+
18
−
9
View file @
b7d29ca0
...
@@ -47,12 +47,13 @@ func (c JolokiaClientImpl) MakeRequest(req *http.Request) (*http.Response, error
...
@@ -47,12 +47,13 @@ func (c JolokiaClientImpl) MakeRequest(req *http.Request) (*http.Response, error
}
}
type
Jolokia
struct
{
type
Jolokia
struct
{
jClient
JolokiaClient
jClient
JolokiaClient
Context
string
Context
string
Mode
string
Mode
string
Servers
[]
Server
Servers
[]
Server
Metrics
[]
Metric
Metrics
[]
Metric
Proxy
Server
Proxy
Server
Delimiter
string
ResponseHeaderTimeout
internal
.
Duration
`toml:"response_header_timeout"`
ResponseHeaderTimeout
internal
.
Duration
`toml:"response_header_timeout"`
ClientTimeout
internal
.
Duration
`toml:"client_timeout"`
ClientTimeout
internal
.
Duration
`toml:"client_timeout"`
...
@@ -84,6 +85,13 @@ const sampleConfig = `
...
@@ -84,6 +85,13 @@ const sampleConfig = `
## Includes connection time, any redirects, and reading the response body.
## Includes connection time, any redirects, and reading the response body.
# client_timeout = "4s"
# client_timeout = "4s"
## Attribute delimiter
##
## When multiple attributes are returned for a single
## [inputs.jolokia.metrics], the field name is a concatenation of the metric
## name, and the attribute name, separated by the given delimiter.
# delimiter = "_"
## List of servers exposing jolokia read service
## List of servers exposing jolokia read service
[[inputs.jolokia.servers]]
[[inputs.jolokia.servers]]
name = "as-server-01"
name = "as-server-01"
...
@@ -238,10 +246,10 @@ func (j *Jolokia) prepareRequest(server Server, metric Metric) (*http.Request, e
...
@@ -238,10 +246,10 @@ func (j *Jolokia) prepareRequest(server Server, metric Metric) (*http.Request, e
return
req
,
nil
return
req
,
nil
}
}
func
extractValues
(
measurement
string
,
value
interface
{},
fields
map
[
string
]
interface
{})
{
func
(
j
*
Jolokia
)
extractValues
(
measurement
string
,
value
interface
{},
fields
map
[
string
]
interface
{})
{
if
mapValues
,
ok
:=
value
.
(
map
[
string
]
interface
{});
ok
{
if
mapValues
,
ok
:=
value
.
(
map
[
string
]
interface
{});
ok
{
for
k2
,
v2
:=
range
mapValues
{
for
k2
,
v2
:=
range
mapValues
{
extractValues
(
measurement
+
"_"
+
k2
,
v2
,
fields
)
j
.
extractValues
(
measurement
+
j
.
Delimiter
+
k2
,
v2
,
fields
)
}
}
}
else
{
}
else
{
fields
[
measurement
]
=
value
fields
[
measurement
]
=
value
...
@@ -282,7 +290,7 @@ func (j *Jolokia) Gather(acc telegraf.Accumulator) error {
...
@@ -282,7 +290,7 @@ func (j *Jolokia) Gather(acc telegraf.Accumulator) error {
fmt
.
Printf
(
"Error handling response: %s
\n
"
,
err
)
fmt
.
Printf
(
"Error handling response: %s
\n
"
,
err
)
}
else
{
}
else
{
if
values
,
ok
:=
out
[
"value"
];
ok
{
if
values
,
ok
:=
out
[
"value"
];
ok
{
extractValues
(
measurement
,
values
,
fields
)
j
.
extractValues
(
measurement
,
values
,
fields
)
}
else
{
}
else
{
fmt
.
Printf
(
"Missing key 'value' in output response
\n
"
)
fmt
.
Printf
(
"Missing key 'value' in output response
\n
"
)
}
}
...
@@ -301,6 +309,7 @@ func init() {
...
@@ -301,6 +309,7 @@ func init() {
return
&
Jolokia
{
return
&
Jolokia
{
ResponseHeaderTimeout
:
DefaultResponseHeaderTimeout
,
ResponseHeaderTimeout
:
DefaultResponseHeaderTimeout
,
ClientTimeout
:
DefaultClientTimeout
,
ClientTimeout
:
DefaultClientTimeout
,
Delimiter
:
"_"
,
}
}
})
})
}
}
This diff is collapsed.
Click to expand it.
plugins/inputs/jolokia/jolokia_test.go
+
4
−
3
View file @
b7d29ca0
...
@@ -104,9 +104,10 @@ func (c jolokiaClientStub) MakeRequest(req *http.Request) (*http.Response, error
...
@@ -104,9 +104,10 @@ func (c jolokiaClientStub) MakeRequest(req *http.Request) (*http.Response, error
// *HttpJson: Pointer to an HttpJson object that uses the generated mock HTTP client
// *HttpJson: Pointer to an HttpJson object that uses the generated mock HTTP client
func
genJolokiaClientStub
(
response
string
,
statusCode
int
,
servers
[]
Server
,
metrics
[]
Metric
)
*
Jolokia
{
func
genJolokiaClientStub
(
response
string
,
statusCode
int
,
servers
[]
Server
,
metrics
[]
Metric
)
*
Jolokia
{
return
&
Jolokia
{
return
&
Jolokia
{
jClient
:
jolokiaClientStub
{
responseBody
:
response
,
statusCode
:
statusCode
},
jClient
:
jolokiaClientStub
{
responseBody
:
response
,
statusCode
:
statusCode
},
Servers
:
servers
,
Servers
:
servers
,
Metrics
:
metrics
,
Metrics
:
metrics
,
Delimiter
:
"_"
,
}
}
}
}
...
...
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