Skip to content

Monitor PostgreSQL flavor in usage ping

Krasimir Angelov requested to merge detect-postgresql-flavor into master

What does this MR do and why?

This MR adds PostgreSQL flavor to usage data metrics.

Flavor can be one of :

  • "Amazon Aurora PostgreSQL"
  • "PostgreSQL on Amazon RDS"
  • "Cloud SQL for PostgreSQL"
  • "Azure Database for PostgreSQL - Flexible Server"
  • "Azure Database for PostgreSQL - Single Server"
  • "null" (if we can't detect what flavor is used)

https://gitlab.com/gitlab-services/version-gitlab-com/-/merge_requests/637 will add new database column to VersionApp where we'll store this new data.

Related to https://gitlab.com/gitlab-org/database-team/team-tasks/-/issues/218.

How to set up and validate locally

  1. In rails console execute the following
    > usage_data = ServicePing::BuildPayloadService.new.execute
    > usage_data[:database]
  2. For standard PostgreSQL you should see
    > {:adapter=>"postgresql", :version=>"12.9", :pg_system_id=>6976470454675971923, :flavor=>nil}
  3. To simulate Aurora first create the following function in your database
    > CREATE OR REPLACE FUNCTION AURORA_VERSION() RETURNS TEXT
    LANGUAGE plpgsql
    AS $$
    BEGIN
     RETURN '1.2.3';
    END;
    $$;
    This will result in
    > {:adapter=>"postgresql", :version=>"12.9", :pg_system_id=>6976470454675971923, :flavor=>"Amazon Aurora PostgreSQL"}
  4. To simulate Azure Database for PostgreSQL - Single Server create the following database
    > CREATE DATABASE azure_maintenance;
    This will result in
    > {:adapter=>"postgresql", :version=>"12.9", :pg_system_id=>6976470454675971923, :flavor=>"Azure Database for PostgreSQL - Single Server"}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Krasimir Angelov

Merge request reports