Skip to content

Commit

Permalink
Add an account_id label in prometheus metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
albinou committed Jan 30, 2023
1 parent 41e4a7e commit c6ff6e6
Showing 1 changed file with 5 additions and 2 deletions.
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

0 comments on commit c6ff6e6

Please sign in to comment.