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

filter: postgres statistics network filter #10642

Merged
merged 58 commits into from
Apr 21, 2020

Conversation

cpakulski
Copy link
Contributor

@cpakulski cpakulski commented Apr 3, 2020

Description:
The filter implements decoding postgres wire protocol and parses messages exchanged between postgres server and client. Based on the decoded messages the filter generates statistics (counters) indicating how many messages of a specific type were exchanged.

Risk Level:
Low: The filter is implemented as extension and the code is not executed unless inserted into filter chain.

Testing:
Added unit and integration tests.

Docs Changes:
Yes - added architecture overview chapter and configuration specific sections

Release Notes:
Yes

Partially fixes: #9107

@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #10642 was opened by cpakulski.

see: more, trace.

@lizan
Copy link
Member

lizan commented Apr 3, 2020

@cpakulski can you merge master to resolve conflicts?

dio and others added 27 commits April 3, 2020 17:27
Signed-off-by: Dhi Aurrahman <dio@tetrate.io>
…ce code.

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
… messages spread over

more than one buffer.
Added unit tests for parsing single, multiple and large messages.

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Added hash map to find the message type and related actions
based on the first byte of the message.

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: Fabrízio de Royes Mello <fabrizio@ongres.com>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
successful authentication. Other R messages are ignored.

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Formatted code with format and spell checkers.

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
configuration.

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
INFO: From ProtoGenValidateCcGenerate external/envoy_api/envoy/config/filter/network/postgresql_proxy/v2alpha/postgresql_proxy.pb.h:
envoy/config/filter/network/postgresql_proxy/v2alpha/postgresql_proxy.proto: warning: Import udpa/annotations/migrate.proto but not used.
envoy/config/filter/network/postgresql_proxy/v2alpha/postgresql_proxy.proto: warning: Import validate/validate.proto but not used.
envoy/config/filter/network/postgresql_proxy/v2alpha/postgresql_proxy.proto: warning: Import udpa/annotations/status.proto but not used.

INFO: From ProtoGenValidateCcGenerate external/envoy_api/envoy/extensions/filters/network/postgresql_proxy/v3alpha/postgresql_proxy.pb.h:
envoy/extensions/filters/network/postgresql_proxy/v3alpha/postgresql_proxy.proto: warning: Import udpa/annotations/versioning.proto but not used.
envoy/extensions/filters/network/postgresql_proxy/v3alpha/postgresql_proxy.proto: warning: Import validate/validate.proto but not used.
envoy/extensions/filters/network/postgresql_proxy/v3alpha/postgresql_proxy.proto: warning: Import udpa/annotations/status.proto but not used.

Signed-off-by: Fabrízio de Royes Mello <fabrizio@ongres.com>
This reverts commit 83bb9b4.

Signed-off-by: Fabrízio de Royes Mello <fabrizio@ongres.com>
Signed-off-by: Fabrízio de Royes Mello <fabrizio@ongres.com>
…d messages.

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Moved logic from multi-level if..else to hash map.
Updated documention.

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
- sessions:  Number of successful logins
- sessions_encrypted: Number of times the proxy detected encrypted sessions
- sessions_unencrypted: Number of messages indicating unencrypted successful login

Signed-off-by: Fabrízio de Royes Mello <fabrizio@ongres.com>
- errors: Total number of backend decoded errors (ErrorResponse)
- errors_error: Number of ERROR severity errors detected by the filter
- errors_fatal: Number of FATAL severity errors detected by the filter
- errors_panic: Number of PANIC severity errors detected by the filter
- errors_unknown: Number of severity errors that filter can't detected

Signed-off-by: Fabrízio de Royes Mello <fabrizio@ongres.com>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
to use enums, not separate methods.

Error and Notice parser searches for S and V prefixes.

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
for keywords with S and V prefixes.

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
- file names
- directory names
- variables and class names
- config items
- documentation

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
cpakulski and others added 4 commits April 10, 2020 23:36
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Copy link
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, structurally looks good. Mostly C++ style/readability nits.

fabriziomello and others added 3 commits April 16, 2020 20:44
Signed-off-by: Fabrízio de Royes Mello <fabrizio@ongres.com>
Use writeBEInt templates to write integers in network format to buffer.

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
… into postgresql-cp

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
@htuch
Copy link
Member

htuch commented Apr 19, 2020

/lgtm api

lizan
lizan previously approved these changes Apr 20, 2020
Copy link
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, can you merge master to resolve conflict and fix CI?

@fabriziomello
Copy link
Contributor

@lizan now all CI tests are ok.

@lizan lizan dismissed htuch’s stale review April 21, 2020 01:22

API review addressed

@lizan lizan merged commit f599ad7 into envoyproxy:master Apr 21, 2020
penguingao pushed a commit to penguingao/envoy that referenced this pull request Apr 22, 2020
Description:
The filter implements decoding postgres wire protocol and parses messages exchanged between postgres server and client. Based on the decoded messages the filter generates statistics (counters) indicating how many messages of a specific type were exchanged. envoyproxy#9107

Risk Level: Low: The filter is implemented as extension and the code is not executed unless inserted into filter chain.
Testing: Added unit and integration tests.
Docs Changes: Yes - added architecture overview chapter and configuration specific sections
Release Notes: Yes

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Co-authored-by: Dhi Aurrahman <dio@tetrate.io>
Co-authored-by: Fabrízio de Royes Mello <fabrizio@ongres.com>
Signed-off-by: pengg <pengg@google.com>
@tmc
Copy link

tmc commented Apr 22, 2020

Typo: sesions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Postgres Statistics Envoy Network Filter
7 participants