ndelitski / rancher-alarms

Will kick your ass if found unhealthy service in Rancher environment
85 stars 20 forks source link

New actions - webhook/exec or plugin for Graphite/InfluxDB events and Hipchat #27

Open VAdamec opened 7 years ago

VAdamec commented 7 years ago

Hi, is there any chance to add webhook call (for example Jenkins) or simple exec ? For example my use case is to adding events/tags to Graphite/InfluxDB, like this:

curl -X POST "http://xxx:xxxx@influxdb:8086/write?db=events&precision=s" --data-binary "events title=\"Service prometheus degraded\",text=\"stack Prometheus became degraded (active)\",tags=\"rancher,alerts\" date +%s"

curl -X POST "http://graphite/events/" -d '{"what": "Service prometheus degraded", "tags": "rancher,alerts", "data": "stack Prometheus became degraded (active) at Fri Jan 3 22:34:41 UTC 2017"}'

VAdamec commented 7 years ago

https://github.com/VAdamec/rancher-alarms - graphite draft (authentication has some issue, still getting 401 and template can be completely removed). Any advice will be appreciated

VAdamec commented 7 years ago

await axios({url: this._url, headers: {'Authorization': 'Basic Z3Vlc3Q6Z3Vlc3Q='}, withCredentials: true, auth: {username: this._GraphiteLogin, password: this._GraphitePass}, method: 'POST', data: webhookPayload});

auth setup with pass and login not working, with auth header and base64 hash it's ok. Anybody know how to create base64 hash ? I'm not programmer and didn't find any working solution for such easy operation :-)

ndelitski commented 7 years ago

Hello @VAdamec! You are on a correct way by adding a new Notification target. For your case with passing credentials try not to add headers: Authorizaion field when you already defined auth one. If you would like setup basic auth header manually then just remove auth prop and use Buffer for encoding {Authorization: 'Basic ' + new Buffer(username + ':' + password).toString('base64')}, no need to add special package for base64 encoding. Please send me a PR and I will cleanup your code and we could work on releasing your feature then.

VAdamec commented 7 years ago

Still no luck to use auth, so base64 header is now only option. I'll make some test tomorrow and send you PR.

VAdamec commented 7 years ago

29

VAdamec commented 7 years ago

No luck with auth, so just basic header used. Not sure about npm module installation. I have stable builds and tests with adding direct installation to Dockerfile. Also minimatch package was added due deprecation/security warning of used version.

RUN npm install minimatch
RUN npm install js-base64
VAdamec commented 7 years ago

Hipchat added