diff --git a/config/crd/bases/postgres-operator.crunchydata.com_pgadmins.yaml b/config/crd/bases/postgres-operator.crunchydata.com_pgadmins.yaml index b72ba71438..92b0b542bd 100644 --- a/config/crd/bases/postgres-operator.crunchydata.com_pgadmins.yaml +++ b/config/crd/bases/postgres-operator.crunchydata.com_pgadmins.yaml @@ -2120,6 +2120,13 @@ spec: type: string x-kubernetes-validations: - rule: duration("0") <= self && self <= duration("60m") + databases: + description: |- + The databases to target with added custom queries. + Default behavior is to target `postgres`. + items: + type: string + type: array name: description: |- The name of this batch of queries, which will be used in naming the OTel @@ -2165,6 +2172,12 @@ spec: type: string type: array type: object + perDBMetricTargets: + description: User defined databases to target for default + per-db metrics + items: + type: string + type: array type: object resources: description: Resources holds the resource requirements for the diff --git a/config/crd/bases/postgres-operator.crunchydata.com_postgresclusters.yaml b/config/crd/bases/postgres-operator.crunchydata.com_postgresclusters.yaml index 7e8fcfc535..845dc12078 100644 --- a/config/crd/bases/postgres-operator.crunchydata.com_postgresclusters.yaml +++ b/config/crd/bases/postgres-operator.crunchydata.com_postgresclusters.yaml @@ -11965,6 +11965,13 @@ spec: type: string x-kubernetes-validations: - rule: duration("0") <= self && self <= duration("60m") + databases: + description: |- + The databases to target with added custom queries. + Default behavior is to target `postgres`. + items: + type: string + type: array name: description: |- The name of this batch of queries, which will be used in naming the OTel @@ -12010,6 +12017,12 @@ spec: type: string type: array type: object + perDBMetricTargets: + description: User defined databases to target for default + per-db metrics + items: + type: string + type: array type: object resources: description: Resources holds the resource requirements for the diff --git a/internal/collector/generated/gte_pg16_slow_metrics.json b/internal/collector/generated/gte_pg16_slow_metrics.json deleted file mode 100644 index 3b27be7bc0..0000000000 --- a/internal/collector/generated/gte_pg16_slow_metrics.json +++ /dev/null @@ -1 +0,0 @@ -[{"metrics":[{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of times this table has been manually analyzed","metric_name":"ccp_stat_user_tables_analyze_count","static_attributes":{"server":"localhost:5432"},"value_column":"analyze_count"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of times this table has been analyzed by the autovacuum daemon","metric_name":"ccp_stat_user_tables_autoanalyze_count","static_attributes":{"server":"localhost:5432"},"value_column":"autoanalyze_count"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of times this table has been vacuumed by the autovacuum daemon","metric_name":"ccp_stat_user_tables_autovacuum_count","static_attributes":{"server":"localhost:5432"},"value_column":"autovacuum_count"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of index scans initiated on this table","metric_name":"ccp_stat_user_tables_idx_scan","static_attributes":{"server":"localhost:5432"},"value_column":"idx_scan"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of live rows fetched by index scans","metric_name":"ccp_stat_user_tables_idx_tup_fetch","static_attributes":{"server":"localhost:5432"},"value_column":"idx_tup_fetch"},{"attribute_columns":["dbname","relname","schemaname"],"description":"Estimated number of dead rows","metric_name":"ccp_stat_user_tables_n_dead_tup","static_attributes":{"server":"localhost:5432"},"value_column":"n_dead_tup"},{"attribute_columns":["dbname","relname","schemaname"],"description":"Estimated number of live rows","metric_name":"ccp_stat_user_tables_n_live_tup","static_attributes":{"server":"localhost:5432"},"value_column":"n_live_tup"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of rows deleted","metric_name":"ccp_stat_user_tables_n_tup_del","static_attributes":{"server":"localhost:5432"},"value_column":"n_tup_del"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of rows HOT updated (i.e., with no separate index update required)","metric_name":"ccp_stat_user_tables_n_tup_hot_upd","static_attributes":{"server":"localhost:5432"},"value_column":"n_tup_hot_upd"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of rows inserted","metric_name":"ccp_stat_user_tables_n_tup_ins","static_attributes":{"server":"localhost:5432"},"value_column":"n_tup_ins"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of rows updated","metric_name":"ccp_stat_user_tables_n_tup_upd","static_attributes":{"server":"localhost:5432"},"value_column":"n_tup_upd"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of sequential scans initiated on this table","metric_name":"ccp_stat_user_tables_seq_scan","static_attributes":{"server":"localhost:5432"},"value_column":"seq_scan"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of live rows fetched by sequential scans","metric_name":"ccp_stat_user_tables_seq_tup_read","static_attributes":{"server":"localhost:5432"},"value_column":"seq_tup_read"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of times this table has been manually vacuumed (not counting VACUUM FULL)","metric_name":"ccp_stat_user_tables_vacuum_count","static_attributes":{"server":"localhost:5432"},"value_column":"vacuum_count"}],"sql":"SELECT\n current_database() as dbname\n , p.schemaname\n , p.relname\n , p.seq_scan\n , p.seq_tup_read\n , COALESCE(p.idx_scan, 0) AS idx_scan\n , COALESCE(p.idx_tup_fetch, 0) as idx_tup_fetch\n , p.n_tup_ins\n , p.n_tup_upd\n , p.n_tup_del\n , p.n_tup_hot_upd\n , p.n_tup_newpage_upd\n , p.n_live_tup\n , p.n_dead_tup\n , p.vacuum_count\n , p.autovacuum_count\n , p.analyze_count\n , p.autoanalyze_count\n FROM pg_catalog.pg_stat_user_tables p;\n"}] diff --git a/internal/collector/generated/lt_pg16_slow_metrics.json b/internal/collector/generated/lt_pg16_slow_metrics.json deleted file mode 100644 index 98bb0cc213..0000000000 --- a/internal/collector/generated/lt_pg16_slow_metrics.json +++ /dev/null @@ -1 +0,0 @@ -[{"metrics":[{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of times this table has been manually analyzed","metric_name":"ccp_stat_user_tables_analyze_count","static_attributes":{"server":"localhost:5432"},"value_column":"analyze_count"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of times this table has been analyzed by the autovacuum daemon","metric_name":"ccp_stat_user_tables_autoanalyze_count","static_attributes":{"server":"localhost:5432"},"value_column":"autoanalyze_count"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of times this table has been vacuumed by the autovacuum daemon","metric_name":"ccp_stat_user_tables_autovacuum_count","static_attributes":{"server":"localhost:5432"},"value_column":"autovacuum_count"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of index scans initiated on this table","metric_name":"ccp_stat_user_tables_idx_scan","static_attributes":{"server":"localhost:5432"},"value_column":"idx_scan"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of live rows fetched by index scans","metric_name":"ccp_stat_user_tables_idx_tup_fetch","static_attributes":{"server":"localhost:5432"},"value_column":"idx_tup_fetch"},{"attribute_columns":["dbname","relname","schemaname"],"description":"Estimated number of dead rows","metric_name":"ccp_stat_user_tables_n_dead_tup","static_attributes":{"server":"localhost:5432"},"value_column":"n_dead_tup"},{"attribute_columns":["dbname","relname","schemaname"],"description":"Estimated number of live rows","metric_name":"ccp_stat_user_tables_n_live_tup","static_attributes":{"server":"localhost:5432"},"value_column":"n_live_tup"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of rows deleted","metric_name":"ccp_stat_user_tables_n_tup_del","static_attributes":{"server":"localhost:5432"},"value_column":"n_tup_del"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of rows HOT updated (i.e., with no separate index update required)","metric_name":"ccp_stat_user_tables_n_tup_hot_upd","static_attributes":{"server":"localhost:5432"},"value_column":"n_tup_hot_upd"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of rows inserted","metric_name":"ccp_stat_user_tables_n_tup_ins","static_attributes":{"server":"localhost:5432"},"value_column":"n_tup_ins"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of rows updated","metric_name":"ccp_stat_user_tables_n_tup_upd","static_attributes":{"server":"localhost:5432"},"value_column":"n_tup_upd"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of sequential scans initiated on this table","metric_name":"ccp_stat_user_tables_seq_scan","static_attributes":{"server":"localhost:5432"},"value_column":"seq_scan"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of live rows fetched by sequential scans","metric_name":"ccp_stat_user_tables_seq_tup_read","static_attributes":{"server":"localhost:5432"},"value_column":"seq_tup_read"},{"attribute_columns":["dbname","relname","schemaname"],"data_type":"sum","description":"Number of times this table has been manually vacuumed (not counting VACUUM FULL)","metric_name":"ccp_stat_user_tables_vacuum_count","static_attributes":{"server":"localhost:5432"},"value_column":"vacuum_count"}],"sql":"SELECT\n current_database() as dbname\n , p.schemaname\n , p.relname\n , p.seq_scan\n , p.seq_tup_read\n , COALESCE(p.idx_scan, 0) AS idx_scan\n , COALESCE(p.idx_tup_fetch, 0) as idx_tup_fetch\n , p.n_tup_ins\n , p.n_tup_upd\n , p.n_tup_del\n , p.n_tup_hot_upd\n , 0::bigint AS n_tup_newpage_upd\n , p.n_live_tup\n , p.n_dead_tup\n , p.vacuum_count\n , p.autovacuum_count\n , p.analyze_count\n , p.autoanalyze_count\nFROM pg_catalog.pg_stat_user_tables p;\n"}] diff --git a/internal/collector/generated/pgbackrest_metrics.json b/internal/collector/generated/pgbackrest_metrics.json deleted file mode 100644 index 63114afc03..0000000000 --- a/internal/collector/generated/pgbackrest_metrics.json +++ /dev/null @@ -1 +0,0 @@ -[{"metrics":[{"attribute_columns":["repo"],"description":"Seconds since the last completed full or differential backup. Differential is always based off last full.","metric_name":"ccp_backrest_last_diff_backup_time_since_completion_seconds","static_attributes":{"server":"localhost:5432","stanza":"db"},"value_column":"last_diff_backup"},{"attribute_columns":["repo"],"description":"Seconds since the last completed full backup","metric_name":"ccp_backrest_last_full_backup_time_since_completion_seconds","static_attributes":{"server":"localhost:5432","stanza":"db"},"value_column":"last_full_backup"},{"attribute_columns":["repo"],"description":"Seconds since the last completed full, differential or incremental backup.\nIncremental is always based off last full or differential.\n","metric_name":"ccp_backrest_last_incr_backup_time_since_completion_seconds","static_attributes":{"server":"localhost:5432","stanza":"db"},"value_column":"last_incr_backup"},{"attribute_columns":["backup_type","repo"],"description":"pgBackRest version number when this backup was performed","metric_name":"ccp_backrest_last_info_backrest_repo_version","static_attributes":{"server":"localhost:5432","stanza":"db"},"value_column":"last_info_backrest_repo_version"},{"attribute_columns":["backup_type","repo"],"description":"An error has been encountered in the backup. Check logs for more information.","metric_name":"ccp_backrest_last_info_backup_error","static_attributes":{"server":"localhost:5432","stanza":"db"},"value_column":"last_info_backup_error"},{"attribute_columns":["backup_type","repo"],"description":"Total runtime in seconds of this backup","metric_name":"ccp_backrest_last_info_backup_runtime_seconds","static_attributes":{"server":"localhost:5432","stanza":"db"},"value_column":"backup_runtime_seconds"},{"attribute_columns":["backup_type","repo"],"description":"Actual size of only this individual backup in the pgbackrest repository","metric_name":"ccp_backrest_last_info_repo_backup_size_bytes","static_attributes":{"server":"localhost:5432","stanza":"db"},"value_column":"repo_backup_size_bytes"},{"attribute_columns":["backup_type","repo"],"description":"Total size of this backup in the pgbackrest repository, including all required previous backups and WAL","metric_name":"ccp_backrest_last_info_repo_total_size_bytes","static_attributes":{"server":"localhost:5432","stanza":"db"},"value_column":"repo_total_size_bytes"},{"attribute_columns":["repo"],"description":"Seconds since the oldest completed full backup","metric_name":"ccp_backrest_oldest_full_backup_time_seconds","static_attributes":{"server":"localhost:5432"},"value_column":"oldest_full_backup"}],"sql":"SELECT * FROM get_pgbackrest_info();\n"}] diff --git a/internal/collector/generated/postgres_5m_per_db_metrics.json b/internal/collector/generated/postgres_5m_per_db_metrics.json new file mode 100644 index 0000000000..0478569504 --- /dev/null +++ b/internal/collector/generated/postgres_5m_per_db_metrics.json @@ -0,0 +1 @@ +[{"metrics":[{"attribute_columns":["dbname","schemaname","relname"],"description":"Table size in bytes including indexes","metric_name":"ccp_table_size_bytes","static_attributes":{"server":"localhost:5432"},"value_column":"bytes","value_type":"double"}],"sql":"SELECT current_database() as dbname , n.nspname as schemaname , c.relname , pg_catalog.pg_total_relation_size(c.oid) as bytes FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid WHERE NOT pg_is_other_temp_schema(n.oid) AND relkind IN ('r', 'm', 'f');\n"},{"metrics":[{"attribute_columns":["dbname","schemaname","relname"],"data_type":"sum","description":"Number of sequential scans initiated on this table","metric_name":"ccp_stat_user_tables_seq_scan","static_attributes":{"server":"localhost:5432"},"value_column":"seq_scan"},{"attribute_columns":["dbname","schemaname","relname"],"data_type":"sum","description":"Number of live rows fetched by sequential scans","metric_name":"ccp_stat_user_tables_seq_tup_read","static_attributes":{"server":"localhost:5432"},"value_column":"seq_tup_read"},{"attribute_columns":["dbname","schemaname","relname"],"data_type":"sum","description":"Number of index scans initiated on this table","metric_name":"ccp_stat_user_tables_idx_scan","static_attributes":{"server":"localhost:5432"},"value_column":"idx_scan"},{"attribute_columns":["dbname","schemaname","relname"],"data_type":"sum","description":"Number of live rows fetched by index scans","metric_name":"ccp_stat_user_tables_idx_tup_fetch","static_attributes":{"server":"localhost:5432"},"value_column":"idx_tup_fetch"},{"attribute_columns":["dbname","schemaname","relname"],"data_type":"sum","description":"Number of rows inserted","metric_name":"ccp_stat_user_tables_n_tup_ins","static_attributes":{"server":"localhost:5432"},"value_column":"n_tup_ins"},{"attribute_columns":["dbname","schemaname","relname"],"data_type":"sum","description":"Number of rows updated","metric_name":"ccp_stat_user_tables_n_tup_upd","static_attributes":{"server":"localhost:5432"},"value_column":"n_tup_upd"},{"attribute_columns":["dbname","schemaname","relname"],"data_type":"sum","description":"Number of rows deleted","metric_name":"ccp_stat_user_tables_n_tup_del","static_attributes":{"server":"localhost:5432"},"value_column":"n_tup_del"},{"attribute_columns":["dbname","schemaname","relname"],"data_type":"sum","description":"Number of rows HOT updated (i.e., with no separate index update required)","metric_name":"ccp_stat_user_tables_n_tup_hot_upd","static_attributes":{"server":"localhost:5432"},"value_column":"n_tup_hot_upd"},{"attribute_columns":["dbname","schemaname","relname"],"data_type":"sum","description":"Number of rows updated where the successor version goes onto a new heap page, leaving behind an original version with a t_ctid field that points to a different heap page. These are always non-HOT updates.","metric_name":"ccp_stat_user_tables_n_tup_newpage_upd","static_attributes":{"server":"localhost:5432"},"value_column":"n_tup_newpage_upd"},{"attribute_columns":["dbname","schemaname","relname"],"description":"Estimated number of live rows","metric_name":"ccp_stat_user_tables_n_live_tup","static_attributes":{"server":"localhost:5432"},"value_column":"n_live_tup"},{"attribute_columns":["dbname","schemaname","relname"],"description":"Estimated number of dead rows","metric_name":"ccp_stat_user_tables_n_dead_tup","static_attributes":{"server":"localhost:5432"},"value_column":"n_dead_tup"},{"attribute_columns":["dbname","schemaname","relname"],"data_type":"sum","description":"Number of times this table has been manually vacuumed (not counting VACUUM FULL)","metric_name":"ccp_stat_user_tables_vacuum_count","static_attributes":{"server":"localhost:5432"},"value_column":"vacuum_count"},{"attribute_columns":["dbname","schemaname","relname"],"data_type":"sum","description":"Number of times this table has been vacuumed by the autovacuum daemon","metric_name":"ccp_stat_user_tables_autovacuum_count","static_attributes":{"server":"localhost:5432"},"value_column":"autovacuum_count"},{"attribute_columns":["dbname","schemaname","relname"],"data_type":"sum","description":"Number of times this table has been manually analyzed","metric_name":"ccp_stat_user_tables_analyze_count","static_attributes":{"server":"localhost:5432"},"value_column":"analyze_count"},{"attribute_columns":["dbname","schemaname","relname"],"data_type":"sum","description":"Number of times this table has been analyzed by the autovacuum daemon","metric_name":"ccp_stat_user_tables_autoanalyze_count","static_attributes":{"server":"localhost:5432"},"value_column":"autoanalyze_count"}],"sql":"SELECT current_database() as dbname , p.schemaname , p.relname , p.seq_scan , p.seq_tup_read , COALESCE(p.idx_scan, 0) AS idx_scan , COALESCE(p.idx_tup_fetch, 0) as idx_tup_fetch , p.n_tup_ins , p.n_tup_upd , p.n_tup_del , p.n_tup_hot_upd , CASE\n WHEN current_setting('server_version_num')::int \u003e= 160000 \n THEN p.n_tup_newpage_upd\n ELSE 0::bigint\n END AS n_tup_newpage_upd\n, p.n_live_tup , p.n_dead_tup , p.vacuum_count , p.autovacuum_count , p.analyze_count , p.autoanalyze_count FROM pg_catalog.pg_stat_user_tables p;\n"}] diff --git a/internal/collector/gte_pg16_slow_metrics.yaml b/internal/collector/gte_pg16_slow_metrics.yaml deleted file mode 100644 index 319aad62dc..0000000000 --- a/internal/collector/gte_pg16_slow_metrics.yaml +++ /dev/null @@ -1,127 +0,0 @@ -# This list of queries configures an OTel SQL Query Receiver to read pgMonitor -# metrics from Postgres. -# -# https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/-/receiver/sqlqueryreceiver#metrics-queries -# https://github.com/CrunchyData/pgmonitor/blob/development/sql_exporter/common/crunchy_global_collector.yml - -# NOTE: Some of the columns below can return NULL values, for which sqlqueryreceiver will warn. -# https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/sqlqueryreceiver#null-values -# Those columns are idx_scan and idx_tup_fetch and we avoid NULL by using COALESCE. - - sql: > - SELECT - current_database() as dbname - , p.schemaname - , p.relname - , p.seq_scan - , p.seq_tup_read - , COALESCE(p.idx_scan, 0) AS idx_scan - , COALESCE(p.idx_tup_fetch, 0) as idx_tup_fetch - , p.n_tup_ins - , p.n_tup_upd - , p.n_tup_del - , p.n_tup_hot_upd - , p.n_tup_newpage_upd - , p.n_live_tup - , p.n_dead_tup - , p.vacuum_count - , p.autovacuum_count - , p.analyze_count - , p.autoanalyze_count - FROM pg_catalog.pg_stat_user_tables p; - metrics: - - metric_name: ccp_stat_user_tables_analyze_count - data_type: sum - value_column: analyze_count - description: Number of times this table has been manually analyzed - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_autoanalyze_count - data_type: sum - value_column: autoanalyze_count - description: Number of times this table has been analyzed by the autovacuum daemon - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_autovacuum_count - data_type: sum - value_column: autovacuum_count - description: Number of times this table has been vacuumed by the autovacuum daemon - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_idx_scan - data_type: sum - value_column: idx_scan - description: Number of index scans initiated on this table - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_idx_tup_fetch - data_type: sum - value_column: idx_tup_fetch - description: Number of live rows fetched by index scans - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_n_dead_tup - value_column: n_dead_tup - description: Estimated number of dead rows - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_n_live_tup - value_column: n_live_tup - description: Estimated number of live rows - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_n_tup_del - data_type: sum - value_column: n_tup_del - description: Number of rows deleted - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_n_tup_hot_upd - data_type: sum - value_column: n_tup_hot_upd - description: Number of rows HOT updated (i.e., with no separate index update required) - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_n_tup_ins - data_type: sum - value_column: n_tup_ins - description: Number of rows inserted - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_n_tup_upd - data_type: sum - value_column: n_tup_upd - description: Number of rows updated - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_seq_scan - data_type: sum - value_column: seq_scan - description: Number of sequential scans initiated on this table - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_seq_tup_read - data_type: sum - value_column: seq_tup_read - description: Number of live rows fetched by sequential scans - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_vacuum_count - data_type: sum - value_column: vacuum_count - description: Number of times this table has been manually vacuumed (not counting VACUUM FULL) - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" diff --git a/internal/collector/lt_pg16_slow_metrics.yaml b/internal/collector/lt_pg16_slow_metrics.yaml deleted file mode 100644 index ca9fe8a0c8..0000000000 --- a/internal/collector/lt_pg16_slow_metrics.yaml +++ /dev/null @@ -1,135 +0,0 @@ -# This list of queries configures an OTel SQL Query Receiver to read pgMonitor -# metrics from Postgres. -# -# https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/-/receiver/sqlqueryreceiver#metrics-queries -# https://github.com/CrunchyData/pgmonitor/blob/development/sql_exporter/common/crunchy_global_collector.yml - -# NOTE: Some of the columns below can return NULL values, for which sqlqueryreceiver will warn. -# https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/sqlqueryreceiver#null-values -# Those columns are idx_scan and idx_tup_fetch and we avoid NULL by using COALESCE. - - sql: > - SELECT - current_database() as dbname - , p.schemaname - , p.relname - , p.seq_scan - , p.seq_tup_read - , COALESCE(p.idx_scan, 0) AS idx_scan - , COALESCE(p.idx_tup_fetch, 0) as idx_tup_fetch - , p.n_tup_ins - , p.n_tup_upd - , p.n_tup_del - , p.n_tup_hot_upd - , 0::bigint AS n_tup_newpage_upd - , p.n_live_tup - , p.n_dead_tup - , p.vacuum_count - , p.autovacuum_count - , p.analyze_count - , p.autoanalyze_count - FROM pg_catalog.pg_stat_user_tables p; - metrics: - - metric_name: ccp_stat_user_tables_analyze_count - data_type: sum - value_column: analyze_count - description: Number of times this table has been manually analyzed - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_autoanalyze_count - data_type: sum - value_column: autoanalyze_count - description: Number of times this table has been analyzed by the autovacuum daemon - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_autovacuum_count - data_type: sum - value_column: autovacuum_count - description: Number of times this table has been vacuumed by the autovacuum daemon - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_idx_scan - data_type: sum - value_column: idx_scan - description: Number of index scans initiated on this table - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_idx_tup_fetch - data_type: sum - value_column: idx_tup_fetch - description: Number of live rows fetched by index scans - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_n_dead_tup - value_column: n_dead_tup - description: Estimated number of dead rows - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - # FIXME: This metric returns 0, when the query returns 1 for relname="pgbackrest_info",schemaname="pg_temp_33". - # The issue doesn't occur with gte_pg16. - - metric_name: ccp_stat_user_tables_n_live_tup - value_column: n_live_tup - description: Estimated number of live rows - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_n_tup_del - data_type: sum - value_column: n_tup_del - description: Number of rows deleted - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_n_tup_hot_upd - data_type: sum - value_column: n_tup_hot_upd - description: Number of rows HOT updated (i.e., with no separate index update required) - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - # FIXME: This metric returns 0, when the query returns 1 for relname="pgbackrest_info",schemaname="pg_temp_33". - # The issue doesn't occur with gte_pg16. - - metric_name: ccp_stat_user_tables_n_tup_ins - data_type: sum - value_column: n_tup_ins - description: Number of rows inserted - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_n_tup_upd - data_type: sum - value_column: n_tup_upd - description: Number of rows updated - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - # FIXME: This metric returns 0, when the query returns 1 for relname="pgbackrest_info",schemaname="pg_temp_33". - # The issue doesn't occur with gte_pg16. - - metric_name: ccp_stat_user_tables_seq_scan - data_type: sum - value_column: seq_scan - description: Number of sequential scans initiated on this table - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - # FIXME: This metric returns 0, when the query returns 1 for relname="pgbackrest_info",schemaname="pg_temp_33". - # The issue doesn't occur with gte_pg16. - - metric_name: ccp_stat_user_tables_seq_tup_read - data_type: sum - value_column: seq_tup_read - description: Number of live rows fetched by sequential scans - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" - - metric_name: ccp_stat_user_tables_vacuum_count - data_type: sum - value_column: vacuum_count - description: Number of times this table has been manually vacuumed (not counting VACUUM FULL) - attribute_columns: ["dbname", "relname", "schemaname"] - static_attributes: - server: "localhost:5432" diff --git a/internal/collector/postgres_5m_per_db_metrics.yaml b/internal/collector/postgres_5m_per_db_metrics.yaml new file mode 100644 index 0000000000..6fcefcf9d0 --- /dev/null +++ b/internal/collector/postgres_5m_per_db_metrics.yaml @@ -0,0 +1,161 @@ +# This list of queries configures an OTel SQL Query Receiver to read pgMonitor +# metrics from Postgres. +# +# https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/-/receiver/sqlqueryreceiver#metrics-queries +# https://github.com/CrunchyData/pgmonitor/blob/v5.2.1/sql_exporter/common/crunchy_per_db_collector.yml +# +# Note: Several metrics in the `crunchy_per_db_collector` track the materialized views and +# pgMonitor-extension version -- metrics that aren't meaningful in the CPK environment. +# The list of metrics that fall into this category include +# * ccp_metric_matview_refresh_last_run_fail_count +# * ccp_metric_matview_refresh_longest_runtime_seconds +# * ccp_metric_matview_refresh_longest_runtime +# * ccp_metric_table_refresh_longest_runtime +# * ccp_pgmonitor_extension_per_db + + - sql: > + SELECT current_database() as dbname + , n.nspname as schemaname + , c.relname + , pg_catalog.pg_total_relation_size(c.oid) as bytes + FROM pg_catalog.pg_class c + JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid + WHERE NOT pg_is_other_temp_schema(n.oid) + AND relkind IN ('r', 'm', 'f'); + metrics: + - metric_name: ccp_table_size_bytes + value_type: double + value_column: bytes + description: "Table size in bytes including indexes" + attribute_columns: ["dbname", "schemaname", "relname"] + static_attributes: + server: "localhost:5432" + + - sql: > + SELECT current_database() as dbname + , p.schemaname + , p.relname + , p.seq_scan + , p.seq_tup_read + , COALESCE(p.idx_scan, 0) AS idx_scan + , COALESCE(p.idx_tup_fetch, 0) as idx_tup_fetch + , p.n_tup_ins + , p.n_tup_upd + , p.n_tup_del + , p.n_tup_hot_upd + , CASE + WHEN current_setting('server_version_num')::int >= 160000 + THEN p.n_tup_newpage_upd + ELSE 0::bigint + END AS n_tup_newpage_upd + , p.n_live_tup + , p.n_dead_tup + , p.vacuum_count + , p.autovacuum_count + , p.analyze_count + , p.autoanalyze_count + FROM pg_catalog.pg_stat_user_tables p; + metrics: + - metric_name: ccp_stat_user_tables_seq_scan + data_type: sum + value_column: seq_scan + description: "Number of sequential scans initiated on this table" + attribute_columns: ["dbname", "schemaname", "relname"] + static_attributes: + server: "localhost:5432" + - metric_name: ccp_stat_user_tables_seq_tup_read + data_type: sum + value_column: seq_tup_read + description: "Number of live rows fetched by sequential scans" + attribute_columns: ["dbname", "schemaname", "relname"] + static_attributes: + server: "localhost:5432" + - metric_name: ccp_stat_user_tables_idx_scan + data_type: sum + description: "Number of index scans initiated on this table" + value_column: idx_scan + static_attributes: + server: "localhost:5432" + attribute_columns: ["dbname", "schemaname", "relname"] + - metric_name: ccp_stat_user_tables_idx_tup_fetch + data_type: sum + description: "Number of live rows fetched by index scans" + value_column: idx_tup_fetch + static_attributes: + server: "localhost:5432" + attribute_columns: ["dbname", "schemaname", "relname"] + - metric_name: ccp_stat_user_tables_n_tup_ins + data_type: sum + description: "Number of rows inserted" + value_column: n_tup_ins + static_attributes: + server: "localhost:5432" + attribute_columns: ["dbname", "schemaname", "relname"] + - metric_name: ccp_stat_user_tables_n_tup_upd + data_type: sum + description: "Number of rows updated" + value_column: n_tup_upd + static_attributes: + server: "localhost:5432" + attribute_columns: ["dbname", "schemaname", "relname"] + - metric_name: ccp_stat_user_tables_n_tup_del + data_type: sum + description: "Number of rows deleted" + value_column: n_tup_del + static_attributes: + server: "localhost:5432" + attribute_columns: ["dbname", "schemaname", "relname"] + - metric_name: ccp_stat_user_tables_n_tup_hot_upd + data_type: sum + description: "Number of rows HOT updated (i.e., with no separate index update required)" + value_column: n_tup_hot_upd + static_attributes: + server: "localhost:5432" + attribute_columns: ["dbname", "schemaname", "relname"] + - metric_name: ccp_stat_user_tables_n_tup_newpage_upd + data_type: sum + description: "Number of rows updated where the successor version goes onto a new heap page, leaving behind an original version with a t_ctid field that points to a different heap page. These are always non-HOT updates." + value_column: n_tup_newpage_upd + static_attributes: + server: "localhost:5432" + attribute_columns: ["dbname", "schemaname", "relname"] + - metric_name: ccp_stat_user_tables_n_live_tup + description: "Estimated number of live rows" + value_column: n_live_tup + static_attributes: + server: "localhost:5432" + attribute_columns: ["dbname", "schemaname", "relname"] + - metric_name: ccp_stat_user_tables_n_dead_tup + description: "Estimated number of dead rows" + value_column: n_dead_tup + static_attributes: + server: "localhost:5432" + attribute_columns: ["dbname", "schemaname", "relname"] + - metric_name: ccp_stat_user_tables_vacuum_count + data_type: sum + description: "Number of times this table has been manually vacuumed (not counting VACUUM FULL)" + value_column: vacuum_count + static_attributes: + server: "localhost:5432" + attribute_columns: ["dbname", "schemaname", "relname"] + - metric_name: ccp_stat_user_tables_autovacuum_count + data_type: sum + description: "Number of times this table has been vacuumed by the autovacuum daemon" + value_column: autovacuum_count + static_attributes: + server: "localhost:5432" + attribute_columns: ["dbname", "schemaname", "relname"] + - metric_name: ccp_stat_user_tables_analyze_count + data_type: sum + description: "Number of times this table has been manually analyzed" + value_column: analyze_count + static_attributes: + server: "localhost:5432" + attribute_columns: ["dbname", "schemaname", "relname"] + - metric_name: ccp_stat_user_tables_autoanalyze_count + data_type: sum + description: "Number of times this table has been analyzed by the autovacuum daemon" + value_column: autoanalyze_count + static_attributes: + server: "localhost:5432" + attribute_columns: ["dbname", "schemaname", "relname"] diff --git a/internal/collector/postgres_metrics.go b/internal/collector/postgres_metrics.go index 098d1ff2be..072ec6987a 100644 --- a/internal/collector/postgres_metrics.go +++ b/internal/collector/postgres_metrics.go @@ -21,6 +21,9 @@ import ( //go:embed "generated/postgres_5s_metrics.json" var fiveSecondMetrics json.RawMessage +//go:embed "generated/postgres_5m_per_db_metrics.json" +var fiveMinutePerDBMetrics json.RawMessage + //go:embed "generated/postgres_5m_metrics.json" var fiveMinuteMetrics json.RawMessage @@ -33,15 +36,9 @@ var ltPG17Fast json.RawMessage //go:embed "generated/eq_pg16_fast_metrics.json" var eqPG16Fast json.RawMessage -//go:embed "generated/gte_pg16_slow_metrics.json" -var gtePG16Slow json.RawMessage - //go:embed "generated/lt_pg16_fast_metrics.json" var ltPG16Fast json.RawMessage -//go:embed "generated/lt_pg16_slow_metrics.json" -var ltPG16Slow json.RawMessage - type queryMetrics struct { Metrics []*metric `json:"metrics"` Query string `json:"sql"` @@ -71,6 +68,7 @@ func EnablePostgresMetrics(ctx context.Context, inCluster *v1beta1.PostgresClust // will continually append to it and blow up our ConfigMap fiveSecondMetricsClone := slices.Clone(fiveSecondMetrics) fiveMinuteMetricsClone := slices.Clone(fiveMinuteMetrics) + fiveMinutePerDBMetricsClone := slices.Clone(fiveMinutePerDBMetrics) if inCluster.Spec.PostgresVersion >= 17 { fiveSecondMetricsClone, err = appendToJSONArray(fiveSecondMetricsClone, gtePG17Fast) @@ -91,20 +89,11 @@ func EnablePostgresMetrics(ctx context.Context, inCluster *v1beta1.PostgresClust log.Error(err, "error compiling metrics for postgres 16") } - if inCluster.Spec.PostgresVersion >= 16 { - fiveMinuteMetricsClone, err = appendToJSONArray(fiveMinuteMetricsClone, gtePG16Slow) - if err != nil { - log.Error(err, "error compiling metrics for postgres 16 and greater") - } - } else { + if inCluster.Spec.PostgresVersion < 16 { fiveSecondMetricsClone, err = appendToJSONArray(fiveSecondMetricsClone, ltPG16Fast) if err != nil { log.Error(err, "error compiling fast metrics for postgres versions less than 16") } - fiveMinuteMetricsClone, err = appendToJSONArray(fiveMinuteMetricsClone, ltPG16Slow) - if err != nil { - log.Error(err, "error compiling slow metrics for postgres versions less than 16") - } } // Remove any queries that user has specified in the spec @@ -117,7 +106,7 @@ func EnablePostgresMetrics(ctx context.Context, inCluster *v1beta1.PostgresClust var fiveSecondMetricsArr []queryMetrics err := json.Unmarshal(fiveSecondMetricsClone, &fiveSecondMetricsArr) if err != nil { - log.Error(err, "error compiling postgres metrics") + log.Error(err, "error compiling five second postgres metrics") } // Remove any specified metrics from the five second metrics @@ -128,19 +117,31 @@ func EnablePostgresMetrics(ctx context.Context, inCluster *v1beta1.PostgresClust var fiveMinuteMetricsArr []queryMetrics err = json.Unmarshal(fiveMinuteMetricsClone, &fiveMinuteMetricsArr) if err != nil { - log.Error(err, "error compiling postgres metrics") + log.Error(err, "error compiling five minute postgres metrics") } // Remove any specified metrics from the five minute metrics fiveMinuteMetricsArr = removeMetricsFromQueries( inCluster.Spec.Instrumentation.Metrics.CustomQueries.Remove, fiveMinuteMetricsArr) + // Convert json to array of queryMetrics objects + var fiveMinutePerDBMetricsArr []queryMetrics + err = json.Unmarshal(fiveMinutePerDBMetricsClone, &fiveMinutePerDBMetricsArr) + if err != nil { + log.Error(err, "error compiling per-db postgres metrics") + } + + // Remove any specified metrics from the five minute per-db metrics + fiveMinutePerDBMetricsArr = removeMetricsFromQueries( + inCluster.Spec.Instrumentation.Metrics.CustomQueries.Remove, fiveMinutePerDBMetricsArr) + // Convert back to json data // The error return value can be ignored as the errchkjson linter // deems the []queryMetrics to be a safe argument: // https://github.com/breml/errchkjson fiveSecondMetricsClone, _ = json.Marshal(fiveSecondMetricsArr) fiveMinuteMetricsClone, _ = json.Marshal(fiveMinuteMetricsArr) + fiveMinutePerDBMetricsClone, _ = json.Marshal(fiveMinutePerDBMetricsArr) } // Add Prometheus exporter @@ -180,31 +181,65 @@ func EnablePostgresMetrics(ctx context.Context, inCluster *v1beta1.PostgresClust Exporters: []ComponentID{Prometheus}, } - // Add custom queries if they are defined in the spec + // Add custom queries and per-db metrics if they are defined in the spec if inCluster.Spec.Instrumentation != nil && - inCluster.Spec.Instrumentation.Metrics != nil && - inCluster.Spec.Instrumentation.Metrics.CustomQueries != nil && - inCluster.Spec.Instrumentation.Metrics.CustomQueries.Add != nil { - - for _, querySet := range inCluster.Spec.Instrumentation.Metrics.CustomQueries.Add { - // Create a receiver for the query set - receiverName := "sqlquery/" + querySet.Name - config.Receivers[receiverName] = map[string]any{ - "driver": "postgres", - "datasource": fmt.Sprintf( - `host=localhost dbname=postgres port=5432 user=%s password=${env:PGPASSWORD}`, - MonitoringUser), - "collection_interval": querySet.CollectionInterval, - // Give Postgres time to finish setup. - "initial_delay": "15s", - "queries": "${file:/etc/otel-collector/" + - querySet.Name + "/" + querySet.Queries.Key + "}", + inCluster.Spec.Instrumentation.Metrics != nil { + + if inCluster.Spec.Instrumentation.Metrics.CustomQueries != nil && + inCluster.Spec.Instrumentation.Metrics.CustomQueries.Add != nil { + + for _, querySet := range inCluster.Spec.Instrumentation.Metrics.CustomQueries.Add { + // Create a receiver for the query set + + dbs := []string{"postgres"} + if len(querySet.Databases) != 0 { + dbs = querySet.Databases + } + for _, db := range dbs { + receiverName := fmt.Sprintf( + "sqlquery/%s-%s", querySet.Name, db) + config.Receivers[receiverName] = map[string]any{ + "driver": "postgres", + "datasource": fmt.Sprintf( + `host=localhost dbname=%s port=5432 user=%s password=${env:PGPASSWORD}`, + db, + MonitoringUser), + "collection_interval": querySet.CollectionInterval, + // Give Postgres time to finish setup. + "initial_delay": "15s", + "queries": "${file:/etc/otel-collector/" + + querySet.Name + "/" + querySet.Queries.Key + "}", + } + + // Add the receiver to the pipeline + pipeline := config.Pipelines[PostgresMetrics] + pipeline.Receivers = append(pipeline.Receivers, receiverName) + config.Pipelines[PostgresMetrics] = pipeline + } } + } + if inCluster.Spec.Instrumentation.Metrics.PerDBMetricTargets != nil { + + for _, db := range inCluster.Spec.Instrumentation.Metrics.PerDBMetricTargets { + // Create a receiver for the query set for the db + receiverName := "sqlquery/" + db + config.Receivers[receiverName] = map[string]any{ + "driver": "postgres", + "datasource": fmt.Sprintf( + `host=localhost dbname=%s port=5432 user=%s password=${env:PGPASSWORD}`, + db, + MonitoringUser), + "collection_interval": "5m", + // Give Postgres time to finish setup. + "initial_delay": "15s", + "queries": slices.Clone(fiveMinutePerDBMetricsClone), + } - // Add the receiver to the pipeline - pipeline := config.Pipelines[PostgresMetrics] - pipeline.Receivers = append(pipeline.Receivers, receiverName) - config.Pipelines[PostgresMetrics] = pipeline + // Add the receiver to the pipeline + pipeline := config.Pipelines[PostgresMetrics] + pipeline.Receivers = append(pipeline.Receivers, receiverName) + config.Pipelines[PostgresMetrics] = pipeline + } } } } diff --git a/pkg/apis/postgres-operator.crunchydata.com/v1beta1/instrumentation_types.go b/pkg/apis/postgres-operator.crunchydata.com/v1beta1/instrumentation_types.go index d3f6882271..9481d748cc 100644 --- a/pkg/apis/postgres-operator.crunchydata.com/v1beta1/instrumentation_types.go +++ b/pkg/apis/postgres-operator.crunchydata.com/v1beta1/instrumentation_types.go @@ -107,6 +107,11 @@ type InstrumentationMetricsSpec struct { // --- // +optional CustomQueries *InstrumentationCustomQueriesSpec `json:"customQueries,omitempty"` + + // User defined databases to target for default per-db metrics + // --- + // +optional + PerDBMetricTargets []string `json:"perDBMetricTargets,omitempty"` } type InstrumentationCustomQueriesSpec struct { @@ -159,6 +164,12 @@ type InstrumentationCustomQueries struct { // +default="5s" // +optional CollectionInterval *Duration `json:"collectionInterval,omitempty"` + + // The databases to target with added custom queries. + // Default behavior is to target `postgres`. + // --- + // +optional + Databases []string `json:"databases,omitempty"` } // --- diff --git a/pkg/apis/postgres-operator.crunchydata.com/v1beta1/zz_generated.deepcopy.go b/pkg/apis/postgres-operator.crunchydata.com/v1beta1/zz_generated.deepcopy.go index 8ee494d5f8..7d12eccefb 100644 --- a/pkg/apis/postgres-operator.crunchydata.com/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/postgres-operator.crunchydata.com/v1beta1/zz_generated.deepcopy.go @@ -481,6 +481,11 @@ func (in *InstrumentationCustomQueries) DeepCopyInto(out *InstrumentationCustomQ *out = new(Duration) **out = **in } + if in.Databases != nil { + in, out := &in.Databases, &out.Databases + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstrumentationCustomQueries. @@ -558,6 +563,11 @@ func (in *InstrumentationMetricsSpec) DeepCopyInto(out *InstrumentationMetricsSp *out = new(InstrumentationCustomQueriesSpec) (*in).DeepCopyInto(*out) } + if in.PerDBMetricTargets != nil { + in, out := &in.PerDBMetricTargets, &out.PerDBMetricTargets + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstrumentationMetricsSpec. diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/11--add-logs-exporter.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/11--add-logs-exporter.yaml deleted file mode 100644 index 298adb06b4..0000000000 --- a/testing/kuttl/e2e/otel-logging-and-metrics/11--add-logs-exporter.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -apply: -- files/11--add-logs-exporter.yaml -assert: -- files/11-logs-exporter-added.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/11--add-per-db-metrics-to-postgrescluster.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/11--add-per-db-metrics-to-postgrescluster.yaml new file mode 100644 index 0000000000..8e73e1874e --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/11--add-per-db-metrics-to-postgrescluster.yaml @@ -0,0 +1,4 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- files/11--add-per-db-metrics.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/12-assert-per-db-queries.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/12-assert-per-db-queries.yaml new file mode 100644 index 0000000000..10a8645b32 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/12-assert-per-db-queries.yaml @@ -0,0 +1,32 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +commands: +# First, check that all containers in the instance pod are ready. +# Then, grab the collector metrics output and check that the per-db metrics +# are present for the single added target. +- script: | + retry() { bash -ceu 'printf "$1\nSleeping...\n" && sleep 5' - "$@"; } + check_containers_ready() { bash -ceu 'echo "$1" | jq -e ".[] | select(.type==\"ContainersReady\") | .status==\"True\""' - "$@"; } + contains() { bash -ceu '[[ "$1" == *"$2"* ]]' - "$@"; } + + pod=$(kubectl get pods -o name -n "${NAMESPACE}" \ + -l postgres-operator.crunchydata.com/cluster=otel-cluster,postgres-operator.crunchydata.com/data=postgres) + [ "$pod" = "" ] && retry "Pod not found" && exit 1 + + condition_json=$(kubectl get "${pod}" -n "${NAMESPACE}" -o jsonpath="{.status.conditions}") + [ "$condition_json" = "" ] && retry "conditions not found" && exit 1 + { check_containers_ready "$condition_json"; } || { + retry "containers not ready" + exit 1 + } + + scrape_metrics=$(kubectl exec "${pod}" -c collector -n "${NAMESPACE}" -- \ + curl --insecure --silent http://localhost:9187/metrics) + { contains "${scrape_metrics}" 'ccp_table_size_bytes{dbname="pikachu"'; } || { + retry "ccp_table_size_bytes not found for pikachu" + exit 1 + } + { ! contains "${scrape_metrics}" 'ccp_table_size_bytes{dbname="onix"'; } || { + retry "ccp_table_size_bytes found for onix" + exit 1 + } diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/13--add-second-per-db-metrics-to-postgrescluster.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/13--add-second-per-db-metrics-to-postgrescluster.yaml new file mode 100644 index 0000000000..12791e5066 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/13--add-second-per-db-metrics-to-postgrescluster.yaml @@ -0,0 +1,4 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- files/13--add-per-db-metrics.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/13--cluster-no-backups.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/13--cluster-no-backups.yaml deleted file mode 100644 index b4c6f272f6..0000000000 --- a/testing/kuttl/e2e/otel-logging-and-metrics/13--cluster-no-backups.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -apply: -- files/13--create-cluster.yaml -assert: -- files/13-cluster-created.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/14-assert-per-db-queries-for-multiple-targets.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/14-assert-per-db-queries-for-multiple-targets.yaml new file mode 100644 index 0000000000..bfbe2b1578 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/14-assert-per-db-queries-for-multiple-targets.yaml @@ -0,0 +1,32 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +commands: +# First, check that all containers in the instance pod are ready. +# Then, grab the collector metrics output and check that the per-db metrics +# are present for both added targets. +- script: | + retry() { bash -ceu 'printf "$1\nSleeping...\n" && sleep 5' - "$@"; } + check_containers_ready() { bash -ceu 'echo "$1" | jq -e ".[] | select(.type==\"ContainersReady\") | .status==\"True\""' - "$@"; } + contains() { bash -ceu '[[ "$1" == *"$2"* ]]' - "$@"; } + + pod=$(kubectl get pods -o name -n "${NAMESPACE}" \ + -l postgres-operator.crunchydata.com/cluster=otel-cluster,postgres-operator.crunchydata.com/data=postgres) + [ "$pod" = "" ] && retry "Pod not found" && exit 1 + + condition_json=$(kubectl get "${pod}" -n "${NAMESPACE}" -o jsonpath="{.status.conditions}") + [ "$condition_json" = "" ] && retry "conditions not found" && exit 1 + { check_containers_ready "$condition_json"; } || { + retry "containers not ready" + exit 1 + } + + scrape_metrics=$(kubectl exec "${pod}" -c collector -n "${NAMESPACE}" -- \ + curl --insecure --silent http://localhost:9187/metrics) + { contains "${scrape_metrics}" 'ccp_table_size_bytes{dbname="pikachu"'; } || { + retry "ccp_table_size_bytes not found for pikachu" + exit 1 + } + { contains "${scrape_metrics}" 'ccp_table_size_bytes{dbname="onix"'; } || { + retry "ccp_table_size_bytes not found for onix" + exit 1 + } diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/15--remove-per-db-metrics-from-postgrescluster.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/15--remove-per-db-metrics-from-postgrescluster.yaml new file mode 100644 index 0000000000..549f21d55e --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/15--remove-per-db-metrics-from-postgrescluster.yaml @@ -0,0 +1,4 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- files/15--remove-per-db-metrics.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/16-assert-per-db-query-removed.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/16-assert-per-db-query-removed.yaml new file mode 100644 index 0000000000..d75c06827d --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/16-assert-per-db-query-removed.yaml @@ -0,0 +1,32 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +commands: +# First, check that all containers in the instance pod are ready. +# Then, grab the collector metrics output and check that the per-db metrics +# are absent from the targets since they've been removed. +- script: | + retry() { bash -ceu 'printf "$1\nSleeping...\n" && sleep 5' - "$@"; } + check_containers_ready() { bash -ceu 'echo "$1" | jq -e ".[] | select(.type==\"ContainersReady\") | .status==\"True\""' - "$@"; } + contains() { bash -ceu '[[ "$1" == *"$2"* ]]' - "$@"; } + + pod=$(kubectl get pods -o name -n "${NAMESPACE}" \ + -l postgres-operator.crunchydata.com/cluster=otel-cluster,postgres-operator.crunchydata.com/data=postgres) + [ "$pod" = "" ] && retry "Pod not found" && exit 1 + + condition_json=$(kubectl get "${pod}" -n "${NAMESPACE}" -o jsonpath="{.status.conditions}") + [ "$condition_json" = "" ] && retry "conditions not found" && exit 1 + { check_containers_ready "$condition_json"; } || { + retry "containers not ready" + exit 1 + } + + scrape_metrics=$(kubectl exec "${pod}" -c collector -n "${NAMESPACE}" -- \ + curl --insecure --silent http://localhost:9187/metrics) + { ! contains "${scrape_metrics}" 'ccp_table_size_bytes{dbname="pikachu"'; } || { + retry "ccp_table_size_bytes found for pikachu" + exit 1 + } + { ! contains "${scrape_metrics}" 'ccp_table_size_bytes{dbname="onix"'; } || { + retry "ccp_table_size_bytes found for onix" + exit 1 + } diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/17--add-custom-queries-per-db.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/17--add-custom-queries-per-db.yaml new file mode 100644 index 0000000000..e1b2ebfeb3 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/17--add-custom-queries-per-db.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- files/17--add-custom-queries-per-db.yaml +assert: +- files/17-custom-queries-per-db-added.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/18-assert-custom-queries-per-db.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/18-assert-custom-queries-per-db.yaml new file mode 100644 index 0000000000..a4631bf9e8 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/18-assert-custom-queries-per-db.yaml @@ -0,0 +1,42 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +commands: +# First, check that all containers in the instance pod are ready. +# Then, grab the collector metrics output and check that the two metrics that we +# checked for earlier are no longer there. +# Then, check that the two custom metrics that we added are present +# only for the targets that were specified. +- script: | + retry() { bash -ceu 'printf "$1\nSleeping...\n" && sleep 5' - "$@"; } + check_containers_ready() { bash -ceu 'echo "$1" | jq -e ".[] | select(.type==\"ContainersReady\") | .status==\"True\""' - "$@"; } + contains() { bash -ceu '[[ "$1" == *"$2"* ]]' - "$@"; } + + pod=$(kubectl get pods -o name -n "${NAMESPACE}" \ + -l postgres-operator.crunchydata.com/cluster=otel-cluster,postgres-operator.crunchydata.com/data=postgres) + [ "$pod" = "" ] && retry "Pod not found" && exit 1 + + condition_json=$(kubectl get "${pod}" -n "${NAMESPACE}" -o jsonpath="{.status.conditions}") + [ "$condition_json" = "" ] && retry "conditions not found" && exit 1 + { check_containers_ready "$condition_json"; } || { + retry "containers not ready" + exit 1 + } + + scrape_metrics=$(kubectl exec "${pod}" -c collector -n "${NAMESPACE}" -- \ + curl --insecure --silent http://localhost:9187/metrics) + { contains "${scrape_metrics}" 'ccp_table_size_bytes_1{dbname="pikachu"'; } || { + retry "custom metric not found for pikachu db" + exit 1 + } + { contains "${scrape_metrics}" 'ccp_table_size_bytes_1{dbname="onix"'; } || { + retry "custom metric found for onix db" + exit 1 + } + { contains "${scrape_metrics}" 'ccp_table_size_bytes_2{dbname="onix"'; } || { + retry "custom metric not found for onix db" + exit 1 + } + { ! contains "${scrape_metrics}" 'ccp_table_size_bytes_2{dbname="pikachu"'; } || { + retry "custom metric found for pikachu db" + exit 1 + } diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/19--add-logs-exporter.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/19--add-logs-exporter.yaml new file mode 100644 index 0000000000..dc85f9707c --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/19--add-logs-exporter.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- files/19--add-logs-exporter.yaml +assert: +- files/19-logs-exporter-added.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/12-assert-logs-exported.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/20-assert-logs-exported.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/12-assert-logs-exported.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/20-assert-logs-exported.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/21--cluster-no-backups.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/21--cluster-no-backups.yaml new file mode 100644 index 0000000000..a24e1c8f2d --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/21--cluster-no-backups.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +apply: +- files/21--create-cluster.yaml +assert: +- files/21-cluster-created.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/14-assert-instance.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/22-assert-instance.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/14-assert-instance.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/22-assert-instance.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/15--cluster-add-backups.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/23--cluster-add-backups.yaml similarity index 50% rename from testing/kuttl/e2e/otel-logging-and-metrics/15--cluster-add-backups.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/23--cluster-add-backups.yaml index 3bdd0b37e8..52990e4372 100644 --- a/testing/kuttl/e2e/otel-logging-and-metrics/15--cluster-add-backups.yaml +++ b/testing/kuttl/e2e/otel-logging-and-metrics/23--cluster-add-backups.yaml @@ -1,6 +1,6 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep apply: -- files/15--add-backups.yaml +- files/23--add-backups.yaml assert: -- files/15-backups-added.yaml +- files/23-backups-added.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/16--remove-backups.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/24--remove-backups.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/16--remove-backups.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/24--remove-backups.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/17--annotate-cluster.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/25--annotate-cluster.yaml similarity index 86% rename from testing/kuttl/e2e/otel-logging-and-metrics/17--annotate-cluster.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/25--annotate-cluster.yaml index 2da3da58a3..d017479ca3 100644 --- a/testing/kuttl/e2e/otel-logging-and-metrics/17--annotate-cluster.yaml +++ b/testing/kuttl/e2e/otel-logging-and-metrics/25--annotate-cluster.yaml @@ -4,4 +4,4 @@ commands: - command: kubectl annotate postgrescluster otel-cluster-no-backups postgres-operator.crunchydata.com/authorizeBackupRemoval="true" namespaced: true assert: -- files/17-backups-removed.yaml +- files/25-backups-removed.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/README.md b/testing/kuttl/e2e/otel-logging-and-metrics/README.md index e14bdd899c..46e3169e71 100644 --- a/testing/kuttl/e2e/otel-logging-and-metrics/README.md +++ b/testing/kuttl/e2e/otel-logging-and-metrics/README.md @@ -6,9 +6,9 @@ This test assumes that the operator has both OpenTelemetryLogs and OpenTelemetry ## Process -1. Create a basic cluster with pgbouncer and pgadmin in place. +1. Create a basic cluster with pgbouncer and pgadmin in place. (00) 1. Ensure cluster comes up, that all containers are running and ready, and that the initial backup is complete. -2. Add the `instrumentation` spec to both PostgresCluster and PGAdmin manifests. +2. Add the `instrumentation` spec to both PostgresCluster and PGAdmin manifests. (01-08) 1. Ensure that OTel collector containers and `crunchy-otel-collector` labels are added to the four pods (postgres instance, repo-host, pgbouncer, & pgadmin) and that the collector containers are running and ready. 2. Assert that the instance pod collector is getting postgres and patroni metrics and postgres, patroni, and pgbackrest logs. 3. Assert that the pgbouncer pod collector is getting pgbouncer metrics and logs. @@ -16,14 +16,19 @@ This test assumes that the operator has both OpenTelemetryLogs and OpenTelemetry 5. Assert that the repo-host pod collector is NOT getting pgbackrest logs. We do not expect logs yet as the initial backup completed and created a log file; however, we configure the collector to only ingest new logs after it has started up. 6. Create a manual backup and ensure that it completes successfully. 7. Ensure that the repo-host pod collector is now getting pgbackrest logs. -3. Add both "add" and "remove" custom queries to the PostgresCluster `instrumentation` spec and create a ConfigMap that holds the custom queries to add. +3. Add both "add" and "remove" custom queries to the PostgresCluster `instrumentation` spec and create a ConfigMap that holds the custom queries to add. (09-10) 1. Ensure that the ConfigMap is created. 2. Assert that the metrics that were removed (which we checked for earlier) are in fact no longer present in the collector metrics. 3. Assert that the custom metrics that were added are present in the collector metrics. -4. Add an `otlp` exporter to both PostgresCluster and PGAdmin `instrumentation` specs and create a standalone OTel collector to receive data from our sidecar collectors. +4. Exercise per-db metric functionality by adding users, per-db targets, removing metrics from per-db defaults, adding custom metric db target. (11-18) + 1. Add users and per-db target, assert that per-db default metric is available for named target. + 2. Add second per-db target, assert that per-db default metric is available for all named targets. + 3. Remove per-db metric, assert that the per-db default metric is absent for all targets. + 4. Add custom metrics with a specified db, assert that we get that metric just for the specified target. +5. Add an `otlp` exporter to both PostgresCluster and PGAdmin `instrumentation` specs and create a standalone OTel collector to receive data from our sidecar collectors. (9-20) 1. Ensure that the ConfigMap, Service, and Deployment for the standalone OTel collector come up and that the collector container is running and ready. 2. Assert that the standalone collector is receiving logs from all of our components (i.e. the standalone collector is getting logs for postgres, patroni, pgbackrest, pgbouncer, pgadmin, and gunicorn). -5. Create a new cluster with `instrumentation` spec in place, but no `backups` spec to test the OTel features with optional backups. +6. Create a new cluster with `instrumentation` spec in place, but no `backups` spec to test the OTel features with optional backups. (21-25) 1. Ensure that the cluster comes up and the database and collector containers are running and ready. 2. Add a backups spec to the new cluster and ensure that pgbackrest is added to the instance pod, a repo-host pod is created, and the collector runs on both pods. 3. Remove the backups spec from the new cluster. diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/11--add-per-db-metrics.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/11--add-per-db-metrics.yaml new file mode 100644 index 0000000000..1cf4c28a83 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/files/11--add-per-db-metrics.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: postgres-operator.crunchydata.com/v1beta1 +kind: PostgresCluster +metadata: + name: otel-cluster +spec: + users: + - name: ash + databases: + - pikachu + - name: brock + databases: + - onix + instrumentation: + metrics: + perDBMetricTargets: + - pikachu diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/13--add-per-db-metrics.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/13--add-per-db-metrics.yaml new file mode 100644 index 0000000000..c383238be9 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/files/13--add-per-db-metrics.yaml @@ -0,0 +1,11 @@ +--- +apiVersion: postgres-operator.crunchydata.com/v1beta1 +kind: PostgresCluster +metadata: + name: otel-cluster +spec: + instrumentation: + metrics: + perDBMetricTargets: + - pikachu + - onix diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/15--remove-per-db-metrics.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/15--remove-per-db-metrics.yaml new file mode 100644 index 0000000000..4421de8482 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/files/15--remove-per-db-metrics.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: postgres-operator.crunchydata.com/v1beta1 +kind: PostgresCluster +metadata: + name: otel-cluster +spec: + instrumentation: + metrics: + customQueries: + remove: + - ccp_connection_stats_active + - ccp_database_size_bytes + - ccp_table_size_bytes diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/17--add-custom-queries-per-db.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/17--add-custom-queries-per-db.yaml new file mode 100644 index 0000000000..92360a4a9a --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/files/17--add-custom-queries-per-db.yaml @@ -0,0 +1,62 @@ +--- +apiVersion: postgres-operator.crunchydata.com/v1beta1 +kind: PostgresCluster +metadata: + name: otel-cluster +spec: + instrumentation: + metrics: + customQueries: + add: + - name: custom1 + databases: [pikachu, onix] + queries: + name: my-custom-queries2 + key: custom1.yaml + - name: custom2 + databases: [onix] + queries: + name: my-custom-queries2 + key: custom2.yaml +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: my-custom-queries2 +data: + custom1.yaml: | + - sql: > + SELECT current_database() as dbname + , n.nspname as schemaname + , c.relname + , pg_catalog.pg_total_relation_size(c.oid) as bytes + FROM pg_catalog.pg_class c + JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid + WHERE NOT pg_is_other_temp_schema(n.oid) + AND relkind IN ('r', 'm', 'f'); + metrics: + - metric_name: ccp_table_size_bytes_1 + value_type: double + value_column: bytes + description: "Table size in bytes including indexes" + attribute_columns: ["dbname", "schemaname", "relname"] + static_attributes: + server: "localhost:5432" + custom2.yaml: | + - sql: > + SELECT current_database() as dbname + , n.nspname as schemaname + , c.relname + , pg_catalog.pg_total_relation_size(c.oid) as bytes + FROM pg_catalog.pg_class c + JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid + WHERE NOT pg_is_other_temp_schema(n.oid) + AND relkind IN ('r', 'm', 'f'); + metrics: + - metric_name: ccp_table_size_bytes_2 + value_type: double + value_column: bytes + description: "Table size in bytes including indexes" + attribute_columns: ["dbname", "schemaname", "relname"] + static_attributes: + server: "localhost:5432" \ No newline at end of file diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/17-custom-queries-per-db-added.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/17-custom-queries-per-db-added.yaml new file mode 100644 index 0000000000..5bd9cec286 --- /dev/null +++ b/testing/kuttl/e2e/otel-logging-and-metrics/files/17-custom-queries-per-db-added.yaml @@ -0,0 +1,124 @@ +apiVersion: postgres-operator.crunchydata.com/v1beta1 +kind: PostgresCluster +metadata: + name: otel-cluster +status: + instances: + - name: instance1 + readyReplicas: 1 + replicas: 1 + updatedReplicas: 1 + proxy: + pgBouncer: + readyReplicas: 1 + replicas: 1 +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + postgres-operator.crunchydata.com/data: postgres + postgres-operator.crunchydata.com/role: master + postgres-operator.crunchydata.com/cluster: otel-cluster + postgres-operator.crunchydata.com/crunchy-otel-collector: "true" +status: + containerStatuses: + - name: collector + ready: true + started: true + - name: database + ready: true + started: true + - name: pgbackrest + ready: true + started: true + - name: pgbackrest-config + ready: true + started: true + - name: replication-cert-copy + ready: true + started: true + phase: Running +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + postgres-operator.crunchydata.com/data: pgbackrest + postgres-operator.crunchydata.com/cluster: otel-cluster + postgres-operator.crunchydata.com/crunchy-otel-collector: "true" +status: + containerStatuses: + - name: collector + ready: true + started: true + - name: pgbackrest + ready: true + started: true + - name: pgbackrest-config + ready: true + started: true + phase: Running +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + postgres-operator.crunchydata.com/role: pgbouncer + postgres-operator.crunchydata.com/cluster: otel-cluster + postgres-operator.crunchydata.com/crunchy-otel-collector: "true" +status: + containerStatuses: + - name: collector + ready: true + started: true + - name: pgbouncer + ready: true + started: true + - name: pgbouncer-config + ready: true + started: true + phase: Running +--- +apiVersion: v1 +kind: Service +metadata: + name: otel-cluster-primary +--- +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + postgres-operator.crunchydata.com/role: pgadmin + postgres-operator.crunchydata.com/pgadmin: otel-pgadmin +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + postgres-operator.crunchydata.com/data: pgadmin + postgres-operator.crunchydata.com/role: pgadmin + postgres-operator.crunchydata.com/pgadmin: otel-pgadmin + postgres-operator.crunchydata.com/crunchy-otel-collector: "true" +status: + containerStatuses: + - name: collector + ready: true + started: true + - name: pgadmin + ready: true + started: true + phase: Running +--- +apiVersion: v1 +kind: Secret +metadata: + labels: + postgres-operator.crunchydata.com/role: pgadmin + postgres-operator.crunchydata.com/pgadmin: otel-pgadmin +type: Opaque +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: my-custom-queries2 diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/11--add-logs-exporter.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/19--add-logs-exporter.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/files/11--add-logs-exporter.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/files/19--add-logs-exporter.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/11-logs-exporter-added.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/19-logs-exporter-added.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/files/11-logs-exporter-added.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/files/19-logs-exporter-added.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/13--create-cluster.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/21--create-cluster.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/files/13--create-cluster.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/files/21--create-cluster.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/13-cluster-created.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/21-cluster-created.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/files/13-cluster-created.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/files/21-cluster-created.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/15--add-backups.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/23--add-backups.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/files/15--add-backups.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/files/23--add-backups.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/15-backups-added.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/23-backups-added.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/files/15-backups-added.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/files/23-backups-added.yaml diff --git a/testing/kuttl/e2e/otel-logging-and-metrics/files/17-backups-removed.yaml b/testing/kuttl/e2e/otel-logging-and-metrics/files/25-backups-removed.yaml similarity index 100% rename from testing/kuttl/e2e/otel-logging-and-metrics/files/17-backups-removed.yaml rename to testing/kuttl/e2e/otel-logging-and-metrics/files/25-backups-removed.yaml