feat(check): MQTT, Kafka and RabbitMQ checks
MQTT signs in and, with a topic, waits for a message (retained ones count) that may have to contain a text. Kafka fetches cluster metadata from one or more brokers, checks that a topic exists with a leader for every partition and can produce a message, with SASL PLAIN or SCRAM. RabbitMQ signs in over AMQP, opens a channel and checks that a queue exists. All connect through the network guard with optional TLS, and the TLS modes and error redaction are now shared with the database checks. Tested against an in-process MQTT broker and real Kafka and RabbitMQ. Refs #94 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
fb03b28df7
commit
8ca56635cd
8 files changed
+545
-20
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package check
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"net"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// TLS modes of services with optional encryption: "require" encrypts
|
||||
// without verifying the certificate, "verify" also verifies it.
|
||||
func validTLSMode(m string) bool { return m == "disable" || m == "require" || m == "verify" }
|
||||
|
||||
// tlsFor returns the client TLS settings for mode, or nil for "disable".
|
||||
func tlsFor(mode, target string) *tls.Config {
|
||||
if mode == "disable" {
|
||||
return nil
|
||||
}
|
||||
host, _, _ := net.SplitHostPort(target)
|
||||
return &tls.Config{ServerName: host, InsecureSkipVerify: mode == "require"} //nolint:gosec // "require" encrypts without verifying, as chosen per monitor
|
||||
}
|
||||
|
||||
// redact shortens err for customers and removes secrets some clients
|
||||
// repeat in their errors.
|
||||
func redact(err error, secrets ...string) string {
|
||||
msg := err.Error()
|
||||
for _, s := range secrets {
|
||||
if s != "" {
|
||||
msg = strings.ReplaceAll(msg, s, "***")
|
||||
}
|
||||
}
|
||||
return truncate(msg, 300)
|
||||
}
|
||||
Reference in new issue
Block a user