Skip to content
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

kafka output read/write statistic #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions collector/libbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type LibBeat struct {
Reloads float64 `json:"reloads"`
} `json:"config"`
Output LibBeatOutput `json:"output"`
Outputs LibBeatOutputs `json:"outputs"`
Pipeline LibBeatPipeline `json:"pipeline"`
}

Expand Down Expand Up @@ -45,6 +46,14 @@ type LibBeatOutput struct {
Type string `json:"type"`
}

//LibBeatOutputs json structure
type LibBeatOutputs struct {
Kafka struct {
Read float64 `json:"bytes_read"`
Write float64 `json:"bytes_write"`
} `json:"kafka"`
}

//LibBeatPipeline json structure
type LibBeatPipeline struct {
Clients float64 `json:"clients"`
Expand Down Expand Up @@ -119,7 +128,12 @@ func NewLibBeatCollector(beatInfo *BeatInfo, stats *Stats) prometheus.Collector
nil, nil,
),
eval: func(stats *Stats) float64 {
return stats.LibBeat.Output.Read.Bytes
if stats.LibBeat.Output.Type == "kafka" {
return stats.LibBeat.Outputs.Kafka.Read
} else {
return stats.LibBeat.Output.Read.Bytes
}

},
valType: prometheus.CounterValue,
},
Expand All @@ -141,7 +155,11 @@ func NewLibBeatCollector(beatInfo *BeatInfo, stats *Stats) prometheus.Collector
nil, nil,
),
eval: func(stats *Stats) float64 {
return stats.LibBeat.Output.Write.Bytes
if stats.LibBeat.Output.Type == "kafka" {
return stats.LibBeat.Outputs.Kafka.Write
} else {
return stats.LibBeat.Output.Write.Bytes
}
},
valType: prometheus.CounterValue,
},
Expand Down