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

Add stream_raft_group #319

Merged
merged 1 commit into from
Nov 18, 2024
Merged
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
11 changes: 7 additions & 4 deletions collector/jsz.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func newJszCollector(system, endpoint string, servers []*CollectedServer) promet
streamLabels = append(streamLabels, "stream_name")
streamLabels = append(streamLabels, "stream_leader")
streamLabels = append(streamLabels, "is_stream_leader")
streamLabels = append(streamLabels, "stream_raft_group")

var consumerLabels []string
consumerLabels = append(consumerLabels, streamLabels...)
Expand Down Expand Up @@ -282,7 +283,7 @@ func (nc *jszCollector) Collect(ch chan<- prometheus.Metric) {
case "account", "accounts":
suffix = "/jsz?accounts=true"
case "consumer", "consumers", "all":
suffix = "/jsz?consumers=true&config=true"
suffix = "/jsz?consumers=true&config=true&raft=true"
case "stream", "streams":
suffix = "/jsz?streams=true"
default:
Expand All @@ -298,7 +299,7 @@ func (nc *jszCollector) Collect(ch chan<- prometheus.Metric) {
continue
}
var serverID, serverName, clusterName, jsDomain, clusterLeader string
var streamName, streamLeader string
var streamName, streamLeader, streamRaftGroup string
var consumerName, consumerDesc, consumerLeader string
var isMetaLeader, isStreamLeader, isConsumerLeader string
var accountName string
Expand Down Expand Up @@ -351,12 +352,14 @@ func (nc *jszCollector) Collect(ch chan<- prometheus.Metric) {
} else {
isStreamLeader = "true"
}
streamRaftGroup = stream.RaftGroup

streamMetric := func(key *prometheus.Desc, value float64) prometheus.Metric {
return prometheus.MustNewConstMetric(key, prometheus.GaugeValue, value,
// Server Labels
serverID, serverName, clusterName, jsDomain, clusterLeader, isMetaLeader,
// Stream Labels
accountName, accountID, streamName, streamLeader, isStreamLeader)
accountName, accountID, streamName, streamLeader, isStreamLeader, streamRaftGroup)
}
ch <- streamMetric(nc.streamMessages, float64(stream.State.Msgs))
ch <- streamMetric(nc.streamBytes, float64(stream.State.Bytes))
Expand Down Expand Up @@ -386,7 +389,7 @@ func (nc *jszCollector) Collect(ch chan<- prometheus.Metric) {
// Server Labels
serverID, serverName, clusterName, jsDomain, clusterLeader, isMetaLeader,
// Stream Labels
accountName, accountID, streamName, streamLeader, isStreamLeader,
accountName, accountID, streamName, streamLeader, isStreamLeader, streamRaftGroup,
// Consumer Labels
consumerName, consumerLeader, isConsumerLeader, consumerDesc,
)
Expand Down