How to Dump and Filter Logs


This page contains commands that can be useful for dumping, filtering, and searching your MariaDB Xpand logs.

Cluster Logs From the Last 24 Hours

To create a tar file of the logs from all cluster nodes from the last 24 hours, use the clx logdump all command with the following options:

$ clx -a -s 24 logdump all

Sort Query Log by Query Time

To compile an index of slow queries, you can sort the query logs from all cluster nodes by query time by combining the clx cmd command and Linux tools like sed, sort, and grep:

$ clx cmd 'grep "Mar 12" /data/clustrix/log/query.log' >> ~/query_sort.log
$ cat query_sort.log \
   | sed 's/^.*time \([0-9]*\).*$/\1 \0/' \
   | sort -rn \
   | less

Measure Log Line Frequency

To measure the frequency of a log line file by hour, use Linux tools like grep, cut, and uniq:

   | cut -b1-13 \
   | uniq -c

For example, to determine the frequency of log lines that mention "Duplicate key in container" and "qpc_current", use a command like the following:

$ grep "Duplicate key in container" /data/clustrix/log/query.log \
   | grep "qpc_current" \
   | cut -b1-13 \
   | uniq -c
11 2021-09-19 22
 1 2021-09-19 23
 4 2021-09-20 00