OneAgent PostgreSQL plugin

Gathers PostgreSQL stats. The full description of stats is described at https://www.postgresql.org/docs/current/static/monitoring-stats.html

Plugin collects subset of:

  • database level metrics available at pg_stat_database view. Only non-template databases are taken into account (those that have datistemplate set to false)
  • aggregated table level metrics read from pg_stat_all_tables

This is a singleton type plugin - one instance will be created even if multiple PostgreSQL process groups instances are detected. To enable plugin following configuration options need to be specified:

  • user credentials - role with md5 authentication method should be provided
  • port - access to the PostgreSQL via localhost interface is required
  • database name
class ruxit_postgresql.DatabasePerSecondStats(tup_inserted, tup_updated, tup_deleted, xact_commit, xact_rollback, blks_hit, blks_read)

Bases: tuple

List of metrics that are collected on database level as per second stats:

blks_hit
blks_read
tup_deleted
tup_inserted
tup_updated
xact_commit
xact_rollback
class ruxit_postgresql.TablePerSecondStats(idx_tup_fetch, seq_tup_read, idx_scan)

Bases: tuple

List of metrics that are collected on table level as per second stats:

idx_scan
idx_tup_fetch
seq_tup_read
ruxit_postgresql.handle_ERROR_RESPONSE_patch(self, data, ps)[source]

Patch for handle_ERROR_RESPONSE function from pg8000 package ensuring that plugin will not crash while decoding error response in the situation when proper encoding is not set yet.

class ruxit_postgresql.PostgresqlPlugin(**kwargs)[source]

Bases: ruxit.api.base_plugin.BasePlugin

PostgreSQL plugin class. This plugin is stateful - initialize method is defined in order to maintain one connection to database engine for the lifetime of the plugin.

__init__ should not be overridden without a call to super.

Parameters:
  • config (Dict[str, str]) -- plugin configuration
  • results_builder (ResultsBuilder) -- instance for this plugin,
  • json_config -- parsed plugin.json contents,
  • plugin_info (PluginInfo) -- json data of the plugin exposed in a more convenient way,
  • associated_entity -- monitored entity associated with the plugin, if any (deprecated).
  • activation_context -- activation context for the plugin,
  • process_snapshot (ProcessSnapshot) -- latest available at method call,
  • entity_resolver (EntityResolver) -- exposes additional methods for querying snapshot
  • logger -- plugin specific logger for plugin development, set to None only in unit tests
postgres_auth_errors = ['28P01']

PostgreSQL authentication error code

postgres_auth_msgs = ['md5 password authentication failed', 'server requesting password authentication, but no password was provided', 'server requesting MD5 password authentication, but no password was provided']

List of messages returned by PostgreSQL that raises authorization exception if encountered while initializing database connection

initialize(**kwargs)[source]

Plugin initialization is limited to parsing configuration.

get_databases(cursor)[source]

Collects and stores list of existing database.

get_database_level_statistics(cursor)[source]

Performs query that selects requested database metrics and sends gathered results.

get_table_level_statistics()[source]

Method that tries connecting to every database and gets its stats.

query(**kwargs)[source]

Main method that connects to PostgreSQL using configuration from global variable.

Raises: