Log apps metrics.
This commit is contained in:
parent
a047bb7319
commit
cd995c9638
|
@ -20,8 +20,8 @@ type StatsServer struct {
|
|||
|
||||
type Worker struct {
|
||||
// Tags
|
||||
Id int `json:"id"`
|
||||
Pid int `json:"pid"`
|
||||
WorkerId int `json:"id"`
|
||||
Pid int `json:"pid"`
|
||||
|
||||
// Fields
|
||||
Accepting int `json:"accepting"`
|
||||
|
@ -38,4 +38,19 @@ type Worker struct {
|
|||
RespawnCount int `json:"respawn_count"`
|
||||
Tx int `json:"tx"`
|
||||
AvgRt int `json:"avg_rt"`
|
||||
|
||||
Apps []*App `json:"apps"`
|
||||
}
|
||||
|
||||
type App struct {
|
||||
// Tags
|
||||
AppId int `json:"id"`
|
||||
MountPoint string `json:"mountpoint"`
|
||||
Chdir string `json:"chdir"`
|
||||
|
||||
// Fields
|
||||
Modifier1 int `json:"modifier1"`
|
||||
Requests int `json:"requests"`
|
||||
StartupTime int `json:"startup_time"`
|
||||
Exceptions int `json:"exceptions"`
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ func (u *Uwsgi) gatherServer(acc telegraf.Accumulator, url *url.URL) error {
|
|||
|
||||
u.gatherStatServer(acc, &s)
|
||||
u.gatherWorkers(acc, &s)
|
||||
u.gatherApps(acc, &s)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -113,9 +114,9 @@ func (u *Uwsgi) gatherWorkers(acc telegraf.Accumulator, s *StatsServer) error {
|
|||
"avg_rt": w.AvgRt,
|
||||
}
|
||||
tags := map[string]string{
|
||||
"id": strconv.Itoa(w.Id),
|
||||
"url": s.Url,
|
||||
"pid": strconv.Itoa(w.Pid),
|
||||
"worker_id": strconv.Itoa(w.WorkerId),
|
||||
"url": s.Url,
|
||||
"pid": strconv.Itoa(w.Pid),
|
||||
}
|
||||
|
||||
acc.AddFields("uwsgi_workers", fields, tags)
|
||||
|
@ -124,6 +125,28 @@ func (u *Uwsgi) gatherWorkers(acc telegraf.Accumulator, s *StatsServer) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (u *Uwsgi) gatherApps(acc telegraf.Accumulator, s *StatsServer) error {
|
||||
for _, w := range s.Workers {
|
||||
for _, a := range w.Apps {
|
||||
fields := map[string]interface{}{
|
||||
"modifier1": a.Modifier1,
|
||||
"requests": a.Requests,
|
||||
"startup_time": a.StartupTime,
|
||||
"exceptions": a.Exceptions,
|
||||
}
|
||||
tags := map[string]string{
|
||||
"app_id": strconv.Itoa(a.AppId),
|
||||
"worker_id": strconv.Itoa(w.WorkerId),
|
||||
"mountpoint": a.MountPoint,
|
||||
"chdir": a.Chdir,
|
||||
}
|
||||
acc.AddFields("uwsgi_apps", fields, tags)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
inputs.Add("uwsgi", func() telegraf.Input { return &Uwsgi{} })
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue