Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to isolate pt-query-digest per host

I'm having some difficulty coming up with correct syntax to pull in specific host information for my slow query log file:

I'm using the following:

sudo pt-query-digest mysql-slow.log --since "2017-05-07 22:00:00" --until "2017-05-08 22:00:00" --filter ‘$event->{host} !~ m/^ip-1-1-1-1/’ > slow.log

In this scenario I'm trying to exclude all IPs that are 1.1.1.1. I can't figure out what's wrong.

like image 402
JimRomeFan Avatar asked May 08 '17 23:05

JimRomeFan


People also ask

How do I use PT query digest?

To use this feature, you run pt-query-digest with the --review option. It will store the fingerprints and other information into the table you specify. Next time you run it with the same option, it will do the following: It won't show you queries you've already reviewed.

How do I disable slow query log in mysql?

To disable or enable the slow query log or change the log file name at runtime, use the global slow_query_log and slow_query_log_file system variables. Set slow_query_log to 0 to disable the log or to 1 to enable it.

What is Long_query_time in mysql?

The minimum and default values of long_query_time are 0 and 10, respectively. The value can be specified to a resolution of microseconds. For logging to a file, times are written including the microseconds part.


1 Answers

Use ascii quote ('), not this non-ascii quote (‘);

Assuming that m/^ip-1-1-1-1/ works, it will catch both ip-1-1-1-1 and ip-1-1-1-123. So you may need something to terminate the ip. Perhaps m/^ip-1-1-1-1$/

Without hiding the arg in single-quotes, the shell is interpreting (at least) $event as a shell variable, {...} as something, and !~ as something.

like image 53
Rick James Avatar answered Oct 22 '22 23:10

Rick James