Skip to content
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

Support mysql prepare statement command #8084

Merged
merged 29 commits into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
df09c0d
support prepare statement
Nov 17, 2017
eb0b020
fix 8 bit too small to shift of 16
Nov 20, 2017
1862834
fix violations
Nov 20, 2017
aac8269
fix Code differs from goimports' style
Nov 20, 2017
6d8b697
support prepare statement
Nov 21, 2017
bdbbe2e
add prepare_statement pcap file
Nov 21, 2017
b2aa0e5
add a system test for mysql prepare statement
Nov 21, 2017
0ebb082
add data length check
Nov 22, 2017
223b031
execute make fmt
Nov 22, 2017
e7a052e
to use binary package
Nov 24, 2017
c707ceb
publish prepare/close statement request
Apr 11, 2018
b880476
include helper function
Apr 11, 2018
26a8ddc
Fix
adriansr Aug 24, 2018
7861240
add mysql default port
Aug 24, 2018
5c1a637
Add an entry to CHANGELOG.asciidoc
Aug 24, 2018
c030cea
make update
adriansr Aug 24, 2018
6237773
Fix CHANGELOG
adriansr Aug 24, 2018
089e4d1
Goimports format fix
adriansr Aug 24, 2018
92a6a44
Merge branch 'master' into feature/pb/mysql_prepare
adriansr Oct 29, 2018
cf4ece6
Fix merge
adriansr Oct 29, 2018
19e9b78
Documentation for `statement_timeout`
adriansr Oct 29, 2018
bebbe49
Small fixes from comments
adriansr Oct 31, 2018
b04f95c
Simple unit test to increase coverage
adriansr Oct 31, 2018
3a072f9
Remove manual integer decoding
adriansr Oct 31, 2018
8875fc9
Address review comments
adriansr Dec 12, 2018
f34684d
Merge branch 'master' into feature/pb/mysql_prepare
adriansr Dec 12, 2018
98f65f0
Fix CHANGELOG
adriansr Dec 12, 2018
a627dde
Merge branch 'master' into feature/pb/mysql_prepare
adriansr Jan 8, 2019
8b32c96
Adapt system-test to new ECS field name
adriansr Jan 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d

*Packetbeat*

- Add support to decode mysql prepare statement command. {pull}8084[8084]

*Functionbeat*

==== Deprecated
Expand Down
2 changes: 1 addition & 1 deletion packetbeat/_meta/beat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ packetbeat.protocols:

# Configure the ports where to listen for MySQL traffic. You can disable
# the MySQL protocol by commenting out the list of ports.
ports: [3306]
ports: [3306,3307]

# If this option is enabled, the raw message of the request (`request` field)
# is sent to Elasticsearch. The default is false.
Expand Down
2 changes: 1 addition & 1 deletion packetbeat/_meta/beat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ packetbeat.protocols:
- type: mysql
# Configure the ports where to listen for MySQL traffic. You can disable
# the MySQL protocol by commenting out the list of ports.
ports: [3306]
ports: [3306,3307]

- type: pgsql
# Configure the ports where to listen for Pgsql traffic. You can disable
Expand Down
2 changes: 1 addition & 1 deletion packetbeat/docs/gettingstarted.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ packetbeat.protocols:
ports: [11211]

- type: mysql
ports: [3306]
ports: [3306,3307]

- type: pgsql
ports: [5432]
Expand Down
50 changes: 43 additions & 7 deletions packetbeat/docs/packetbeat-options.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ packetbeat.protocols:
ports: [11211]

- type: mysql
ports: [3306]
ports: [3306,3307]

- type: redis
ports: [6379]
Expand Down Expand Up @@ -899,22 +899,58 @@ The memcache protocol analyzer will wait for the number of milliseconds specifie
`udptransactiontimeout` before publishing quiet messages. Non-quiet messages or
quiet requests with an error response are published immediately.

[[packetbeat-mysql-pgsql-options]]
=== Capture MySQL and PgSQL traffic
[[packetbeat-mysql-options]]
=== Capture MySQL traffic

++++
<titleabbrev>MySQL and PgSQL</titleabbrev>
<titleabbrev>MySQL</titleabbrev>
++++

The `mysql` and `pgsql` sections of the +{beatname_lc}.yml+ config file specify configuration options for the MySQL
and PgSQL protocols.
The `mysql` section of the +{beatname_lc}.yml+ config file specifies configuration
options for the MySQL protocols.

[source,yaml]
------------------------------------------------------------------------------
packetbeat.protocols:

- type: mysql
ports: [3306]
ports: [3306,3307]
------------------------------------------------------------------------------

==== Configuration options

Also see <<common-protocol-options>>.

===== `max_rows`

The maximum number of rows from the SQL message to publish to Elasticsearch. The
default is 10 rows.


===== `max_row_length`

The maximum length in bytes of a row from the SQL message to publish to
Elasticsearch. The default is 1024 bytes.

==== `statement_timeout`

The duration for which prepared statements are cached after their last use.
Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
The default is `1h`.

[[packetbeat-pgsql-options]]
=== Capture PgSQL traffic

++++
<titleabbrev>PgSQL</titleabbrev>
++++

The `pgsql` sections of the +{beatname_lc}.yml+ config file specifies configuration
options for the PgSQL protocols.

[source,yaml]
------------------------------------------------------------------------------
packetbeat.protocols:

- type: pgsql
ports: [5432]
Expand Down
2 changes: 1 addition & 1 deletion packetbeat/packetbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ packetbeat.protocols:

# Configure the ports where to listen for MySQL traffic. You can disable
# the MySQL protocol by commenting out the list of ports.
ports: [3306]
ports: [3306,3307]

# If this option is enabled, the raw message of the request (`request` field)
# is sent to Elasticsearch. The default is false.
Expand Down
2 changes: 1 addition & 1 deletion packetbeat/packetbeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ packetbeat.protocols:
- type: mysql
# Configure the ports where to listen for MySQL traffic. You can disable
# the MySQL protocol by commenting out the list of ports.
ports: [3306]
ports: [3306,3307]

- type: pgsql
# Configure the ports where to listen for Pgsql traffic. You can disable
Expand Down
12 changes: 8 additions & 4 deletions packetbeat/protos/mysql/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,26 @@
package mysql

import (
"time"

"github.com/elastic/beats/packetbeat/config"
"github.com/elastic/beats/packetbeat/protos"
)

type mysqlConfig struct {
config.ProtocolCommon `config:",inline"`
MaxRowLength int `config:"max_row_length"`
MaxRows int `config:"max_rows"`
MaxRowLength int `config:"max_row_length"`
MaxRows int `config:"max_rows"`
StatementTimeout time.Duration `config:"statement_timeout"`
adriansr marked this conversation as resolved.
Show resolved Hide resolved
}

var (
defaultConfig = mysqlConfig{
ProtocolCommon: config.ProtocolCommon{
TransactionTimeout: protos.DefaultTransactionExpiration,
},
MaxRowLength: 1024,
MaxRows: 10,
MaxRowLength: 1024,
MaxRows: 10,
StatementTimeout: 3600 * time.Second,
}
)
Loading