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
6648c101
Commit
6648c101
authored
8 years ago
by
Cameron Sparr
Browse files
Options
Downloads
Patches
Plain Diff
Add configurable timeout to influxdb input
closes #1773
parent
8d328552
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+2
-1
2 additions, 1 deletion
CHANGELOG.md
plugins/inputs/influxdb/influxdb.go
+22
-11
22 additions, 11 deletions
plugins/inputs/influxdb/influxdb.go
with
24 additions
and
12 deletions
CHANGELOG.md
+
2
−
1
View file @
6648c101
...
...
@@ -34,7 +34,8 @@
### Bugfixes
-
[
#1775
](
https://github.com/influxdata/telegraf/issues/1775
)
: Prometheus output: Fix bug with multi-batch writes.
-
[
#1738
](
https://github.com/influxdata/telegraf/issues/1738
)
: Fix unmarshal of influxdb metrics with null tags
-
[
#1738
](
https://github.com/influxdata/telegraf/issues/1738
)
: Fix unmarshal of influxdb metrics with null tags.
-
[
#1773
](
https://github.com/influxdata/telegraf/issues/1773
)
: Add configurable timeout to influxdb input plugin.
## v1.0 [2016-09-08]
...
...
This diff is collapsed.
Click to expand it.
plugins/inputs/influxdb/influxdb.go
+
22
−
11
View file @
6648c101
...
...
@@ -10,11 +10,16 @@ import (
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/inputs"
)
type
InfluxDB
struct
{
URLs
[]
string
`toml:"urls"`
Timeout
internal
.
Duration
client
*
http
.
Client
}
func
(
*
InfluxDB
)
Description
()
string
{
...
...
@@ -32,6 +37,9 @@ func (*InfluxDB) SampleConfig() string {
urls = [
"http://localhost:8086/debug/vars"
]
## http request & header timeout
timeout = "5s"
`
}
...
...
@@ -39,6 +47,16 @@ func (i *InfluxDB) Gather(acc telegraf.Accumulator) error {
if
len
(
i
.
URLs
)
==
0
{
i
.
URLs
=
[]
string
{
"http://localhost:8086/debug/vars"
}
}
if
i
.
client
==
nil
{
i
.
client
=
&
http
.
Client
{
Transport
:
&
http
.
Transport
{
ResponseHeaderTimeout
:
i
.
Timeout
.
Duration
,
},
Timeout
:
i
.
Timeout
.
Duration
,
}
}
errorChannel
:=
make
(
chan
error
,
len
(
i
.
URLs
))
var
wg
sync
.
WaitGroup
...
...
@@ -104,15 +122,6 @@ type memstats struct {
GCCPUFraction
float64
`json:"GCCPUFraction"`
}
var
tr
=
&
http
.
Transport
{
ResponseHeaderTimeout
:
time
.
Duration
(
3
*
time
.
Second
),
}
var
client
=
&
http
.
Client
{
Transport
:
tr
,
Timeout
:
time
.
Duration
(
4
*
time
.
Second
),
}
// Gathers data from a particular URL
// Parameters:
// acc : The telegraf Accumulator to use
...
...
@@ -127,7 +136,7 @@ func (i *InfluxDB) gatherURL(
shardCounter
:=
0
now
:=
time
.
Now
()
resp
,
err
:=
client
.
Get
(
url
)
resp
,
err
:=
i
.
client
.
Get
(
url
)
if
err
!=
nil
{
return
err
}
...
...
@@ -248,6 +257,8 @@ func (i *InfluxDB) gatherURL(
func
init
()
{
inputs
.
Add
(
"influxdb"
,
func
()
telegraf
.
Input
{
return
&
InfluxDB
{}
return
&
InfluxDB
{
Timeout
:
internal
.
Duration
{
Duration
:
time
.
Second
*
5
},
}
})
}
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