diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23154c3..60aced5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,6 @@ jobs: - name: Install extra build dependencies run: sudo apt-get install -y golang - name: Build - run: go generate && go build + run: make REVISION="xxxx" BRANCH="ci" VERSION="unittest" BUILD_USER="ci" BUILD_DATE="0000-00-00" - name: Test on PostgreSQL ${{ matrix.pg }} run: if ! make installcheck; then cat regression.diffs; exit 1; fi diff --git a/expected/all_0.out b/expected/all_0.out index 6ba959b..f8dfeae 100644 --- a/expected/all_0.out +++ b/expected/all_0.out @@ -102,7 +102,7 @@ go_memstats_sys_bytes go_threads # HELP pg_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which pg_exporter was built. # TYPE pg_exporter_build_info gauge -pg_exporter_build_info{branch="",goversion="",revision="",version=""} +pg_exporter_build_info{branch="ci",goversion="",revision="xxxx",version="unittest"} # HELP postgresql_archiver_archived_count_total Number of WAL files that have been successfully archived # TYPE postgresql_archiver_archived_count_total counter postgresql_archiver_archived_count_total diff --git a/expected/all_1.out b/expected/all_1.out index 733cfd6..07237be 100644 --- a/expected/all_1.out +++ b/expected/all_1.out @@ -102,7 +102,7 @@ go_memstats_sys_bytes go_threads # HELP pg_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which pg_exporter was built. # TYPE pg_exporter_build_info gauge -pg_exporter_build_info{branch="",goversion="",revision="",version=""} +pg_exporter_build_info{branch="ci",goversion="",revision="xxxx",version="unittest"} # HELP postgresql_archiver_archived_count_total Number of WAL files that have been successfully archived # TYPE postgresql_archiver_archived_count_total counter postgresql_archiver_archived_count_total diff --git a/expected/all_2.out b/expected/all_2.out index 7dd344f..d333f32 100644 --- a/expected/all_2.out +++ b/expected/all_2.out @@ -102,7 +102,7 @@ go_memstats_sys_bytes go_threads # HELP pg_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which pg_exporter was built. # TYPE pg_exporter_build_info gauge -pg_exporter_build_info{branch="",goversion="",revision="",version=""} +pg_exporter_build_info{branch="ci",goversion="",revision="xxxx",version="unittest"} # HELP postgresql_archiver_archived_count_total Number of WAL files that have been successfully archived # TYPE postgresql_archiver_archived_count_total counter postgresql_archiver_archived_count_total diff --git a/expected/all_3.out b/expected/all_3.out index 5096e89..be82906 100644 --- a/expected/all_3.out +++ b/expected/all_3.out @@ -102,7 +102,7 @@ go_memstats_sys_bytes go_threads # HELP pg_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which pg_exporter was built. # TYPE pg_exporter_build_info gauge -pg_exporter_build_info{branch="",goversion="",revision="",version=""} +pg_exporter_build_info{branch="ci",goversion="",revision="xxxx",version="unittest"} # HELP postgresql_archiver_archived_count_total Number of WAL files that have been successfully archived # TYPE postgresql_archiver_archived_count_total counter postgresql_archiver_archived_count_total diff --git a/expected/all_4.out b/expected/all_4.out index 806d58a..7084377 100644 --- a/expected/all_4.out +++ b/expected/all_4.out @@ -102,7 +102,7 @@ go_memstats_sys_bytes go_threads # HELP pg_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which pg_exporter was built. # TYPE pg_exporter_build_info gauge -pg_exporter_build_info{branch="",goversion="",revision="",version=""} +pg_exporter_build_info{branch="ci",goversion="",revision="xxxx",version="unittest"} # HELP postgresql_archiver_archived_count_total Number of WAL files that have been successfully archived # TYPE postgresql_archiver_archived_count_total counter postgresql_archiver_archived_count_total @@ -151,6 +151,9 @@ postgresql_bgwriter_maxwritten_clean_total # HELP postgresql_bgwriter_stats_reset Time at which these statistics were last reset # TYPE postgresql_bgwriter_stats_reset counter postgresql_bgwriter_stats_reset +# HELP postgresql_database_active_time_total Time spent executing SQL statements in this database, in milliseconds +# TYPE postgresql_database_active_time_total counter +postgresql_database_active_time_total{database="contrib_regression",database_id=""} # HELP postgresql_database_backends Number of backends currently connected to this database # TYPE postgresql_database_backends gauge postgresql_database_backends{database="contrib_regression",database_id=""} @@ -190,6 +193,9 @@ postgresql_database_deadlocks_total{database="contrib_regression",database_id="" # HELP postgresql_database_frozen_xid All transaction IDs before this one have been replaced with a permanent transaction ID in this database # TYPE postgresql_database_frozen_xid counter postgresql_database_frozen_xid{database="contrib_regression"} +# HELP postgresql_database_idle_in_transaction_time_total Time spent idling while in a transaction in this database, in milliseconds +# TYPE postgresql_database_idle_in_transaction_time_total counter +postgresql_database_idle_in_transaction_time_total{database="contrib_regression",database_id=""} # HELP postgresql_database_min_mxid All multixact IDs before this one have been replaced with a transaction ID in this database # TYPE postgresql_database_min_mxid counter postgresql_database_min_mxid{database="contrib_regression"} @@ -208,6 +214,21 @@ postgresql_database_rows_returned_total{database="contrib_regression",database_i # HELP postgresql_database_rows_updated_total Number of rows updated by queries in this database # TYPE postgresql_database_rows_updated_total counter postgresql_database_rows_updated_total{database="contrib_regression",database_id=""} +# HELP postgresql_database_session_time_total Time spent by database sessions in this database, in milliseconds +# TYPE postgresql_database_session_time_total counter +postgresql_database_session_time_total{database="contrib_regression",database_id=""} +# HELP postgresql_database_sessions_abandoned_count Number of database sessions to this database that were terminated because connection to the client was lost +# TYPE postgresql_database_sessions_abandoned_count counter +postgresql_database_sessions_abandoned_count{database="contrib_regression",database_id=""} +# HELP postgresql_database_sessions_count Total number of sessions established to this database +# TYPE postgresql_database_sessions_count counter +postgresql_database_sessions_count{database="contrib_regression",database_id=""} +# HELP postgresql_database_sessions_fatal_count Number of database sessions to this database that were terminated by fatal errors +# TYPE postgresql_database_sessions_fatal_count counter +postgresql_database_sessions_fatal_count{database="contrib_regression",database_id=""} +# HELP postgresql_database_sessions_killed_count Number of database sessions to this database that were terminated by operator intervention +# TYPE postgresql_database_sessions_killed_count counter +postgresql_database_sessions_killed_count{database="contrib_regression",database_id=""} # HELP postgresql_database_stats_reset Time at which these statistics were last reset # TYPE postgresql_database_stats_reset counter postgresql_database_stats_reset{database="contrib_regression",database_id=""} diff --git a/expected/start.out b/expected/start.out index 3d1de21..39e1522 100644 --- a/expected/start.out +++ b/expected/start.out @@ -4,7 +4,7 @@ show unix_socket_directories \gset \setenv PGHOST :unix_socket_directories select current_database() as database \gset \setenv PGDATABASE :database -\! ./pg-exporter --log.level=warn & echo $! > pid; sleep 0.1 +\! ./bin/pg_exporter --log.level=warn & echo $! > pid; sleep 0.1 \! curl -sf localhost:9135/metrics | grep postgresql_up # HELP postgresql_up Whether the PostgreSQL server is up. # TYPE postgresql_up gauge diff --git a/expected/stat_database_4.out b/expected/stat_database_4.out new file mode 100644 index 0000000..4c8fff0 --- /dev/null +++ b/expected/stat_database_4.out @@ -0,0 +1,38 @@ +select current_setting('server_version_num')::int / 10000 >= 10 as is_pg_10; + is_pg_10 +---------- + t +(1 row) + +\! curl -sf localhost:9135/metrics | grep "^postgresql_database_" | sed -e 's/database_id="[0-9]*"/database_id=""/' -e 's/ \([1-9]\|0\.\).*/ NNN/' +postgresql_database_active_time_total{database="contrib_regression",database_id=""} NNN +postgresql_database_backends{database="contrib_regression",database_id=""} NNN +postgresql_database_blk_read_seconds_total{database="contrib_regression",database_id=""} 0 +postgresql_database_blk_write_seconds_total{database="contrib_regression",database_id=""} 0 +postgresql_database_blocks_hit_total{database="contrib_regression",database_id=""} NNN +postgresql_database_blocks_read_total{database="contrib_regression",database_id=""} NNN +postgresql_database_conflicts_confl_bufferpin_total{database="contrib_regression",database_id=""} 0 +postgresql_database_conflicts_confl_deadlock_total{database="contrib_regression",database_id=""} 0 +postgresql_database_conflicts_confl_lock_total{database="contrib_regression",database_id=""} 0 +postgresql_database_conflicts_confl_snapshot_total{database="contrib_regression",database_id=""} 0 +postgresql_database_conflicts_confl_tablespace_total{database="contrib_regression",database_id=""} 0 +postgresql_database_conflicts_total{database="contrib_regression",database_id=""} 0 +postgresql_database_deadlocks_total{database="contrib_regression",database_id=""} 0 +postgresql_database_frozen_xid{database="contrib_regression"} NNN +postgresql_database_idle_in_transaction_time_total{database="contrib_regression",database_id=""} 0 +postgresql_database_min_mxid{database="contrib_regression"} NNN +postgresql_database_rows_deleted_total{database="contrib_regression",database_id=""} 0 +postgresql_database_rows_fetched_total{database="contrib_regression",database_id=""} NNN +postgresql_database_rows_inserted_total{database="contrib_regression",database_id=""} 0 +postgresql_database_rows_returned_total{database="contrib_regression",database_id=""} NNN +postgresql_database_rows_updated_total{database="contrib_regression",database_id=""} 0 +postgresql_database_session_time_total{database="contrib_regression",database_id=""} NNN +postgresql_database_sessions_abandoned_count{database="contrib_regression",database_id=""} 0 +postgresql_database_sessions_count{database="contrib_regression",database_id=""} NNN +postgresql_database_sessions_fatal_count{database="contrib_regression",database_id=""} 0 +postgresql_database_sessions_killed_count{database="contrib_regression",database_id=""} 0 +postgresql_database_stats_reset{database="contrib_regression",database_id=""} NNN +postgresql_database_temp_bytes_total{database="contrib_regression",database_id=""} 0 +postgresql_database_temp_files_total{database="contrib_regression",database_id=""} 0 +postgresql_database_xact_commited_total{database="contrib_regression",database_id=""} NNN +postgresql_database_xact_rolledback_total{database="contrib_regression",database_id=""} 0 diff --git a/sql/start.sql b/sql/start.sql index 89ee365..6d04ae3 100644 --- a/sql/start.sql +++ b/sql/start.sql @@ -5,6 +5,6 @@ show unix_socket_directories \gset select current_database() as database \gset \setenv PGDATABASE :database -\! ./pg-exporter --log.level=warn & echo $! > pid; sleep 0.1 +\! ./bin/pg_exporter --log.level=warn & echo $! > pid; sleep 0.1 \! curl -sf localhost:9135/metrics | grep postgresql_up