Sign inSign up

nindate/webhook

By nindate

Updated almost 7 years ago

Webhook

Image
0

108

nindate/webhook repository overview

Original source/work https://github.com/adnanh/webhook https://hub.docker.com/r/prasenforu/kubewebhook

Download container image docker pull nindate/webhook:v0.1

Create container for webhook mapping host port 9000 to container port 9000 docker run -it -d --name my-webhook1 -p 9000:9000 nindate/webhook:v0.1

From your docker host test webhook run

Open 2 login sessions to Docker host

Session 1: docker logs -f my-webhook1

Session 2: data='{"alerts": [{"labels": {"alertname": "CPUHigh","instance": "vm1","severity": "high"},"startsAt": "2019-10-12T08:33:07.641920832Z","status": "firing"}],"status": "firing"}' curl -X POST http://localhost:9000/hooks/generic-hook -d "$data"

Check the docker logs output from session 1 login

Explanation: The webhook configuration file is /etc/webhook/hooks.json

[ { "pass-arguments-to-command": [ { "source": "entire-payload" } ], "id": "generic-hook", "execute-command": "/etc/webhook/print_all.py", "command-working-directory": "/etc/webhook" } ]

Above only one hook id is defined - generic-hook. The script /etc/webhook/print_all.py will get executed [It should have the execute permission set] when the webhook is called Please refer to the documentation for more understanding https://github.com/adnanh/webhook https://github.com/adnanh/webhook/blob/master/docs/Referencing-Request-Values.md https://github.com/adnanh/webhook/blob/master/docs/Hook-Examples.md https://github.com/adnanh/webhook/wiki/Hook-Examples

You can add more hooks like below example

[ { "pass-arguments-to-command": [ { "source": "entire-payload" } ], "id": "generic-hook", "execute-command": "/etc/webhook/print_all.py", "command-working-directory": "/etc/webhook" }, { "pass-arguments-to-command": [ { "source": "entire-payload" } ], "id": "my-hook-1", "execute-command": "/etc/webhook/my-hook-1.py", "command-working-directory": "/etc/webhook" } ]

The container image is from Alpine, hence if you want to say install something use apk e.g. apk update apk add python3

Tag summary

Content type

Image

Digest

Size

-

Last updated

almost 7 years ago

docker pull nindate/webhook:v0.1