\#920 Log core metrics.
This commit is contained in:
parent
290fdeb283
commit
755332a458
|
@ -39,7 +39,8 @@ type Worker struct {
|
|||
Tx int `json:"tx"`
|
||||
AvgRt int `json:"avg_rt"`
|
||||
|
||||
Apps []*App `json:"apps"`
|
||||
Apps []*App `json:"apps"`
|
||||
Cores []*Core `json:"cores"`
|
||||
}
|
||||
|
||||
type App struct {
|
||||
|
@ -54,3 +55,17 @@ type App struct {
|
|||
StartupTime int `json:"startup_time"`
|
||||
Exceptions int `json:"exceptions"`
|
||||
}
|
||||
|
||||
type Core struct {
|
||||
// Tags
|
||||
CoreId int `json:"id"`
|
||||
|
||||
// Fields
|
||||
Requests int `json:"requests"`
|
||||
StaticRequests int `json:"static_requests"`
|
||||
RoutedRequests int `json:"routed_requests"`
|
||||
OffloadedRequests int `json:"offloaded_requests"`
|
||||
WriteErrors int `json:"write_errors"`
|
||||
ReadErrors int `json:"read_errors"`
|
||||
InRequest int `json:"in_request"`
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ func (u *Uwsgi) gatherURL(acc telegraf.Accumulator, url string) error {
|
|||
u.gatherStatServer(acc, &s)
|
||||
u.gatherWorkers(acc, &s)
|
||||
u.gatherApps(acc, &s)
|
||||
u.gatherCores(acc, &s)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -143,6 +144,30 @@ func (u *Uwsgi) gatherApps(acc telegraf.Accumulator, s *StatsServer) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (u *Uwsgi) gatherCores(acc telegraf.Accumulator, s *StatsServer) error {
|
||||
for _, w := range s.Workers {
|
||||
for _, c := range w.Cores {
|
||||
fields := map[string]interface{}{
|
||||
"requests": c.Requests,
|
||||
"static_requests": c.StaticRequests,
|
||||
"routed_requests": c.RoutedRequests,
|
||||
"offloaded_requests": c.OffloadedRequests,
|
||||
"write_errors": c.WriteErrors,
|
||||
"read_errors": c.ReadErrors,
|
||||
"in_request": c.InRequest,
|
||||
}
|
||||
tags := map[string]string{
|
||||
"core_id": strconv.Itoa(c.CoreId),
|
||||
"worker_id": strconv.Itoa(w.WorkerId),
|
||||
}
|
||||
acc.AddFields("uwsgi_cores", fields, tags)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
inputs.Add("uwsgi", func() telegraf.Input { return &Uwsgi{} })
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue