Skip to content

Latest commit

 

History

History
75 lines (58 loc) · 2.12 KB

0003_github.md

File metadata and controls

75 lines (58 loc) · 2.12 KB

Ingress Webhooks

klev has support for ingesting messages via webhooks, also called ingress-webhooks. We support Slack, Stripe, and since recently GitHub.

You configure an ingress webhook with a provider, secret and target log. Once klev receives the https call, it will validate it, and then push a new message on the target log with the webhook payload as a value.

GitHub Webhooks

Let's try to add a GitHub ingress webhook. We'll need to first configure klev, then add a webhook to GitHub, and finally see the payloads in klev.

klev configuration

Start by adding a log, that will contain the payloads:

$ klev-cli logs create --metadata "github webhooks"
{
  "log_id": "log_2NcGE3LLPDhHS2pPwUh946EibAK",
  "metadata": "github webhook",
  "compacting": false
}

Then add the ingress webhook itself, like:

$ klev-cli ingress-webhooks create --log-id log_2NcGE3LLPDhHS2pPwUh946EibAK --metadata "github webhook" --type "github" --secret REDACTED
{
  "webhook_id": "wh_2NcGTsqkKANRT9mxieRbSpKIlaB",
  "log_id": "log_2NcGE3LLPDhHS2pPwUh946EibAK",
  "metadata": "github webhook",
  "type": "github"
}

GitHub configuration

Now create a new webhook in GitHub with the following parameters:

Now watch the status of the webhook in GitHub, and when it turns green go to the next step.

klev consume

Now lets check what this webhook delivered us:

$ klev-cli consume log_2NcGE3LLPDhHS2pPwUh946EibAK
{
  "next_offset": 1,
  "encoding": "string",
  "messages": [
    {
      "offset": 0,
      "time": 1679956862967113,
      "value": "{\"zen\":\"Anything added dilutes everything else.\"...",
    }
  ]
}

Conclusion

By using the power of klev, we ingested webhooks directly into klev, which we can then further process on as needed basis.

👋 Enjoy hacking!