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

feat: Implement byte matching in TCP query responses #1112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tacho
Copy link

@tacho tacho commented Aug 18, 2023

Currently the exporter only supports lines, which breaks byte-oriented protocols such as the PostgreSQL StartTLS handshake.

We also give a working example for Postgres in the sample configuration.

Fixes: #801

@Raymondmax
Copy link

Is there any ETA for this PR merge?

@tacho
Copy link
Author

tacho commented Oct 27, 2023

I was wondering the same - it's been two months without any reaction. Is this project dead, or abandoned?

@rj-home
Copy link

rj-home commented Dec 5, 2023

+1 on this PR, we have the same issue which will be fixed after the merge

@freeyoung
Copy link

+1 on this PR too, would be nice to have this builtin

@sonman
Copy link

sonman commented May 27, 2024

+1 if we can use blackbox exporter also for postgres

@SuperQ SuperQ requested review from mem and electron0zero May 27, 2024 09:48
@Raymondmax
Copy link

FYI, here's a demo code to get Postgres cert info via TrustManager when connecting to the server

https://github.com/Raymondmax/PostgresCert/blob/main/main.java

prober/tcp_test.go Outdated Show resolved Hide resolved
Currently the exporter only supports lines, which breaks byte-oriented
protocols such as the PostgreSQL StartTLS handshake.

We also give a working example for Postgres in the sample configuration.

Signed-off-by: Stanislav Grozev <[email protected]>
@@ -159,6 +160,31 @@ func ProbeTCP(ctx context.Context, target string, module config.Module, registry
probeFailedDueToRegex.Set(0)
send = string(qr.Expect.Regexp.Expand(nil, []byte(send), scanner.Bytes(), match))
}
if qr.ExpectBytes != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks OK to me.

I would prefer to have stronger validation in the configuration, because as this section of the code shows, it's possible to specify both a regular expression and the sequence of bytes to be read, and I'm not sure how that's going to play together. If you think specifying both at the same time makes sense, I would like to see an example (and also a test).

My hunch is that it has to be either the regular expression or the specific sequence of bytes, but not both at the same time.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, makes sense it would be one or the other - protocols are either line oriented or not. I'll adjust the patch soon.

Choose a reason for hiding this comment

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

It would be awesome if we get this MR merged and release :)

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.

Unable to scrape Postgres cert metrics
8 participants