From d5434100c742a08fd82a4986cd4ba15b59b1726d Mon Sep 17 00:00:00 2001 From: idoko Date: Thu, 12 Sep 2024 15:21:55 +0100 Subject: [PATCH 1/2] follow convention for metric name --- docker/scripts/setup-pbm.sh | 2 +- exporter/pbm_collector.go | 2 +- exporter/pbm_collector_test.go | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docker/scripts/setup-pbm.sh b/docker/scripts/setup-pbm.sh index 5dac3b7d..dcc3700f 100755 --- a/docker/scripts/setup-pbm.sh +++ b/docker/scripts/setup-pbm.sh @@ -2,7 +2,7 @@ docker exec -it --user root pbm-mongo-2-1 bash -c "chown -R mongodb /opt/backups" # PBM config fails if replica sets are not completely up, so give enough time for both replica sets and pbm agents to be up. -sleep 20 +sleep 25 docker exec pbm-mongo-2-1 bash -c "pbm config --file /etc/config/pbm.yaml" diff --git a/exporter/pbm_collector.go b/exporter/pbm_collector.go index f498349c..fc613a2b 100644 --- a/exporter/pbm_collector.go +++ b/exporter/pbm_collector.go @@ -164,7 +164,7 @@ func (p *pbmCollector) pbmBackupsMetrics(ctx context.Context, pbmClient *sdk.Cli metrics := make([]prometheus.Metric, 0, len(backupsList)) for _, backup := range backupsList { - metrics = append(metrics, createPBMMetric("backup_size", + metrics = append(metrics, createPBMMetric("backup_size_bytes", "Size of PBM backup", float64(backup.Size), map[string]string{ "opid": backup.OPID, diff --git a/exporter/pbm_collector_test.go b/exporter/pbm_collector_test.go index 5a03599b..d73101e0 100644 --- a/exporter/pbm_collector_test.go +++ b/exporter/pbm_collector_test.go @@ -63,4 +63,12 @@ func TestPBMCollector(t *testing.T) { count := testutil.CollectAndCount(c, filter...) assert.Equal(t, expectedLength, count, "PBM metrics are missing") }) + + t.Run("pbm backup size metric", func(t *testing.T) { + filter := []string{ + "mongodb_pbm_backup_size_bytes", + } + count := testutil.CollectAndCount(c, filter...) + assert.Greater(t, count, 0, "PBM metrics are missing") + }) } From fc6545171f2d0d0bdaa8f57ceab81cdebc969c88 Mon Sep 17 00:00:00 2001 From: idoko Date: Thu, 12 Sep 2024 15:43:16 +0100 Subject: [PATCH 2/2] drop sleep time bump --- docker/scripts/setup-pbm.sh | 2 +- exporter/pbm_collector_test.go | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/docker/scripts/setup-pbm.sh b/docker/scripts/setup-pbm.sh index dcc3700f..5dac3b7d 100755 --- a/docker/scripts/setup-pbm.sh +++ b/docker/scripts/setup-pbm.sh @@ -2,7 +2,7 @@ docker exec -it --user root pbm-mongo-2-1 bash -c "chown -R mongodb /opt/backups" # PBM config fails if replica sets are not completely up, so give enough time for both replica sets and pbm agents to be up. -sleep 25 +sleep 20 docker exec pbm-mongo-2-1 bash -c "pbm config --file /etc/config/pbm.yaml" diff --git a/exporter/pbm_collector_test.go b/exporter/pbm_collector_test.go index d73101e0..5a03599b 100644 --- a/exporter/pbm_collector_test.go +++ b/exporter/pbm_collector_test.go @@ -63,12 +63,4 @@ func TestPBMCollector(t *testing.T) { count := testutil.CollectAndCount(c, filter...) assert.Equal(t, expectedLength, count, "PBM metrics are missing") }) - - t.Run("pbm backup size metric", func(t *testing.T) { - filter := []string{ - "mongodb_pbm_backup_size_bytes", - } - count := testutil.CollectAndCount(c, filter...) - assert.Greater(t, count, 0, "PBM metrics are missing") - }) }