-
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
Some improvment in mesos input plugin, #1572
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7db4c34
Some improvment in mesos input plugin,
tuier 2dc259f
typo, replacing cpus_total with elected to determine leader
tuier 140d065
Remove remaining statistics_ from sample
tuier 4a315f0
using timestamp from mesos as metric timestamp
tuier 3edeae4
change mesos-tasks to mesos_tasks, measurement
tuier d63d62c
change measurement name in test
tuier 26d89f9
Replace follower by standby
tuier 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,7 +116,7 @@ func (m *Mesos) Gather(acc telegraf.Accumulator) error { | |
for _, v := range m.Slaves { | ||
wg.Add(1) | ||
go func(c string) { | ||
errorChannel <- m.gatherMainMetrics(c, ":5051", MASTER, acc) | ||
errorChannel <- m.gatherMainMetrics(c, ":5051", SLAVE, acc) | ||
wg.Done() | ||
return | ||
}(v) | ||
|
@@ -420,8 +420,15 @@ var client = &http.Client{ | |
Timeout: time.Duration(4 * time.Second), | ||
} | ||
|
||
// TaskStats struct for JSON API output /monitor/statistics | ||
type TaskStats struct { | ||
ExecutorID string `json:"executor_id"` | ||
FrameworkID string `json:"framework_id"` | ||
Statistics map[string]interface{} `json:"statistics"` | ||
} | ||
|
||
func (m *Mesos) gatherSlaveTaskMetrics(address string, defaultPort string, acc telegraf.Accumulator) error { | ||
var metrics []map[string]interface{} | ||
var metrics []TaskStats | ||
|
||
host, _, err := net.SplitHostPort(address) | ||
if err != nil { | ||
|
@@ -452,16 +459,18 @@ func (m *Mesos) gatherSlaveTaskMetrics(address string, defaultPort string, acc t | |
} | ||
|
||
for _, task := range metrics { | ||
tags["task_id"] = task["executor_id"].(string) | ||
tags["task_id"] = task.ExecutorID | ||
tags["framework_id"] = task.FrameworkID | ||
|
||
jf := jsonparser.JSONFlattener{} | ||
err = jf.FlattenJSON("", task) | ||
err = jf.FlattenJSON("", task.Statistics) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
timestamp := time.Unix(int64(jf.Fields["timestamp"].(float64)), 0) | ||
|
||
acc.AddFields("mesos-tasks", jf.Fields, tags) | ||
acc.AddFields("mesos_tasks", jf.Fields, tags, timestamp) | ||
} | ||
|
||
return nil | ||
|
@@ -510,6 +519,14 @@ func (m *Mesos) gatherMainMetrics(a string, defaultPort string, role Role, acc t | |
return err | ||
} | ||
|
||
if role == MASTER { | ||
if jf.Fields["master/elected"] != 0.0 { | ||
tags["state"] = "leader" | ||
} else { | ||
tags["state"] = "standby" | ||
} | ||
} | ||
|
||
acc.AddFields("mesos", jf.Fields, tags) | ||
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. I've just noticed that slave metrics have timestamp which we can use to pass as fourth parameter to |
||
|
||
return nil | ||
|
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
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.
Good catch! 👍