autoinstall - using webhooks for reporting

autoinstall includes the option to report to a webhook:

reporting:
 hook:
  type: webhook
  endpoint: http://example.com/endpoint/path
  consumer_key: "ck_foo"
  consumer_secret: "cs_foo"
  token_key: "tk_foo"
  token_secret: "tk_secret"
  level: INFO

I tried to configure this, but to no avail. Since I'm not really familiar with webhooks, I first tried to get any info at all and set up this config:

reporting:
 hook:
  type: webhook
  endpoint: localhost:8000

I then set up netcat on my local server like this:

nc -l localhost 8000

But on this socket I get nothing at all. I'm not very sure how to consume this service, but I'd expect to see any data at least.


Solution 1:

I setup an http-echo-server and added the reporting section to a config. When the webhook reporting works, it appears to send one HTTP request for each log message generated.

For example, this line in the file /var/log/installer/subiquity-server-debug.log

2021-05-05 00:06:50,666 DEBUG root:39 finish: subiquity/Network/_send_update: SUCCESS: CHANGE ens192

corresponds with this HTTP request

--> POST / HTTP/1.1
--> Accept-Encoding: identity
--> Content-Length: 190
--> Host: REDACTED:8080
--> User-Agent: Curtin/21.2-7-gd49d35bc6
--> Content-Type: application/json
--> Authorization: OAuth oauth_nonce="24545438356422201711620173210", oauth_timestamp="1620173210", oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="ck_foo", oauth_token="tk_foo", oauth_signature="cs_foo%26tk_secret"
--> Connection: close
-->
--> {"name": "subiquity/Network/_send_update", "description": "CHANGE ens192", "event_type": "finish", "origin": "curtin", "timestamp": 1620173210.6665578, "level": "DEBUG", "result": "SUCCESS"}

I tested originally with subiquity 20.04.3 and the HTTP server received no data, just like you observed.

I added the configuration to have subiquity update itself. This resulted in using subiquity 21.04.2 and the HTTP server did receive messages.

Here is a partial config of what was tested

#cloud-config
autoinstall:
  refresh-installer:
    update: yes
  reporting:
    mylistener:
      type: webhook
      endpoint: http://REDACTED:8080/
      consumer_key: "ck_foo"
      consumer_secret: "cs_foo"
      token_key: "tk_foo"
      token_secret: "tk_secret"
      level: INFO

Other Notes

  • I do not see any commits or bug fixes related to reporting or webhook, so I'm not certain what fixes it or how reliable it should be considered.
  • Even though the level is set to INFO, the webhook is still sent messages for DEBUG.