Skip to content

Best way to parse mysql slow query log #18806

Answered by milkrage
hungpr0 asked this question in Q&A
Discussion options

You must be logged in to vote

The slow query log file can contain not only information about slow queries, but also other service information. Entries that are not related to slow queries will cause parsing errors. As a solution, you can use drop_on_error and if with abort.

In the example I use the continue_through mode

Example:

sources:
  slow_log_source:
    type: "file"
    data_dir: .
    include:
      - slow.log
    read_from: "end"
    multiline:
      condition_pattern: "(^#.*|.*;$)"
      start_pattern: "^# Time.*"
      mode: continue_through
      timeout_ms: 1000

transforms:
    slow_log:
      inputs:
        - slow_log_source
      type: "remap"
      drop_on_error: true
      source: |-
        .conten…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@spihiker
Comment options

@hungpr0
Comment options

@milkrage
Comment options

Answer selected by jszwedko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants