diff --git a/collector/jsz.go b/collector/jsz.go index ff3699e..921b830 100644 --- a/collector/jsz.go +++ b/collector/jsz.go @@ -39,6 +39,11 @@ type jszCollector struct { maxMemory *prometheus.Desc maxStorage *prometheus.Desc + // Account stats + maxAccountMemory *prometheus.Desc + maxAccountStorage *prometheus.Desc + accountStorage *prometheus.Desc + // Stream stats streamMessages *prometheus.Desc streamBytes *prometheus.Desc @@ -74,6 +79,11 @@ func newJszCollector(system, endpoint string, servers []*CollectedServer) promet streamLabels = append(streamLabels, "is_stream_leader") streamLabels = append(streamLabels, "stream_raft_group") + var accountLabels []string + accountLabels = append(accountLabels, serverLabels...) + accountLabels = append(accountLabels, "account") + accountLabels = append(accountLabels, "account_id") + var consumerLabels []string consumerLabels = append(consumerLabels, streamLabels...) consumerLabels = append(consumerLabels, "consumer_name") @@ -135,6 +145,29 @@ func newJszCollector(system, endpoint string, servers []*CollectedServer) promet serverLabels, nil, ), + // jetstream_account_max_memory + maxAccountMemory: prometheus.NewDesc( + prometheus.BuildFQName(system, "account", "max_memory"), + "JetStream Account Max Memory in bytes", + accountLabels, + nil, + ), + + // jetstream_account_max_storage + maxAccountStorage: prometheus.NewDesc( + prometheus.BuildFQName(system, "account", "max_storage"), + "JetStream Account Max Storage in bytes", + accountLabels, + nil, + ), + + // jetstream_account_total_bytes + accountStorage: prometheus.NewDesc( + prometheus.BuildFQName(system, "account", "total_bytes"), + "Total number of bytes stored in JetStream account", + accountLabels, + nil, + ), // jetstream_stream_total_messages streamMessages: prometheus.NewDesc( prometheus.BuildFQName(system, "stream", "total_messages"), @@ -340,6 +373,19 @@ func (nc *jszCollector) Collect(ch chan<- prometheus.Metric) { for _, account := range resp.AccountDetails { accountName = account.Name accountID = account.Id + + accountMetric := func(key *prometheus.Desc, value float64) prometheus.Metric { + return prometheus.MustNewConstMetric(key, prometheus.GaugeValue, value, + // Server Labels + serverID, serverName, clusterName, jsDomain, clusterLeader, isMetaLeader, + // Account Labels + accountName, accountID) + } + + ch <- accountMetric(nc.maxAccountStorage, float64(account.ReservedStore)) + ch <- accountMetric(nc.maxAccountMemory, float64(account.ReservedMemory)) + ch <- accountMetric(nc.accountStorage, float64(account.Store)) + for _, stream := range account.Streams { streamName = stream.Name if stream.Cluster != nil {