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
f74687dc
Unverified
Commit
f74687dc
authored
7 years ago
by
Sebastian Borza
Committed by
Daniel Nelson
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
split metrics based on UDPPayload size (#2795)
parent
a47aa0dc
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
plugins/outputs/influxdb/client/udp.go
+7
-3
7 additions, 3 deletions
plugins/outputs/influxdb/client/udp.go
plugins/outputs/influxdb/influxdb.go
+11
-5
11 additions, 5 deletions
plugins/outputs/influxdb/influxdb.go
with
18 additions
and
8 deletions
plugins/outputs/influxdb/client/udp.go
+
7
−
3
View file @
f74687dc
...
@@ -25,6 +25,7 @@ type UDPConfig struct {
...
@@ -25,6 +25,7 @@ type UDPConfig struct {
PayloadSize
int
PayloadSize
int
}
}
// NewUDP will return an instance of the telegraf UDP output plugin for influxdb
func
NewUDP
(
config
UDPConfig
)
(
Client
,
error
)
{
func
NewUDP
(
config
UDPConfig
)
(
Client
,
error
)
{
p
,
err
:=
url
.
Parse
(
config
.
URL
)
p
,
err
:=
url
.
Parse
(
config
.
URL
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -55,20 +56,22 @@ type udpClient struct {
...
@@ -55,20 +56,22 @@ type udpClient struct {
buffer
[]
byte
buffer
[]
byte
}
}
// Query will send the provided query command to the client, returning an error if any issues arise
func
(
c
*
udpClient
)
Query
(
command
string
)
error
{
func
(
c
*
udpClient
)
Query
(
command
string
)
error
{
return
nil
return
nil
}
}
// Write will send the byte stream to the given UDP client endpoint
func
(
c
*
udpClient
)
Write
(
b
[]
byte
)
(
int
,
error
)
{
func
(
c
*
udpClient
)
Write
(
b
[]
byte
)
(
int
,
error
)
{
return
c
.
WriteStream
(
bytes
.
NewReader
(
b
),
-
1
)
return
c
.
WriteStream
(
bytes
.
NewReader
(
b
),
-
1
)
}
}
//
w
rite
p
arams are ignored by the UDP client
//
W
rite
WithP
arams are ignored by the UDP client
, will forward to WriteStream
func
(
c
*
udpClient
)
WriteWithParams
(
b
[]
byte
,
wp
WriteParams
)
(
int
,
error
)
{
func
(
c
*
udpClient
)
WriteWithParams
(
b
[]
byte
,
wp
WriteParams
)
(
int
,
error
)
{
return
c
.
WriteStream
(
bytes
.
NewReader
(
b
),
-
1
)
return
c
.
WriteStream
(
bytes
.
NewReader
(
b
),
-
1
)
}
}
// contentLength is ignored by the UDP client
.
//
WriteStream will send the provided data through to the client,
contentLength is ignored by the UDP client
func
(
c
*
udpClient
)
WriteStream
(
r
io
.
Reader
,
contentLength
int
)
(
int
,
error
)
{
func
(
c
*
udpClient
)
WriteStream
(
r
io
.
Reader
,
contentLength
int
)
(
int
,
error
)
{
var
totaln
int
var
totaln
int
for
{
for
{
...
@@ -88,12 +91,13 @@ func (c *udpClient) WriteStream(r io.Reader, contentLength int) (int, error) {
...
@@ -88,12 +91,13 @@ func (c *udpClient) WriteStream(r io.Reader, contentLength int) (int, error) {
return
totaln
,
nil
return
totaln
,
nil
}
}
// contentLength is ignored by the UDP client
.
//
WriteStreamWithParams will forward the stream to the client backend,
contentLength is ignored by the UDP client
// write params are ignored by the UDP client
// write params are ignored by the UDP client
func
(
c
*
udpClient
)
WriteStreamWithParams
(
r
io
.
Reader
,
contentLength
int
,
wp
WriteParams
)
(
int
,
error
)
{
func
(
c
*
udpClient
)
WriteStreamWithParams
(
r
io
.
Reader
,
contentLength
int
,
wp
WriteParams
)
(
int
,
error
)
{
return
c
.
WriteStream
(
r
,
-
1
)
return
c
.
WriteStream
(
r
,
-
1
)
}
}
// Close will terminate the provided client connection
func
(
c
*
udpClient
)
Close
()
error
{
func
(
c
*
udpClient
)
Close
()
error
{
return
c
.
conn
.
Close
()
return
c
.
conn
.
Close
()
}
}
This diff is collapsed.
Click to expand it.
plugins/outputs/influxdb/influxdb.go
+
11
−
5
View file @
f74687dc
...
@@ -15,6 +15,7 @@ import (
...
@@ -15,6 +15,7 @@ import (
"github.com/influxdata/telegraf/plugins/outputs/influxdb/client"
"github.com/influxdata/telegraf/plugins/outputs/influxdb/client"
)
)
// InfluxDB struct is the primary data structure for the plugin
type
InfluxDB
struct
{
type
InfluxDB
struct
{
// URL is only for backwards compatability
// URL is only for backwards compatability
URL
string
URL
string
...
@@ -79,11 +80,10 @@ var sampleConfig = `
...
@@ -79,11 +80,10 @@ var sampleConfig = `
# insecure_skip_verify = false
# insecure_skip_verify = false
`
`
// Connect initiates the primary connection to the range of provided URLs
func
(
i
*
InfluxDB
)
Connect
()
error
{
func
(
i
*
InfluxDB
)
Connect
()
error
{
var
urls
[]
string
var
urls
[]
string
for
_
,
u
:=
range
i
.
URLs
{
urls
=
append
(
urls
,
i
.
URLs
...
)
urls
=
append
(
urls
,
u
)
}
// Backward-compatability with single Influx URL config files
// Backward-compatability with single Influx URL config files
// This could eventually be removed in favor of specifying the urls as a list
// This could eventually be removed in favor of specifying the urls as a list
...
@@ -144,26 +144,32 @@ func (i *InfluxDB) Connect() error {
...
@@ -144,26 +144,32 @@ func (i *InfluxDB) Connect() error {
return
nil
return
nil
}
}
// Close will terminate the session to the backend, returning error if an issue arises
func
(
i
*
InfluxDB
)
Close
()
error
{
func
(
i
*
InfluxDB
)
Close
()
error
{
return
nil
return
nil
}
}
// SampleConfig returns the formatted sample configuration for the plugin
func
(
i
*
InfluxDB
)
SampleConfig
()
string
{
func
(
i
*
InfluxDB
)
SampleConfig
()
string
{
return
sampleConfig
return
sampleConfig
}
}
// Description returns the human-readable function definition of the plugin
func
(
i
*
InfluxDB
)
Description
()
string
{
func
(
i
*
InfluxDB
)
Description
()
string
{
return
"Configuration for influxdb server to send metrics to"
return
"Configuration for influxdb server to send metrics to"
}
}
//
C
hoose a random server in the cluster to write to until a successful write
//
Write will c
hoose a random server in the cluster to write to until a successful write
// occurs, logging each unsuccessful. If all servers fail, return error.
// occurs, logging each unsuccessful. If all servers fail, return error.
func
(
i
*
InfluxDB
)
Write
(
metrics
[]
telegraf
.
Metric
)
error
{
func
(
i
*
InfluxDB
)
Write
(
metrics
[]
telegraf
.
Metric
)
error
{
bufsize
:=
0
bufsize
:=
0
splitData
:=
make
([]
telegraf
.
Metric
,
0
)
for
_
,
m
:=
range
metrics
{
for
_
,
m
:=
range
metrics
{
bufsize
+=
m
.
Len
()
bufsize
+=
m
.
Len
()
splitData
=
append
(
splitData
,
m
.
Split
(
i
.
UDPPayload
)
...
)
}
}
r
:=
metric
.
NewReader
(
metrics
)
r
:=
metric
.
NewReader
(
splitData
)
// This will get set to nil if a successful write occurs
// This will get set to nil if a successful write occurs
err
:=
fmt
.
Errorf
(
"Could not write to any InfluxDB server in cluster"
)
err
:=
fmt
.
Errorf
(
"Could not write to any InfluxDB server in cluster"
)
...
...
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