@@ -39,6 +39,12 @@ type jszCollector struct {
39
39
maxMemory * prometheus.Desc
40
40
maxStorage * prometheus.Desc
41
41
42
+ // Account stats
43
+ maxAccountMemory * prometheus.Desc
44
+ maxAccountStorage * prometheus.Desc
45
+ accountStorage * prometheus.Desc
46
+ accountMemory * prometheus.Desc
47
+
42
48
// Stream stats
43
49
streamMessages * prometheus.Desc
44
50
streamBytes * prometheus.Desc
@@ -74,6 +80,11 @@ func newJszCollector(system, endpoint string, servers []*CollectedServer) promet
74
80
streamLabels = append (streamLabels , "is_stream_leader" )
75
81
streamLabels = append (streamLabels , "stream_raft_group" )
76
82
83
+ var accountLabels []string
84
+ accountLabels = append (accountLabels , serverLabels ... )
85
+ accountLabels = append (accountLabels , "account" )
86
+ accountLabels = append (accountLabels , "account_id" )
87
+
77
88
var consumerLabels []string
78
89
consumerLabels = append (consumerLabels , streamLabels ... )
79
90
consumerLabels = append (consumerLabels , "consumer_name" )
@@ -135,6 +146,34 @@ func newJszCollector(system, endpoint string, servers []*CollectedServer) promet
135
146
serverLabels ,
136
147
nil ,
137
148
),
149
+ // jetstream_account_max_memory
150
+ maxAccountMemory : prometheus .NewDesc (
151
+ prometheus .BuildFQName (system , "account" , "max_memory" ),
152
+ "JetStream Account Max Memory in bytes" ,
153
+ accountLabels ,
154
+ nil ,
155
+ ),
156
+ // jetstream_account_max_storage
157
+ maxAccountStorage : prometheus .NewDesc (
158
+ prometheus .BuildFQName (system , "account" , "max_storage" ),
159
+ "JetStream Account Max Storage in bytes" ,
160
+ accountLabels ,
161
+ nil ,
162
+ ),
163
+ // jetstream_account_storage_used
164
+ accountStorage : prometheus .NewDesc (
165
+ prometheus .BuildFQName (system , "account" , "storage_used" ),
166
+ "Total number of bytes used by JetStream storage" ,
167
+ accountLabels ,
168
+ nil ,
169
+ ),
170
+ // jetstream_account_memory_used
171
+ accountMemory : prometheus .NewDesc (
172
+ prometheus .BuildFQName (system , "account" , "memory_used" ),
173
+ "Total number of bytes used by JetStream memory" ,
174
+ accountLabels ,
175
+ nil ,
176
+ ),
138
177
// jetstream_stream_total_messages
139
178
streamMessages : prometheus .NewDesc (
140
179
prometheus .BuildFQName (system , "stream" , "total_messages" ),
@@ -340,6 +379,20 @@ func (nc *jszCollector) Collect(ch chan<- prometheus.Metric) {
340
379
for _ , account := range resp .AccountDetails {
341
380
accountName = account .Name
342
381
accountID = account .Id
382
+
383
+ accountMetric := func (key * prometheus.Desc , value float64 ) prometheus.Metric {
384
+ return prometheus .MustNewConstMetric (key , prometheus .GaugeValue , value ,
385
+ // Server Labels
386
+ serverID , serverName , clusterName , jsDomain , clusterLeader , isMetaLeader ,
387
+ // Account Labels
388
+ accountName , accountID )
389
+ }
390
+
391
+ ch <- accountMetric (nc .maxAccountStorage , float64 (account .ReservedStore ))
392
+ ch <- accountMetric (nc .maxAccountMemory , float64 (account .ReservedMemory ))
393
+ ch <- accountMetric (nc .accountStorage , float64 (account .Store ))
394
+ ch <- accountMetric (nc .accountMemory , float64 (account .Memory ))
395
+
343
396
for _ , stream := range account .Streams {
344
397
streamName = stream .Name
345
398
if stream .Cluster != nil {
0 commit comments