-
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
Changes from 1 commit
7db4c34
2dc259f
140d065
4a315f0
3edeae4
d63d62c
26d89f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) | ||
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. Good catch! 👍 |
||
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"` | ||
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 think |
||
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,10 +459,11 @@ 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 | ||
|
@@ -510,6 +518,14 @@ func (m *Mesos) gatherMainMetrics(a string, defaultPort string, role Role, acc t | |
return err | ||
} | ||
|
||
if role == MASTER { | ||
if jf.Fields["master/cpus_total"] != 0.0 { | ||
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. Can we use |
||
tags["state"] = "leader" | ||
} else { | ||
tags["state"] = "follower" | ||
} | ||
} | ||
|
||
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 | ||
|
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.
Here and below there are still some
statistics_
prefixes left intact.