Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script for fast loading log files #34

Open
matyaskopp opened this issue Nov 9, 2021 · 0 comments
Open

Script for fast loading log files #34

matyaskopp opened this issue Nov 9, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@matyaskopp
Copy link
Member

Loading script is slow when inserting line by line. Old static log files can be loaded faster with COPY command.

Script should settings

  • load (service_id, regex) from database
  • get SELECT max(file_id)+1 FROM log_files;

convert access-file.log to:

access-file.sql

INSERT 
INTO log_files(file_id, file_name, first_line_checksum, last_read_line_checksum, lines_read, lines_valid, tail) 
VALUES(ID,'access-file.log',FIRST_CHECK,LAST_CHECK,LREAD,LVALID,FALSE);

COPY log_file_entries(file_id, service_id, line_number, line_checksum, remote_addr, remote_user, time_local, method, request, protocol, status, body_bytes_sent, http_referer, http_user_agent, unit) 
FROM 'access-file.dump'
WITH 
   DELIMITER AS '\t';

access-file.dump

TAB      SEPARATED      VALUES

to handle

  • be careful about file_id, check if it does not exist during import.
  • aggregations are not done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant