lib/cfe_internal_hub.cf

Table of Contents

cfe_internal_database_cleanup_diagnostics

Prototype: cfe_internal_database_cleanup_diagnostics(settings)

Arguments:

  • settings of vars promiser index of vars promiser remove_query_$(settings[$(index)][report]) of commands promiser $(sys.bindir)/psql cfdb -c "$(remove_query_$(settings[$(index)][report]))"

Implementation:

bundle agent cfe_internal_database_cleanup_diagnostics (settings)
{
  vars:
      "index" slist => getindices("settings");

      "remove_query_$(settings[$(index)][report])"
      string => "DELETE FROM $(settings[$(index)][table]) WHERE $(settings[$(index)][time_key]) < (CURRENT_TIMESTAMP - INTERVAL '$(settings[$(index)][history_length_days]) day');";

  commands:
      "$(sys.bindir)/psql cfdb -c \"$(remove_query_$(settings[$(index)][report]))\""
      handle => "cf_database_maintain_diagnostics_$(settings[$(index)][report])";
}

monitor bundles

measure_psql

Prototype: measure_psql

Implementation:

bundle monitor measure_psql
{
  measurements:
    policy_server|am_policy_hub::
      "/var/log/postgresql.log"
        if => fileexists( "/var/log/postgresql.log"),
        handle => "psql_lock_wait_before_acquisition",
        stream_type => "file",
        data_type => "real",
        history_type => "weekly",
        units => "ms",
        match_value => acquired_lock;
}

match_value bodies

acquired_lock

Prototype: acquired_lock

Implementation:

body match_value acquired_lock
{
  select_line_matching => ".*acquired.*Lock.*";
  extraction_regex => ".*after (\d+)";
  track_growing_file => "true";
  select_multiline_policy => "average"; # average, sum, first, last
}