From d9d956c93abdfc46bdc6f9d559ae2b7aa0e013bb Mon Sep 17 00:00:00 2001 From: Michael Okoko <10512379+idoqo@users.noreply.github.com> Date: Mon, 26 Aug 2024 22:20:21 +0100 Subject: [PATCH] PMM-10680 enable pbm collector (#3162) * PMM-12848 Enable currentopmetrics collector in mongodb_exporter. * PMM-7 fix golint. * PMM-12848 Add currentopmetrics to scrape config. * PMM-12848 collect currentopmetrics in low resolution. * PMM-12848 Fix tests. * PMM-13141 Enable fcv collector. * enable pbm exporter by default * enable pbm collector in 2.42 * move pbm collector to 2.43 * update scrape configs * revert makefile changes * drop fcv collector until it is recognized by mongodb exporter * add release note highlight for PMM-10680 * merge both new mongodb exporter collectors * enable pbm collector by default * add new note for pbm collector * apply suggestion * fix tests * fix typo --------- Co-authored-by: Nurlan Moldomurov Co-authored-by: Nurlan Moldomurov --- docs/release-notes/2.43.0.md | 24 +++++- managed/services/agents/mongodb.go | 4 + managed/services/agents/mongodb_test.go | 78 +++++++++++++++++++ .../victoriametrics/scrape_configs.go | 3 + 4 files changed, 108 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/2.43.0.md b/docs/release-notes/2.43.0.md index 7e92a19232..b57b98e1c8 100644 --- a/docs/release-notes/2.43.0.md +++ b/docs/release-notes/2.43.0.md @@ -113,10 +113,32 @@ pmm-admin add mongodb --enable-all-collectors ... Specifying a limit with `--max-collections` for this collector is not necessary. !!! note "Operation collection limitation" - To minimize impact on disk usage, the CurrentOp collector is designed to collect only operations that have been running for longer than 1 minute. This limitation helps focus on potentially problematic long-running operations while keeping data volume manageable. +To minimize impact on disk usage, the CurrentOp collector is designed to collect only operations that have been running for longer than 1 minute. This limitation helps focus on potentially problematic long-running operations while keeping data volume manageable. For more information on MongoDB collectors and metrics, see the [pmm-admin commands documentation](../use/commamds/pmm-admin.md). +### Monitoring for Percona Backup for MongoDB +PMM now supports monitoring your Percona Backup for MongoDB (PBM) setup and provides PBM-related metrics such as `pbm-agent` statuses, PITR configuration, and backup statuses. +This is made possible via a new PBM collector in MongoDB exporter that gives you visibility to your PBM setup via these metrics: +- `mongodb_pbm_cluster_backup_configured` +- `mongodb_pbm_agent_status` +- `mongodb_pbm_cluster_pitr_backup_enabled` +- `mongodb_pbm_backup_size` +- `mongodb_pbm_backup_duration_seconds` + +These metrics are enabled by default. If you're already running Percona Backup for MongoDB, you'll automatically receive these metrics without any additional configuration. +## Improvements + +- [PMM-13133](https://perconadev.atlassian.net/browse/PMM-13133) - + +- [PMM-13054](https://perconadev.atlassian.net/browse/PMM-13054) - The default number of log lines for each log file returned by `httsp:///logs.zip` endpoint has been increased from 1,000 to 50,000. + +Additionally, the endpoint now includes a customizable line-count parameter in the download URL, allowing you to specify a custom number of log lines or opt for unlimited log size. For more information, see the [API documentation](https://percona-pmm.readme.io/reference/logs). + +- [PMM-13159](https://perconadev.atlassian.net/browse/PMM-13159) - We have removed the experimental MongoDB **Collection Details** dashboard from PMM. You can now find up-to-date collection information on the new Mongo **Cluster Summary** dashboard, which provides a more comprehensive and accurate view of MongoDB collection metrics. + +If you have been using the **Collection Details** dashboard, make sure to now check the new **MongoDB Cluster Summary** dashboard for similar information. + ## Maintenance diff --git a/managed/services/agents/mongodb.go b/managed/services/agents/mongodb.go index 3b1fa5f68d..a9c39c14f3 100644 --- a/managed/services/agents/mongodb.go +++ b/managed/services/agents/mongodb.go @@ -37,6 +37,7 @@ var ( v2_26_0 = version.MustParse("2.26.0-0") v2_41_1 = version.MustParse("2.41.1-0") v2_42_0 = version.MustParse("2.42.0-0") + v2_43_0 = version.MustParse("2.43.0-0") ) // mongodbExporterConfig returns desired configuration of mongodb_exporter process. @@ -109,6 +110,9 @@ func getArgs(exporter *models.Agent, tdp *models.DelimiterPair, listenAddress st if !pmmAgentVersion.Less(v2_42_0) && collectAll { // >= 2.42.0 args = append(args, "--collector.currentopmetrics") } + if !pmmAgentVersion.Less(v2_43_0) { // >= 2.43.0, enable pbm collector by default + args = append(args, "--collector.pbm") + } args = collectors.FilterOutCollectors("--collector.", args, exporter.DisabledCollectors) args = append(args, collectors.DisableDefaultEnabledCollectors("--no-collector.", defaultEnabledCollectors, exporter.DisabledCollectors)...) diff --git a/managed/services/agents/mongodb_test.go b/managed/services/agents/mongodb_test.go index 0864effc51..74c9fc4a6e 100644 --- a/managed/services/agents/mongodb_test.go +++ b/managed/services/agents/mongodb_test.go @@ -415,6 +415,84 @@ func TestMongodbExporterConfig2411(t *testing.T) { }) } +func TestMongodbExporterConfig2430(t *testing.T) { + pmmAgentVersion := version.MustParse("2.43.0") + node := &models.Node{ + Address: "1.2.3.4", + } + mongodb := &models.Service{ + Address: pointer.ToString("1.2.3.4"), + Port: pointer.ToUint16(27017), + } + exporter := &models.Agent{ + AgentID: "agent-id", + AgentType: models.MongoDBExporterType, + Username: pointer.ToString("username"), + Password: pointer.ToString("s3cur3 p@$$w0r4."), + AgentPassword: pointer.ToString("agent-password"), + } + actual, err := mongodbExporterConfig(node, mongodb, exporter, redactSecrets, pmmAgentVersion) + expected := &agentpb.SetStateRequest_AgentProcess{ + Type: inventorypb.AgentType_MONGODB_EXPORTER, + TemplateLeftDelim: "{{", + TemplateRightDelim: "}}", + Args: []string{ + "--collector.diagnosticdata", + "--collector.pbm", + "--collector.replicasetstatus", + "--compatible-mode", + "--discovering-mode", + "--mongodb.global-conn-pool", + "--web.listen-address=0.0.0.0:{{ .listen_port }}", + "--web.config={{ .TextFiles.webConfigPlaceholder }}", + }, + Env: []string{ + "MONGODB_URI=mongodb://username:s3cur3%20p%40$$w0r4.@1.2.3.4:27017/?connectTimeoutMS=1000&directConnection=true&serverSelectionTimeoutMS=1000", + }, + RedactWords: []string{"s3cur3 p@$$w0r4.", "agent-password"}, + TextFiles: map[string]string{ + "webConfigPlaceholder": "basic_auth_users:\n pmm: agent-password\n", + }, + } + require.NoError(t, err) + requireNoDuplicateFlags(t, actual.Args) + require.Equal(t, expected.Args, actual.Args) + require.Equal(t, expected.Env, actual.Env) + require.Equal(t, expected, actual) + + t.Run("Enabling all collectors", func(t *testing.T) { + exporter.MongoDBOptions = &models.MongoDBOptions{ + EnableAllCollectors: true, + StatsCollections: []string{"db1.col1.one", "db2.col2", "db3"}, + } + + expected.Args = []string{ + "--collector.collstats", + "--collector.collstats-limit=0", + "--collector.currentopmetrics", + "--collector.dbstats", + "--collector.diagnosticdata", + "--collector.indexstats", + "--collector.pbm", + "--collector.replicasetstatus", + "--collector.shards", + "--collector.topmetrics", + "--compatible-mode", + "--discovering-mode", + // this should be here even if limit=0 because it could be used to filter dbstats + // since dbstats is not depending on the number of collections present in the db. + "--mongodb.collstats-colls=db1.col1.one,db2.col2,db3", + "--mongodb.global-conn-pool", + "--mongodb.indexstats-colls=db1.col1.one,db2.col2,db3", + "--web.listen-address=0.0.0.0:{{ .listen_port }}", + "--web.config={{ .TextFiles.webConfigPlaceholder }}", + } + actual, err := mongodbExporterConfig(node, mongodb, exporter, exposeSecrets, pmmAgentVersion) + require.NoError(t, err) + require.Equal(t, expected.Args, actual.Args) + }) +} + func TestMongodbExporterConfig(t *testing.T) { pmmAgentVersion := version.MustParse("2.0.0") node := &models.Node{ diff --git a/managed/services/victoriametrics/scrape_configs.go b/managed/services/victoriametrics/scrape_configs.go index d2a3104fcd..4106a1fd62 100644 --- a/managed/services/victoriametrics/scrape_configs.go +++ b/managed/services/victoriametrics/scrape_configs.go @@ -425,6 +425,9 @@ func scrapeConfigsForMongoDBExporter(params *scrapeConfigParams) ([]*config.Scra if !params.pmmAgentVersion.Less(version.MustParse("2.42.0-0")) { defaultCollectors = append(defaultCollectors, "currentopmetrics") } + if !params.pmmAgentVersion.Less(version.MustParse("2.43.0-0")) { + defaultCollectors = append(defaultCollectors, "pbm") + } lr, err := scrapeConfigForStandardExporter("lr", params.metricsResolution.LR, params, defaultCollectors) if err != nil {