prometheus / blackbox_exporter

Blackbox prober exporter
https://prometheus.io
Apache License 2.0
4.71k stars 1.06k forks source link

Add rabbitMQ config example to the Blackbox Exporter configuration examples file. #1074

Open victorpablosceruelo opened 1 year ago

victorpablosceruelo commented 1 year ago

Please add the config examples we wrote below to the Blackbox Exporter configuration examples file you have. It took us some time to do it and it might help others to develop new probes (it is not an easy one). Thanks!!

Host operating system: output of uname -a

Linux blackbox-exporter-service-86c966c8c-kv9d9 4.18.0-305.76.1.el8_4.x86_64 #1 SMP Thu Jan 12 10:05:36 EST 2023 x86_64 x86_64 x86_64 GNU/Linux

blackbox_exporter version: output of blackbox_exporter --version

blackbox_exporter --version blackbox_exporter, version (branch: , revision: ) build user:
build date:
go version: go1.20.3 platform: linux/amd64

What is the blackbox.yml module config.

  rabbitmq:
    prober: tcp
    timeout: 30s
    tcp:
      query_response:
        - send: "HELO\r"
        - send: "\r"
        - send: "\r"
        - send: "\r"
        - expect: "AMQP"
      tls: true
      tls_config:
        insecure_skip_verify: false
        ca_file: "/etc/blackbox_exporter/CA_cert.crt"
  rabbitmq_insecure:
    prober: tcp
    timeout: 30s
    tcp:
      query_response:
        - send: "HELO\r"
        - send: "\r"
        - send: "\r"
        - send: "\r"
        - expect: "AMQP"
      tls: true
      tls_config:
        insecure_skip_verify: true
        ca_file: "/etc/blackbox_exporter/CA_cert.crt"

What is the prometheus.yml scrape config.

Not applicable.

What logging output did you get from adding &debug=true to the probe URL?

sh-4.4$ curl -vvv -i 'http://localhost:9115/probe?module=rabbitmq_insecure&target=dcr.tst-esrabbitmq-vip.domain:5671&debug=true'
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 9115 (#0)
> GET /probe?module=rabbitmq_insecure&target=dcr.tst-esrabbitmq-vip.domain:5671&debug=true HTTP/1.1
> Host: localhost:9115
> User-Agent: curl/7.61.1
> Accept: */*
> 
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Content-Type: text/plain
Content-Type: text/plain
< Date: Fri, 26 May 2023 06:22:35 GMT
Date: Fri, 26 May 2023 06:22:35 GMT
< Transfer-Encoding: chunked
Transfer-Encoding: chunked

< 
Logs for the probe:
ts=2023-05-26T06:22:35.687062856Z caller=main.go:181 module=rabbitmq_insecure target=dcr.tst-esrabbitmq-vip.domain:5671 level=info msg="Beginning probe" probe=tcp timeout_seconds=30
ts=2023-05-26T06:22:35.687296626Z caller=tcp.go:40 module=rabbitmq_insecure target=dcr.tst-esrabbitmq-vip.domain:5671 level=info msg="Resolving target address" target=dcr.tst-esrabbitmq-vip.domain ip_protocol=ip6
ts=2023-05-26T06:22:35.703586448Z caller=tcp.go:40 module=rabbitmq_insecure target=dcr.tst-esrabbitmq-vip.domain:5671 level=info msg="Resolved target address" target=dcr.tst-esrabbitmq-vip.domain ip=10.4.232.230
ts=2023-05-26T06:22:35.704109648Z caller=tcp.go:112 module=rabbitmq_insecure target=dcr.tst-esrabbitmq-vip.domain:5671 level=info msg="Dialing TCP with TLS"
ts=2023-05-26T06:22:35.742610261Z caller=handler.go:117 module=rabbitmq_insecure target=dcr.tst-esrabbitmq-vip.domain:5671 level=info msg="Successfully dialed"
ts=2023-05-26T06:22:35.742849062Z caller=handler.go:117 module=rabbitmq_insecure target=dcr.tst-esrabbitmq-vip.domain:5671 level=info msg="Processing query response entry" entry_number=0
ts=2023-05-26T06:22:35.742878453Z caller=handler.go:117 module=rabbitmq_insecure target=dcr.tst-esrabbitmq-vip.domain:5671 level=debug msg="Sending line" line="HELO\r"
ts=2023-05-26T06:22:35.74297462Z caller=handler.go:117 module=rabbitmq_insecure target=dcr.tst-esrabbitmq-vip.domain:5671 level=info msg="Processing query response entry" entry_number=1
ts=2023-05-26T06:22:35.742994914Z caller=handler.go:117 module=rabbitmq_insecure target=dcr.tst-esrabbitmq-vip.domain:5671 level=debug msg="Sending line" line="\r"
ts=2023-05-26T06:22:35.743037196Z caller=handler.go:117 module=rabbitmq_insecure target=dcr.tst-esrabbitmq-vip.domain:5671 level=info msg="Processing query response entry" entry_number=2
ts=2023-05-26T06:22:35.743061274Z caller=handler.go:117 module=rabbitmq_insecure target=dcr.tst-esrabbitmq-vip.domain:5671 level=debug msg="Sending line" line="\r"
ts=2023-05-26T06:22:35.743098101Z caller=handler.go:117 module=rabbitmq_insecure target=dcr.tst-esrabbitmq-vip.domain:5671 level=info msg="Processing query response entry" entry_number=3
ts=2023-05-26T06:22:35.743116521Z caller=handler.go:117 module=rabbitmq_insecure target=dcr.tst-esrabbitmq-vip.domain:5671 level=debug msg="Sending line" line="\r"
ts=2023-05-26T06:22:35.743152613Z caller=handler.go:117 module=rabbitmq_insecure target=dcr.tst-esrabbitmq-vip.domain:5671 level=info msg="Processing query response entry" entry_number=4
ts=2023-05-26T06:22:35.746678637Z caller=handler.go:117 module=rabbitmq_insecure target=dcr.tst-esrabbitmq-vip.domain:5671 level=debug msg="Read line" line="AMQP\u0000\u0000\t\u0001"
ts=2023-05-26T06:22:35.746843691Z caller=handler.go:117 module=rabbitmq_insecure target=dcr.tst-esrabbitmq-vip.domain:5671 level=info msg="Regexp matched" regexp=AMQP line="AMQP\u0000\u0000\t\u0001"
ts=2023-05-26T06:22:35.747079994Z caller=main.go:181 module=rabbitmq_insecure target=dcr.tst-esrabbitmq-vip.domain:5671 level=info msg="Probe succeeded" duration_seconds=0.059908748

Metrics that would have been returned:
# HELP probe_dns_lookup_time_seconds Returns the time taken for probe dns lookup in seconds
# TYPE probe_dns_lookup_time_seconds gauge
probe_dns_lookup_time_seconds 0.016363863
# HELP probe_duration_seconds Returns how long the probe took to complete in seconds
# TYPE probe_duration_seconds gauge
probe_duration_seconds 0.059908748
# HELP probe_failed_due_to_regex Indicates if probe failed due to regex
# TYPE probe_failed_due_to_regex gauge
probe_failed_due_to_regex 0
# HELP probe_ip_addr_hash Specifies the hash of IP address. It's useful to detect if the IP address changes.
# TYPE probe_ip_addr_hash gauge
probe_ip_addr_hash 1.733552189e+09
# HELP probe_ip_protocol Specifies whether probe ip protocol is IP4 or IP6
# TYPE probe_ip_protocol gauge
probe_ip_protocol 4
# HELP probe_ssl_earliest_cert_expiry Returns last SSL chain expiry in unixtime
# TYPE probe_ssl_earliest_cert_expiry gauge
probe_ssl_earliest_cert_expiry 1.717428017e+09
# HELP probe_ssl_last_chain_expiry_timestamp_seconds Returns last SSL chain expiry in timestamp
# TYPE probe_ssl_last_chain_expiry_timestamp_seconds gauge
probe_ssl_last_chain_expiry_timestamp_seconds -6.21355968e+10
# HELP probe_ssl_last_chain_info Contains SSL leaf certificate information
# TYPE probe_ssl_last_chain_info gauge
probe_ssl_last_chain_info{info removed on purpose} 1
# HELP probe_success Displays whether or not the probe was a success
# TYPE probe_success gauge
probe_success 1
# HELP probe_tls_version_info Returns the TLS version used or NaN when unknown
# TYPE probe_tls_version_info gauge
probe_tls_version_info{version="TLS 1.2"} 1

Module configuration:
prober: tcp
timeout: 30s
http:
  ip_protocol_fallback: true
  follow_redirects: true
  enable_http2: true
tcp:
  ip_protocol_fallback: true
  query_response:
  - send: "HELO\r"
  - send: "\r"
  - send: "\r"
  - send: "\r"
  - expect: AMQP
  tls: true
  tls_config:
    ca_file: /etc/blackbox_exporter/CA_cert.crt
    insecure_skip_verify: true
icmp:
  ip_protocol_fallback: true
  ttl: 64
dns:
  ip_protocol_fallback: true
  recursion_desired: true
* Connection #0 to host localhost left intact
sh-4.4$ 

What did you do that produced an error?

No error.

What did you expect to see?

What I saw. I'm requesting you add this example to the configuration example file.

What did you see instead?

Not applicable.

robenn11 commented 1 year ago

+1

just tested the configuration mentioned above and can confirm that it's working for me.

Thank you @victorpablosceruelo