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 an account_id label in prometheus metrics #204

Merged
merged 1 commit into from
Feb 2, 2023
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
7 changes: 5 additions & 2 deletions collector/jsz.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func newJszCollector(system, endpoint string, servers []*CollectedServer) promet
var streamLabels []string
streamLabels = append(streamLabels, serverLabels...)
streamLabels = append(streamLabels, "account")
streamLabels = append(streamLabels, "account_id")
streamLabels = append(streamLabels, "stream_name")
streamLabels = append(streamLabels, "stream_leader")
streamLabels = append(streamLabels, "is_stream_leader")
Expand Down Expand Up @@ -292,6 +293,7 @@ func (nc *jszCollector) Collect(ch chan<- prometheus.Metric) {
var consumerName, consumerDesc, consumerLeader string
var isMetaLeader, isStreamLeader, isConsumerLeader string
var accountName string
var accountId string

serverID = server.ID
serverName = varz.Name
Expand Down Expand Up @@ -327,6 +329,7 @@ func (nc *jszCollector) Collect(ch chan<- prometheus.Metric) {

for _, account := range resp.AccountDetails {
accountName = account.Name
accountId = account.Id
for _, stream := range account.Streams {
streamName = stream.Name
if stream.Cluster != nil {
Expand All @@ -344,7 +347,7 @@ func (nc *jszCollector) Collect(ch chan<- prometheus.Metric) {
// Server Labels
serverID, serverName, clusterName, jsDomain, clusterLeader, isMetaLeader,
// Stream Labels
accountName, streamName, streamLeader, isStreamLeader)
accountName, accountId, streamName, streamLeader, isStreamLeader)
}
ch <- streamMetric(nc.streamMessages, float64(stream.State.Msgs))
ch <- streamMetric(nc.streamBytes, float64(stream.State.Bytes))
Expand Down Expand Up @@ -373,7 +376,7 @@ func (nc *jszCollector) Collect(ch chan<- prometheus.Metric) {
// Server Labels
serverID, serverName, clusterName, jsDomain, clusterLeader, isMetaLeader,
// Stream Labels
accountName, streamName, streamLeader, isStreamLeader,
accountName, accountId, streamName, streamLeader, isStreamLeader,
// Consumer Labels
consumerName, consumerLeader, isConsumerLeader, consumerDesc,
)
Expand Down