-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emqtt batch output #4094
Merged
Merged
Emqtt batch output #4094
Changes from 4 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
c8b3f7a
Adds code to batch messages sent on a topic in a flush interval
jvrahav 3cd8a34
Adds code to batch messages sent on a topic in a flush interval
jvrahav df6fea7
modified telegraf configuration file entry
jvrahav 821f5c6
formatted code
jvrahav ea98635
Ignore UTF8 BOM in JSON parser (#4099)
dmeiners88 468ff6f
Update changelog
danielnelson f957ca6
Update gopsutil version
danielnelson 96146a7
Clarify max_retry option in kafka output
danielnelson 7724344
Fix grammar
danielnelson 7b14329
Remove -i flag from `make telegraf`
danielnelson 7e2f219
Move usage string to internal to fix `go run`
danielnelson 8df34fe
Fix platform not supported error in build.py (#4102)
otherpirate a529da0
Fix name_override example in mysql rreadme (#4100)
nsteinmetz 7845d10
Only lowercase mysql slave metrics with metric_version = 2
danielnelson a863b3e
Update kafka readme
danielnelson 5bb797e
Simplify testing with TLS (#4095)
danielnelson 403b515
Add SerializeBatch method to the Serializer interface (#4107)
danielnelson 6875f34
Update changelog
danielnelson 77ae07b
Add topk processor plugin (#4096)
mirath 3f09c69
Update changelog
danielnelson 5f1fafd
Update issue templates (#4116)
danielnelson e2e6fe0
Remove combined issue template
danielnelson eb15ece
Add cursor metrics to mongodb input (#4114)
grubernaut e5216d3
Update changelog
danielnelson 5c9c40f
Run apt-get update in release.sh
danielnelson 9611788
Don't report 0ms on timeout in dns_query (#4118)
danielnelson d43acc1
Update changelog
danielnelson ad9dfdf
Add instructions on how to repair windows performance counters
danielnelson 9b0e011
Add uint/bool support to cratedb output (#4117)
danielnelson 814bf15
Update changelog
danielnelson e3cabe3
Skip fields that report "not supported" in nvidia-smi (#4123)
danielnelson c3bad9d
Add tag/integer pair for result to net_response (#3455)
morfien101 9a0fc78
Use result and result_code in net_response
danielnelson 7ec960e
Update changelog
danielnelson ad40c58
Clarify max_retry option in kafka output
danielnelson 0b0d466
Fix grammar
danielnelson 10128c5
Update kafka readme
danielnelson b1db50f
Add tag/integer pair for result to net_response (#3455)
morfien101 322dfa2
Use result and result_code in net_response
danielnelson 509d5e1
Merge branch 'master' into emqtt-batch-output
jvrahav 64ad442
Modifies emqtt to use SerializeBatch for batch mode of operation
jvrahav 150b344
removed serializeBatchMetric as we need to process each metric at a time
jvrahav 95ac23e
removed serializeBatchMetric as we need to process each metric at a time
jvrahav 266cdad
removed serializeBatchMetric as we need to process each metric at a time
jvrahav 8e2a408
updated Readme
jvrahav f6d067f
modified code to use serializeBatch method for all metrics
jvrahav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,14 +47,15 @@ var sampleConfig = ` | |
` | ||
|
||
type MQTT struct { | ||
Servers []string `toml:"servers"` | ||
Username string | ||
Password string | ||
Database string | ||
Timeout internal.Duration | ||
TopicPrefix string | ||
QoS int `toml:"qos"` | ||
ClientID string `toml:"client_id"` | ||
Servers []string `toml:"servers"` | ||
Username string | ||
Password string | ||
Database string | ||
Timeout internal.Duration | ||
TopicPrefix string | ||
QoS int `toml:"qos"` | ||
ClientID string `toml:"client_id"` | ||
BatchMessage bool `toml:"batch"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add documentation for the new option into the |
||
|
||
// Path to CA file | ||
SSLCA string `toml:"ssl_ca"` | ||
|
@@ -124,6 +125,8 @@ func (m *MQTT) Write(metrics []telegraf.Metric) error { | |
hostname = "" | ||
} | ||
|
||
metricsmap := make(map[string][]byte) | ||
|
||
for _, metric := range metrics { | ||
var t []string | ||
if m.TopicPrefix != "" { | ||
|
@@ -141,7 +144,18 @@ func (m *MQTT) Write(metrics []telegraf.Metric) error { | |
return err | ||
} | ||
|
||
err = m.publish(topic, buf) | ||
if m.BatchMessage { | ||
metricsmap[topic] = append(metricsmap[topic], buf...) | ||
} else { | ||
err = m.publish(topic, buf) | ||
if err != nil { | ||
return fmt.Errorf("Could not write to MQTT server, %s", err) | ||
} | ||
} | ||
} | ||
|
||
for key := range metricsmap { | ||
err := m.publish(key, metricsmap[key]) | ||
if err != nil { | ||
return fmt.Errorf("Could not write to MQTT server, %s", err) | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this file, I'll generate the telegraf.conf later from the sample configurations.