6

我在想出正确的语法来为我的慢速查询日志文件提取特定主机信息时遇到了一些困难:

我正在使用以下内容:

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

在这种情况下,我试图排除所有 1.1.1.1 的 IP。我不知道出了什么问题。

4

1 回答 1

2

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.

于 2017-05-23T21:48:24.393 回答