Skip to content

Commit

Permalink
PMM-13146 Fix v3 telemetry issues (#3154)
Browse files Browse the repository at this point in the history
* PMM-13146 Fix the collection of server settings

* PMM-13146 remove a non-existent field

* PMM-13146 update telemetry configuration

* PMM-13146 rename the envvar for backups

* PMM-13146 fix the error not being used

* Update managed/services/telemetry/config.default.yml

Co-authored-by: Nurlan Moldomurov <[email protected]>

* PMM-13146 put back PMMServerHAEnabled metric

* PMM-13146 simplify boolean logic when reporting feature toggles

* PMM-13146 add a test for a missing metric

* Update managed/services/telemetry/config.default.yml

Co-authored-by: Michael Okoko <[email protected]>

* Update managed/services/telemetry/config.default.yml

Co-authored-by: Nurlan Moldomurov <[email protected]>

* Update managed/services/telemetry/config.default.yml

Co-authored-by: Nurlan Moldomurov <[email protected]>

---------

Co-authored-by: Nurlan Moldomurov <[email protected]>
Co-authored-by: Michael Okoko <[email protected]>
  • Loading branch information
3 people authored Sep 16, 2024
1 parent 5561f58 commit 8ad46db
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 31 deletions.
2 changes: 1 addition & 1 deletion docs/process/v2_to_v3_environment_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Below is a list of affected variables and their new names.
| `DISABLE_UPDATES` | `PMM_ENABLE_UPDATES` | |
| `DISABLE_TELEMETRY` | `PMM_ENABLE_TELEMETRY` | |
| `PERCONA_PLATFORM_API_TIMEOUT` | `PMM_DEV_PERCONA_PLATFORM_API_TIMEOUT` | |
| `DISABLE_BACKUP_MANAGEMENT` | `PMM_DISABLE_BACKUP_MANAGEMENT` | |
| `DISABLE_BACKUP_MANAGEMENT` | `PMM_ENABLE_BACKUP_MANAGEMENT` | Note the reverted boolean |
| `ENABLE_AZUREDISCOVER` | `PMM_ENABLE_AZURE_DISCOVER` | |
| `ENABLE_RBAC` | `PMM_ENABLE_ACCESS_CONTROL` | |
| `LESS_LOG_NOISE` | | Removed in PMM v3 |
Expand Down
58 changes: 32 additions & 26 deletions managed/services/telemetry/config.default.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
telemetry:
# PMM - generic information
- id: PMMServerIAEnabled
- id: PMMServerAlertingEnabled
source: PMMDB_SELECT
query: (CASE WHEN alerting->'disabled' = 'false' THEN '1' ELSE '0' END) AS ia_enabled FROM settings s, jsonb_extract_path(s.settings, 'alerting') AS alerting
query: (CASE WHEN alerting->'enabled' = 'false' THEN '0' ELSE '1' END) AS alerting_enabled FROM settings s, jsonb_extract_path(s.settings, 'alerting') AS alerting
summary: "PMM Server Integration Alerting feature enabled/disabled"
data:
- metric_name: "pmm_server_ia_enabled"
column: "ia_enabled"
- metric_name: "pmm_server_alerting_enabled"
column: "alerting_enabled"

- id: PMMServerAlertsFire
source: VM
Expand All @@ -24,25 +24,17 @@ telemetry:
- metric_name: "pmm_server_alert_rules_number"
value: 1

- id: PMMServerSTTEnabled
- id: PMMServerAdvisorsEnabled
source: PMMDB_SELECT
query: (CASE WHEN stt->'stt_disabled' = 'false' THEN '1' ELSE '0' END) AS stt_enabled FROM settings s, jsonb_extract_path(s.settings, 'sass') AS stt
summary: "PMM Server Security Thread Tool feature enabled/disabled"
query: (CASE WHEN advisors->'enabled' = 'false' THEN '0' ELSE '1' END) AS advisors_enabled FROM settings s, jsonb_extract_path(s.settings, 'sass') AS advisors
summary: "PMM Advisors Enabled"
data:
- metric_name: "pmm_server_stt_enabled"
column: "stt_enabled"

- id: PMMServerAdvisorsDisabled
source: PMMDB_SELECT
query: (CASE WHEN advisors->'enabled' = 'true' THEN '0' ELSE '1' END) AS advisors_disabled FROM settings s, jsonb_extract_path(s.settings, 'sass') AS advisors
summary: "PMM Advisors Disabled"
data:
- metric_name: "pmm_server_advisors_disabled"
column: "advisors_disabled"
- metric_name: "pmm_server_advisors_enabled"
column: "advisors_enabled"

- id: PMMServerBackupManagementEnabled
source: PMMDB_SELECT
query: (CASE WHEN backup_management->'disabled' = 'false' THEN '1' ELSE '0' END) AS backup_management_enabled FROM settings s, jsonb_extract_path(s.settings, 'backup_management') AS backup_management
query: (CASE WHEN backup_management->'enabled' = 'false' THEN '0' ELSE '1' END) AS backup_management_enabled FROM settings s, jsonb_extract_path(s.settings, 'backup_management') AS backup_management
summary: "PMM Server Backup Management feature enabled"
data:
- metric_name: "pmm_server_backup_management_enabled"
Expand All @@ -51,18 +43,26 @@ telemetry:
- id: PMMServerAccessControlEnabled
source: PMMDB_SELECT
query: (CASE WHEN access_control->'enabled' = 'true' THEN '1' ELSE '0' END) AS access_control_enabled FROM settings s, jsonb_extract_path(s.settings, 'access_control') AS access_control
summary: "PMM Server Access Control feature enabled/disabled"
summary: "PMM Server Access Control feature enabled"
data:
- metric_name: "pmm_server_access_control_enabled"
column: "access_control_enabled"

- id: PMMServerUpdatesDisabled
- id: PMMServerUpdatesEnabled
source: PMMDB_SELECT
query: (CASE WHEN updates->'enabled' = 'true' THEN '1' ELSE '0' END) AS updates_enabled FROM settings s, jsonb_extract_path(s.settings, 'updates') AS updates
summary: "PMM Server Check Updates feature enabled"
data:
- metric_name: "pmm_server_updates_enabled"
column: "updates_enabled"

- id: PMMAzureMonitoringEnabled
source: PMMDB_SELECT
query: (CASE WHEN updates->'disabled' = 'true' THEN '1' ELSE '0' END) AS updates_disabled FROM settings s, jsonb_extract_path(s.settings, 'updates') AS updates
summary: "PMM Server Check Updates feature disabled"
query: (CASE WHEN azure->'enabled' = 'true' THEN '1' ELSE '0' END) AS azure_enabled FROM settings s, jsonb_extract_path(s.settings, 'azure') AS azure
summary: "PMM Azure monitoring feature enabled"
data:
- metric_name: "pmm_server_updates_disabled"
column: "updates_disabled"
- metric_name: "pmm_server_azure_enabled"
column: "azure_enabled"

- id: PMMServerFirstServiceAdded
source: PMMDB_SELECT
Expand Down Expand Up @@ -911,7 +911,6 @@ telemetry:
from dumps
where created_at BETWEEN NOW() - INTERVAL '24 HOURS' AND NOW()
group by status, services_count, timerange, ignore_load, export_qan;
transform:
type: JSON
metric: pmm_dumps_performed
Expand Down Expand Up @@ -956,7 +955,14 @@ telemetry:
summary: "Use of HA feature"
data:
- metric_name: "pmm_server_ha_enable"
column: "PERCONA_TEST_HA_ENABLE"
column: "PMM_TEST_HA_ENABLE"

- id: PMMServerBuiltinDatabaseDisabled
source: ENV_VARS
summary: "Use of external PMM database"
data:
- metric_name: "pmm_server_builtin_postgres_disable"
column: "PMM_DISABLE_BUILTIN_POSTGRES"

- id: PMMServerHAUseOfDBs
source: ENV_VARS
Expand Down
29 changes: 27 additions & 2 deletions managed/services/telemetry/transform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,31 @@ func TestTransformToJSON(t *testing.T) {
},
wantErr: assert.NoError,
},
{
name: "test_mysql_plugins_with_an_missing_metric",
args: args{
config: configJSON().changeData([]ConfigData{
{MetricName: "1", Label: "library"}, // this metric will be missing in the output
{MetricName: "2", Label: "licence"},
{MetricName: "3", Label: "name"},
{MetricName: "4", Label: "status"},
{MetricName: "5", Label: "type"},
}),
metrics: []*pmmv1.ServerMetric_Metric{
{Key: "licence", Value: `GPL`},
{Key: "name", Value: `INNODB_TABLES`},
{Key: "status", Value: `ACTIVE`},
{Key: "type", Value: `INFORMATION SCHEMA`},
},
},
want: []*pmmv1.ServerMetric_Metric{
{Key: "metric", Value: `{"v":[{"licence":"GPL","name":"INNODB_TABLES","status":"ACTIVE","type":"INFORMATION SCHEMA"}]}`},
},
wantErr: assert.NoError,
},
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
got, err := transformToJSON(tt.args.config, tt.args.metrics)
if !tt.wantErr(t, err) {
Expand Down Expand Up @@ -220,7 +241,6 @@ func TestTransformExportValues(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
got, err := transformExportValues(tt.args.config, tt.args.metrics)
if !tt.wantErr(t, err) {
Expand Down Expand Up @@ -273,6 +293,11 @@ func (c *Config) changeDataSource(s DataSourceName) *Config {
return c
}

func (c *Config) changeData(d []ConfigData) *Config {
c.Data = d
return c
}

func TestRemoveEmpty(t *testing.T) {
type args struct {
metrics []*pmmv1.ServerMetric_Metric
Expand Down
4 changes: 2 additions & 2 deletions managed/utils/envvars/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func ParseEnvVars(envs []string) (*models.ChangeSettingsParams, []error, []strin
}
envSettings.EnableAzurediscover = &b

case "ENABLE_BACKUP_MANAGEMENT":
case "PMM_ENABLE_BACKUP_MANAGEMENT":
b, err := strconv.ParseBool(v)
if err != nil {
errs = append(errs, fmt.Errorf("invalid value %q for environment variable %q", v, k))
Expand All @@ -173,7 +173,7 @@ func ParseEnvVars(envs []string) (*models.ChangeSettingsParams, []error, []strin
case "PMM_VM_URL":
_, err = url.Parse(v)
if err != nil {
err = fmt.Errorf("invalid value %q for environment variable %q", v, k)
errs = append(errs, fmt.Errorf("invalid value %q for environment variable %q", v, k))
}

case "PMM_INSTALL_METHOD", "PMM_DISTRIBUTION_METHOD":
Expand Down

0 comments on commit 8ad46db

Please sign in to comment.