项目作者: AtlasOfLivingAustralia

项目描述 :
Atlas event logging
高级语言: Groovy
项目地址: git://github.com/AtlasOfLivingAustralia/logger-service.git
创建时间: 2014-07-09T08:42:44Z
项目社区:https://github.com/AtlasOfLivingAustralia/logger-service

开源协议:

下载


logger-service Build Status

Installation

The logger service is deployed using Ansible. Scripts reside in the ala-install repository: ansible/logger-standalone.yml and ansible/roles/logger-service. For testing, there is a vagrant inventory in ansible/inventories/vagrant/logger-service-vagrant

Database setup

SQL scripts to create the database schema, stored procedures and initial reference are in stored with the ansible build script in the ala-install repository under ansible/logger-service/files/db.

Archiving log_event and log_detail tables.

The two tables log_event and log_detail will grow large over time. The content of these tables is summarised in the event_summary_* tables.

These summary tables are incremented by inserts using the stored procedure defined in update_breakdown_summary_information.sql which is triggered on inserts to log_detail.

Steps to archive

1. Rename log_event and log_detail and re-create new blank log_event and log_detail.

  1. RENAME TABLE log_detail to archive_20190204_log_detail;
  2. RENAME TABLE log_event to archive_20190204_log_event;
  3. CREATE TABLE log_detail like archive_20190204_log_detail;
  4. CREATE TABLE log_event like archive_20190204_log_event;

2. Backup existing summaries

  1. CREATE TABLE archive_20190204_event_summary_breakdown_email LIKE event_summary_breakdown_email;
  2. CREATE TABLE archive_20190204_event_summary_breakdown_email_entity LIKE event_summary_breakdown_email_entity;
  3. CREATE TABLE archive_20190204_event_summary_breakdown_reason LIKE event_summary_breakdown_reason;
  4. CREATE TABLE archive_20190204_event_summary_breakdown_reason_entity LIKE event_summary_breakdown_reason_entity;
  5. CREATE TABLE archive_20190204_event_summary_breakdown_reason_entity_source LIKE event_summary_breakdown_reason_entity_source;
  6. CREATE TABLE archive_20190204_event_summary_totals LIKE event_summary_totals;
  1. INSERT archive_20190204_event_summary_breakdown_email
  2. SELECT * FROM event_summary_breakdown_email;
  3. INSERT archive_20190204_event_summary_breakdown_email_entity
  4. SELECT * FROM event_summary_breakdown_email_entity;
  5. INSERT archive_20190204_event_summary_breakdown_reason
  6. SELECT * FROM event_summary_breakdown_reason;
  7. INSERT archive_20190204_event_summary_breakdown_reason_entity
  8. SELECT * FROM event_summary_breakdown_reason_entity;
  9. INSERT archive_20190204_event_summary_breakdown_reason_entity_source
  10. SELECT * FROM event_summary_breakdown_reason_entity_source;
  11. INSERT archive_20190204_event_summary_totals
  12. SELECT * FROM event_summary_totals;

3. Reinitialise the TRIGGER

Reinitialise the TRIGGER by re-running update_breakdown_summary_information.sql

Recreating summary tables with archived summaries

If the eventsummary* tables need to be recreated (this isnt usually required, only ina disaster recovery situation) with the inclusion of archived summaries, the counts can be aggregated from archived summaries and current summaries like so:

  1. create table tmp_event_summary_breakdown_email AS
  2. select month, log_event_type_id, user_email_category, sum(number_of_events), sum(record_count) from (
  3. select month, log_event_type_id, user_email_category, number_of_events, record_count from event_summary_breakdown_email union all
  4. select month, log_event_type_id, user_email_category, number_of_events, record_count from archive_20190204_event_summary_breakdown_email
  5. ) x group by month, log_event_type_id, user_email_category;

Once these temporary tables are created the eventsummary* (in this case event_summary_breakdown_email) can be dropped, and the tmp_event_summary_breakdown_email renamed.

  1. RENAME TABLE tmp_event_summary_breakdown_email to event_summary_breakdown_email;