-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fix mysql slowlog template to support mysql 5.7.22 #9647
Changes from all commits
aed6cc6
07c4fa5
ff52365
5f9f575
09d8b97
141277e
276a1de
19a705a
e54a566
edd4488
b0d2e22
378b4f9
95c43f1
063e3ea
087fa94
0935ce2
e1223ae
1d5f62b
7c836b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Time: 2018-08-07T16:27:47.169604+08:00 | ||
# User@Host: root[root] @ [218.76.8.37] Id: 7234 | ||
# Query_time: 15.000223 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 0 | ||
SET timestamp=1533630467; | ||
select sleep(15); | ||
# Time: 2018-08-07T16:27:47.169604+08:00 | ||
# User@Host: debian-sys-maint[debian-sys-maint] @ localhost [] | ||
# Query_time: 0.000153 Lock_time: 0.000061 Rows_sent: 1 Rows_examined: 5 | ||
SET timestamp=1533630467; | ||
SELECT count(*) FROM mysql.user WHERE user='root' and password=''; | ||
# Time: 2018-08-07T16:27:47.169604+08:00 | ||
# User@Host: apphost[apphost] @ apphost [1.1.1.1] Id: 10997316 | ||
# Query_time: 4.071491 Lock_time: 0.000212 Rows_sent: 1000 Rows_examined: 1489615 | ||
SET timestamp=1533630467; | ||
SELECT mcu.mcu_guid, mcu.cus_guid, mcu.mcu_url, mcu.mcu_crawlelements, mcu.mcu_order, GROUP_CONCAT(mca.mca_guid SEPARATOR ";") as mca_guid | ||
FROM kat_mailcustomerurl mcu, kat_customer cus, kat_mailcampaign mca | ||
WHERE cus.cus_guid = mcu.cus_guid | ||
AND cus.pro_code = 'CYB' | ||
AND cus.cus_offline = 0 | ||
AND mca.cus_guid = cus.cus_guid | ||
AND (mcu.mcu_date IS NULL OR mcu.mcu_date < CURDATE()) | ||
AND mcu.mcu_crawlelements IS NOT NULL | ||
GROUP BY mcu.mcu_guid | ||
ORDER BY mcu.mcu_order ASC | ||
LIMIT 1000; | ||
# Time: 2018-08-07T16:27:47.169604+08:00 | ||
# User@Host: apphost[apphost] @ apphost [1.1.1.1] Id: 10999834 | ||
# Query_time: 10.346539 Lock_time: 0.000036 Rows_sent: 0 Rows_examined: 4751313 | ||
SET timestamp=1533630467; | ||
call load_stats(1, '2017-04-28 00:00:00'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
[ | ||
{ | ||
"@timestamp": "2018-08-07T08:27:47.000Z", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I worried at first that taking the unix timestamp instead of the title one we would loose the timezone diff. But seems like the timestamp is in UTC which is good. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ycombinator I remember you saw something different for ES for example? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ruflin I used to start test environment under beats/testing/environments using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The ES (and LS) logs contain ISO8601 timestamps without the timezone. In MySQL the value of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the details @ycombinator |
||
"ecs.version": "1.0.0-beta2", | ||
"event.dataset": "slowlog", | ||
"event.module": "mysql", | ||
"input.type": "log", | ||
"log.flags": [ | ||
"multiline" | ||
], | ||
"log.offset": 41, | ||
"mysql.slowlog.id": "7234", | ||
"mysql.slowlog.ip": "218.76.8.37", | ||
"mysql.slowlog.lock_time.sec": "0.000000", | ||
"mysql.slowlog.query": "select sleep(15);", | ||
"mysql.slowlog.query_time.sec": "15.000223", | ||
"mysql.slowlog.rows_examined": "0", | ||
"mysql.slowlog.rows_sent": "1", | ||
"mysql.slowlog.timestamp": "1533630467", | ||
"mysql.slowlog.user": "root" | ||
}, | ||
{ | ||
"@timestamp": "2018-08-07T08:27:47.000Z", | ||
"ecs.version": "1.0.0-beta2", | ||
"event.dataset": "slowlog", | ||
"event.module": "mysql", | ||
"input.type": "log", | ||
"log.flags": [ | ||
"multiline" | ||
], | ||
"log.offset": 254, | ||
"mysql.slowlog.host": "localhost", | ||
"mysql.slowlog.lock_time.sec": "0.000061", | ||
"mysql.slowlog.query": "SELECT count(*) FROM mysql.user WHERE user='root' and password='';", | ||
"mysql.slowlog.query_time.sec": "0.000153", | ||
"mysql.slowlog.rows_examined": "5", | ||
"mysql.slowlog.rows_sent": "1", | ||
"mysql.slowlog.timestamp": "1533630467", | ||
"mysql.slowlog.user": "debian-sys-maint" | ||
}, | ||
{ | ||
"@timestamp": "2018-08-07T08:27:47.000Z", | ||
"ecs.version": "1.0.0-beta2", | ||
"event.dataset": "slowlog", | ||
"event.module": "mysql", | ||
"input.type": "log", | ||
"log.flags": [ | ||
"multiline" | ||
], | ||
"log.offset": 526, | ||
"mysql.slowlog.host": "apphost", | ||
"mysql.slowlog.id": "10997316", | ||
"mysql.slowlog.ip": "1.1.1.1", | ||
"mysql.slowlog.lock_time.sec": "0.000212", | ||
"mysql.slowlog.query": "SELECT mcu.mcu_guid, mcu.cus_guid, mcu.mcu_url, mcu.mcu_crawlelements, mcu.mcu_order, GROUP_CONCAT(mca.mca_guid SEPARATOR \";\") as mca_guid\n FROM kat_mailcustomerurl mcu, kat_customer cus, kat_mailcampaign mca\n WHERE cus.cus_guid = mcu.cus_guid\n AND cus.pro_code = 'CYB'\n AND cus.cus_offline = 0\n AND mca.cus_guid = cus.cus_guid\n AND (mcu.mcu_date IS NULL OR mcu.mcu_date < CURDATE())\n AND mcu.mcu_crawlelements IS NOT NULL\n GROUP BY mcu.mcu_guid\n ORDER BY mcu.mcu_order ASC\n LIMIT 1000;", | ||
"mysql.slowlog.query_time.sec": "4.071491", | ||
"mysql.slowlog.rows_examined": "1489615", | ||
"mysql.slowlog.rows_sent": "1000", | ||
"mysql.slowlog.timestamp": "1533630467", | ||
"mysql.slowlog.user": "apphost" | ||
}, | ||
{ | ||
"@timestamp": "2018-08-07T08:27:47.000Z", | ||
"ecs.version": "1.0.0-beta2", | ||
"event.dataset": "slowlog", | ||
"event.module": "mysql", | ||
"input.type": "log", | ||
"log.flags": [ | ||
"multiline" | ||
], | ||
"log.offset": 1438, | ||
"mysql.slowlog.host": "apphost", | ||
"mysql.slowlog.id": "10999834", | ||
"mysql.slowlog.ip": "1.1.1.1", | ||
"mysql.slowlog.lock_time.sec": "0.000036", | ||
"mysql.slowlog.query": "call load_stats(1, '2017-04-28 00:00:00');", | ||
"mysql.slowlog.query_time.sec": "10.346539", | ||
"mysql.slowlog.rows_examined": "4751313", | ||
"mysql.slowlog.rows_sent": "0", | ||
"mysql.slowlog.timestamp": "1533630467", | ||
"mysql.slowlog.user": "apphost" | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm misunderstanding this, but should we be using this new
Time:
header for@timestamp
instead of ignoring it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think there are some magic here that I don't understand. I'm imagining this exclude_lines is only ignoring it when first time parsing
# User@Host
. After that somehow thisTime
still get parsed into@timestamp
since it is captured inmysql/slowlog/test/mysql-5.7.22.log-expected.json
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did not investigate but I'm also a bit confused on why this keeps working. Perhaps the exlcude does not actually work here? Have a look at the pipeline.
Also it would be good to have in the test file below a few more lines to make sure it also works with multiple entries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrewvc @ruflin I looked into this more and found out
@timestamp
field is generated frommysql.slowlog.timestamp
with formatUNIX
. That's why adding# Time
into theexclude_lines
and that didn't change the output.