Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMM-13111 disable new postgresql collectors. #3111

Merged
merged 12 commits into from
Aug 26, 2024
8 changes: 2 additions & 6 deletions docs/release-notes/2.43.0.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Percona Monitoring and Management 2.43.0

| **Release date** | July , 2024 |
| **Release date** | August , 2024 |
| -----------------| ----------------------------------------------------------------------------------------------- |
| **Installation** | [Installing Percona Monitoring and Management](../quickstart/index.md) |

Expand Down Expand Up @@ -164,8 +164,7 @@ If you're looking to upgrade, you can easily [install the latest version of Perc

### Fixed issues


- [PMM-13246](https://perconadev.atlassian.net/browse/PMM-13246) - Addressed four security vulnerabilities (CVEs) related to the GNU C Library (Glibc), specifically affecting the Name Service Cache Daemon (nscd):[CVE-2024-33599](https://nvd.nist.gov/vuln/detail/CVE-2024-33599), [CVE-2024-33600](https://nvd.nist.gov/vuln/detail/CVE-2024-33600), [CVE-2024-33601](https://nvd.nist.gov/vuln/detail/CVE-2024-33601), [CVE-2024-33602](https://nvd.nist.gov/vuln/detail/CVE-2024-33602).
- [PMM-13111](https://perconadev.atlassian.net/browse/PMM-13111) - Fixed an issue with `--disable-collectors` flag not supporting new collectors introduced in the recent `postgres_exporter` upgrade.

- [PMM-13277](https://perconadev.atlassian.net/browse/PMM-13277) - PMM 2.43 is now available on the AWS Marketplace, resolving the previous temporary unavailability issue of PMM 2.42.0. Users can directly install or upgrade to PMM 2.43.0 through AWS Marketplace or the PMM UI for access to the latest features and improvements.

Expand All @@ -176,9 +175,6 @@ If you're looking to upgrade, you can easily [install the latest version of Perc
- [CVE-2024-33601](https://nvd.nist.gov/vuln/detail/CVE-2024-33601)
- [CVE-2024-33602](https://nvd.nist.gov/vuln/detail/CVE-2024-33602)




- [PMM-13002](https://perconadev.atlassian.net/browse/PMM-13246): [Dashboards] - Fixed a bug in the **MongoDB ReplSet Summary** dashboard where the **Node Summary** section only displayed information for one node. It now correctly shows data for all nodes in a replica set when **All** is selected, providing a comprehensive view of multi-node deployments.

- [PMM-13255](https://perconadev.atlassian.net/browse/PMM-13255) - Resolved two issues with the MongoDB Replication Lag Alert: one where an error occurred during the import of the alert rule template, and another where the alert description displayed an incorrect current value for the replication lag.
Expand Down
22 changes: 21 additions & 1 deletion managed/services/agents/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,25 @@ import (
var (
postgresExporterAutodiscoveryVersion = version.MustParse("2.15.99")
postgresExporterWebConfigVersion = version.MustParse("2.30.99")
postgresSSLSniVersion = version.MustParse("2.40.99")
postgresSSLSniVersion = version.MustParse("2.41.0-0")
postgresExporterCollectorsVersion = version.MustParse("2.41.0-0")
postgresMaxExporterConnsVersion = version.MustParse("2.41.2-0")
)

var defaultPostgresExporterCollectors = []string{
"database",
"database_wraparound",
"extensions",
"locks",
"replication",
"replication_slot",
"stat_bgwriter",
"stat_database",
"stat_user_tables",
"statio_user_tables",
"wal",
}

const defaultAutoDiscoveryDatabaseLimit = 50

func postgresExcludedDatabases() []string {
Expand Down Expand Up @@ -101,6 +116,11 @@ func postgresExporterConfig(node *models.Node, service *models.Service, exporter

args = collectors.FilterOutCollectors("--collect.", args, exporter.DisabledCollectors)

if !pmmAgentVersion.Less(postgresExporterCollectorsVersion) {
disableCollectorArgs := collectors.DisableDefaultEnabledCollectors("--no-collector.", defaultPostgresExporterCollectors, exporter.DisabledCollectors)
args = append(args, disableCollectorArgs...)
}

args = withLogLevel(args, exporter.LogLevel, pmmAgentVersion, false)

sort.Strings(args)
Expand Down
12 changes: 8 additions & 4 deletions managed/services/agents/postgresql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ func (s *PostgresExporterConfigTestSuite) TestSocket() {
}

func (s *PostgresExporterConfigTestSuite) TestDisabledCollectors() {
s.pmmAgentVersion = &version.Parsed{}
s.pmmAgentVersion = version.MustParse("2.42.0")
s.postgresql.Address = nil
s.postgresql.Port = nil
s.postgresql.Socket = pointer.ToString("/var/run/postgres")
s.exporter.DisabledCollectors = []string{"custom_query.hr", "custom_query.hr.directory"}
s.exporter.DisabledCollectors = []string{"custom_query.hr", "custom_query.hr.directory", "locks"}

actual, err := postgresExporterConfig(s.node, s.postgresql, s.exporter, exposeSecrets, s.pmmAgentVersion)
s.NoError(err, "Failed to create exporter config")
Expand All @@ -164,11 +164,15 @@ func (s *PostgresExporterConfigTestSuite) TestDisabledCollectors() {
TemplateLeftDelim: "{{",
TemplateRightDelim: "}}",
Args: []string{
"--auto-discover-databases",
"--collect.custom_query.lr",
"--collect.custom_query.lr.directory=" + pathsBase(s.pmmAgentVersion, "{{", "}}") + "/collectors/custom-queries/postgresql/low-resolution",
"--collect.custom_query.lr.directory={{ .paths_base }}/collectors/custom-queries/postgresql/low-resolution",
"--collect.custom_query.mr",
"--collect.custom_query.mr.directory=" + pathsBase(s.pmmAgentVersion, "{{", "}}") + "/collectors/custom-queries/postgresql/medium-resolution",
"--collect.custom_query.mr.directory={{ .paths_base }}/collectors/custom-queries/postgresql/medium-resolution",
"--exclude-databases=template0,template1,postgres,cloudsqladmin,pmm-managed-dev,azure_maintenance,rdsadmin",
"--no-collector.locks",
"--web.listen-address=0.0.0.0:{{ .listen_port }}",
"--web.config={{ .TextFiles.webConfigPlaceholder }}",
},
}
requireNoDuplicateFlags(s.T(), actual.Args)
Expand Down
78 changes: 78 additions & 0 deletions managed/utils/collectors/collectors_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Copyright (C) 2023 Percona LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

package collectors

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestDisableDefaultEnabledCollectors(t *testing.T) {
type args struct {
prefix string
defaultCollectors []string
disabledCollectors []string
}
tests := []struct {
name string
args args
want []string
}{
{
name: "Disable single default enabled collectors",
args: args{
prefix: "--no-collector.",
defaultCollectors: []string{"a", "b", "c", "d", "e"},
disabledCollectors: []string{"b"},
},
want: []string{"--no-collector.b"},
},
{
name: "Disable multiple default enabled collectors",
args: args{
prefix: "--no-collector.",
defaultCollectors: []string{"a", "b", "c", "d", "e", "f"},
disabledCollectors: []string{"a", "c"},
},
want: []string{"--no-collector.a", "--no-collector.c"},
},
{
name: "Disable all default enabled collectors",
args: args{
prefix: "--no-collector.",
defaultCollectors: []string{"a", "b", "c"},
disabledCollectors: []string{"a", "b", "c"},
},
want: []string{"--no-collector.a", "--no-collector.b", "--no-collector.c"},
},
{
name: "Disable non-default enabled collectors",
args: args{
prefix: "--no-collector.",
defaultCollectors: []string{"a", "b", "c"},
disabledCollectors: []string{"d", "e", "f"},
},
want: []string{},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
actual := DisableDefaultEnabledCollectors(tt.args.prefix, tt.args.defaultCollectors, tt.args.disabledCollectors)
require.Equal(t, tt.want, actual, "DisableDefaultEnabledCollectors() = %v, want %v", actual, tt.want)
})
}
}
Loading