feat(bolt): add metrics for influxdb buckets stored in boltdb
parent
49782c3be4
commit
8082c64556
|
|
@ -13,6 +13,11 @@ var (
|
|||
"Number of total organizations on the server",
|
||||
nil, nil)
|
||||
|
||||
bucketsDesc = prometheus.NewDesc(
|
||||
"influxdb_buckets_total",
|
||||
"Number of total buckets on the server",
|
||||
nil, nil)
|
||||
|
||||
usersDesc = prometheus.NewDesc(
|
||||
"influxdb_users_total",
|
||||
"Number of total users on the server",
|
||||
|
|
@ -42,6 +47,7 @@ var (
|
|||
// Describe returns all descriptions of the collector.
|
||||
func (c *Client) Describe(ch chan<- *prometheus.Desc) {
|
||||
ch <- orgsDesc
|
||||
ch <- bucketsDesc
|
||||
ch <- usersDesc
|
||||
ch <- tokensDesc
|
||||
ch <- dashboardsDesc
|
||||
|
|
@ -66,9 +72,10 @@ func (c *Client) Collect(ch chan<- prometheus.Metric) {
|
|||
prometheus.CounterValue,
|
||||
float64(writes),
|
||||
)
|
||||
orgs, users, tokens, dashboards := 0, 0, 0, 0
|
||||
orgs, buckets, users, tokens, dashboards := 0, 0, 0, 0, 0
|
||||
_ = c.db.View(func(tx *bolt.Tx) error {
|
||||
orgs = tx.Bucket(organizationBucket).Stats().KeyN
|
||||
buckets = tx.Bucket(bucketBucket).Stats().KeyN
|
||||
users = tx.Bucket(userBucket).Stats().KeyN
|
||||
tokens = tx.Bucket(authorizationBucket).Stats().KeyN
|
||||
dashboards = tx.Bucket(dashboardBucket).Stats().KeyN
|
||||
|
|
@ -81,6 +88,12 @@ func (c *Client) Collect(ch chan<- prometheus.Metric) {
|
|||
float64(orgs),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
bucketsDesc,
|
||||
prometheus.CounterValue,
|
||||
float64(buckets),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
usersDesc,
|
||||
prometheus.CounterValue,
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ func TestInitialMetrics(t *testing.T) {
|
|||
|
||||
metrics := map[string]int{
|
||||
"influxdb_organizations_total": 0,
|
||||
"influxdb_buckets_total": 0,
|
||||
"influxdb_users_total": 0,
|
||||
"influxdb_tokens_total": 0,
|
||||
"influxdb_dashboards_total": 0,
|
||||
|
|
@ -71,6 +72,7 @@ func TestMetrics_Onboarding(t *testing.T) {
|
|||
|
||||
metrics := map[string]int{
|
||||
"influxdb_organizations_total": 1,
|
||||
"influxdb_buckets_total": 1,
|
||||
"influxdb_users_total": 1,
|
||||
"influxdb_tokens_total": 1,
|
||||
"influxdb_dashboards_total": 1,
|
||||
|
|
|
|||
Loading…
Reference in New Issue