Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Validating WebHook-Response #49

Closed
mathewlsm opened this issue May 8, 2019 · 4 comments
Closed

Validating WebHook-Response #49

mathewlsm opened this issue May 8, 2019 · 4 comments

Comments

@mathewlsm
Copy link
Contributor

Hello,

we created an alerting with an action calling a webhook. The webhook calls a restservice which creates a ticket for the responsible person. Our Ticketsystem return a 201 if the ticket was created successfull.

The Problem is that the DestinationHTTPClient just accept a 200 HTTP-Status as valid.

The HttpClient should also accept a 201 return code.

mathewlsm added a commit to mathewlsm/alerting that referenced this issue May 8, 2019
Reststatus.Created for WebHook-Response is also acceptable (opendistro-for-elasticsearch#49).
mathewlsm added a commit to mathewlsm/alerting that referenced this issue May 8, 2019
mathewlsm added a commit to mathewlsm/alerting that referenced this issue May 8, 2019
…arch#49

Reststatus.Created for WebHook-Response is also acceptable
mathewlsm pushed a commit to mathewlsm/alerting that referenced this issue May 9, 2019
using all 2XX response status as valid response
@aceat64
Copy link

aceat64 commented Oct 15, 2019

I'm still getting an error when a webhook destination returns a 202:

[2019-10-15T15:26:20,043][ERROR][c.a.o.a.d.f.CustomWebhookDestinationFactory] [hot-data-az1-1] Exception publishing Message: DestinationType: CUSTOMWEBHOOK, DestinationName:REDACTED, Url: https://REDACTED, scheme: HTTPS, Host: null, Port: -1, Path: null, Message: { REDACTED }
java.io.IOException: Failed: HttpResponseProxy{HTTP/1.1 202 Accepted [Date: Tue, 15 Oct 2019 15:26:20 GMT, Content-Type: application/json, Content-Length: 32, Connection: keep-alive, CF-Cache-Status: DYNAMIC, Expect-CT: max-age=604800, report-uri="https://REDACTED", Server: cloudflare, CF-RAY: REDACTED] ResponseEntityProxy{[Content-Type: application/json,Content-Length: 32,Chunked: false]}}
	at com.amazon.opendistroforelasticsearch.alerting.destination.client.DestinationHttpClient.validateResponseStatus(DestinationHttpClient.java:156) ~[?:?]
	at com.amazon.opendistroforelasticsearch.alerting.destination.client.DestinationHttpClient.execute(DestinationHttpClient.java:81) ~[?:?]
	at com.amazon.opendistroforelasticsearch.alerting.destination.factory.CustomWebhookDestinationFactory.publish(CustomWebhookDestinationFactory.java:42) ~[?:?]
	at com.amazon.opendistroforelasticsearch.alerting.destination.factory.CustomWebhookDestinationFactory.publish(CustomWebhookDestinationFactory.java:29) ~[?:?]
	at com.amazon.opendistroforelasticsearch.alerting.destination.Notification.lambda$publish$0(Notification.java:43) ~[?:?]
	at java.security.AccessController.doPrivileged(Native Method) [?:1.8.0_201]
	at com.amazon.opendistroforelasticsearch.alerting.destination.Notification.publish(Notification.java:41) [alerting-notification-0.9.0.0.jar:?]
	at com.amazon.opendistroforelasticsearch.alerting.model.destination.Destination.publish(Destination.kt:167) [opendistro_alerting-0.9.0.0.jar:0.9.0.0]
	at com.amazon.opendistroforelasticsearch.alerting.MonitorRunner.runAction(MonitorRunner.kt:393) [opendistro_alerting-0.9.0.0.jar:0.9.0.0]
	at com.amazon.opendistroforelasticsearch.alerting.MonitorRunner.runMonitor(MonitorRunner.kt:196) [opendistro_alerting-0.9.0.0.jar:0.9.0.0]
	at com.amazon.opendistroforelasticsearch.alerting.MonitorRunner.runMonitor$default(MonitorRunner.kt:166) [opendistro_alerting-0.9.0.0.jar:0.9.0.0]
	at com.amazon.opendistroforelasticsearch.alerting.MonitorRunner$runJob$1.run(MonitorRunner.kt:160) [opendistro_alerting-0.9.0.0.jar:0.9.0.0]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_201]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_201]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:681) [elasticsearch-6.7.1.jar:6.7.1]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_201]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_201]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_201]

@mathewlsm
Copy link
Contributor Author

Hello Andrew,

the improvement is not merged back to version 0.9.0.0.

It's avaiable in following versions: v1.2.0.1 v1.2.0.0 v1.1.0.1 v1.1.0.0 v1.0.0.0; which means 1.0.0.0 and above.

Kind regards

Mathew

I'm still getting an error when a webhook destination returns a 202:

	at com.amazon.opendistroforelasticsearch.alerting.destination.Notification.publish(Notification.java:41) [alerting-notification-0.9.0.0.jar:?]

@perkons
Copy link

perkons commented Jun 16, 2020

When creating alert destination getting return code 201

POST /_opendistro/_alerting/destinations/

{
  "name": "test-destination-1",
  "type": "slack",
  "slack": {
    "url": "http://www.example.com"
  }
}

@perkons
Copy link

perkons commented Jun 16, 2020

Same goes for alert monitor creation, getting code 201

tlfeng pushed a commit that referenced this issue Feb 6, 2021
* Issue #49

using all 2XX response status as valid response, fixes #50 & fixes #49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants