@@ -39,6 +39,11 @@ 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
+
42
47
// Stream stats
43
48
streamMessages * prometheus.Desc
44
49
streamBytes * prometheus.Desc
@@ -74,6 +79,11 @@ func newJszCollector(system, endpoint string, servers []*CollectedServer) promet
74
79
streamLabels = append (streamLabels , "is_stream_leader" )
75
80
streamLabels = append (streamLabels , "stream_raft_group" )
76
81
82
+ var accountLabels []string
83
+ accountLabels = append (accountLabels , serverLabels ... )
84
+ accountLabels = append (accountLabels , "account" )
85
+ accountLabels = append (accountLabels , "account_id" )
86
+
77
87
var consumerLabels []string
78
88
consumerLabels = append (consumerLabels , streamLabels ... )
79
89
consumerLabels = append (consumerLabels , "consumer_name" )
@@ -135,6 +145,29 @@ func newJszCollector(system, endpoint string, servers []*CollectedServer) promet
135
145
serverLabels ,
136
146
nil ,
137
147
),
148
+ // jetstream_account_max_memory
149
+ maxAccountMemory : prometheus .NewDesc (
150
+ prometheus .BuildFQName (system , "account" , "max_memory" ),
151
+ "JetStream Account Max Memory in bytes" ,
152
+ accountLabels ,
153
+ nil ,
154
+ ),
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
+
164
+ // jetstream_account_total_bytes
165
+ accountStorage : prometheus .NewDesc (
166
+ prometheus .BuildFQName (system , "account" , "total_bytes" ),
167
+ "Total number of bytes stored in JetStream account" ,
168
+ accountLabels ,
169
+ nil ,
170
+ ),
138
171
// jetstream_stream_total_messages
139
172
streamMessages : prometheus .NewDesc (
140
173
prometheus .BuildFQName (system , "stream" , "total_messages" ),
@@ -340,6 +373,19 @@ func (nc *jszCollector) Collect(ch chan<- prometheus.Metric) {
340
373
for _ , account := range resp .AccountDetails {
341
374
accountName = account .Name
342
375
accountID = account .Id
376
+
377
+ accountMetric := func (key * prometheus.Desc , value float64 ) prometheus.Metric {
378
+ return prometheus .MustNewConstMetric (key , prometheus .GaugeValue , value ,
379
+ // Server Labels
380
+ serverID , serverName , clusterName , jsDomain , clusterLeader , isMetaLeader ,
381
+ // Account Labels
382
+ accountName , accountID )
383
+ }
384
+
385
+ ch <- accountMetric (nc .maxAccountStorage , float64 (account .ReservedStore ))
386
+ ch <- accountMetric (nc .maxAccountMemory , float64 (account .ReservedMemory ))
387
+ ch <- accountMetric (nc .accountStorage , float64 (account .Store ))
388
+
343
389
for _ , stream := range account .Streams {
344
390
streamName = stream .Name
345
391
if stream .Cluster != nil {
0 commit comments