kapacitor icon indicating copy to clipboard operation
kapacitor copied to clipboard

httppost handler throws unsupported protocol scheme when endpoint is created using REST API

Open pravindamodaran opened this issue 6 years ago • 1 comments

kapacitor version: 1.5.4 Environment: docker-compose/kubernetes Docker image used: 1.5.4-alpine

I'm trying to create a handler using httppost. If I specify the httppost endpoint in the kapacitor config file, it works fine and POST gets triggered. But when I try to create similar endpoint using kapacitor's REST API, I get Post : unsupported protocol scheme \"\"" on handling the alert. I confirmed that the URL has the http protocol specified. These are the logs (first request returned an error response, dont mind it. Atleast it reached the server):

httppost endpoint defined in kapacitor config file:

kapacitor_1   | ts=2020-06-19T07:37:20.002Z lvl=debug msg="alert triggered" service=kapacitor task_master=main task=arista_interface node=alert4 level=CRITICAL id=Arista event_message="Arista: Arista ifcounters CRITICAL map[value:false]" data="&{ifcounters map[host:telegraf name:Loopback1 source:54.202.79.126] [time value] [[2020-06-19 07:37:00 +0000 UTC false]]}"
kapacitor_1   | ts=2020-06-19T07:37:20.012Z lvl=error msg="POST returned non 2xx status code" service=httppost handler=post-interface-loopback-down-alert topic=interface err="{\"errors\":{\"error\":[{\"error-type\":\"protocol\",\"error-tag\":\"data-missing\",\"error-message\":\"Mount point does not exist.\"}]}}" code=404

httppost created using REST API:

kapacitor_1   | ts=2020-06-19T07:37:20.003Z lvl=debug msg="alert triggered" service=kapacitor task_master=main task=arista_interface-duplicate node=alert4 level=CRITICAL id=Arista event_message="Arista: Arista ifcounters CRITICAL map[value:false]" data="&{ifcounters map[host:telegraf name:Loopback1 source:54.202.79.126] [time value] [[2020-06-19 07:37:00 +0000 UTC false]]}"
kapacitor_1   | ts=2020-06-19T07:37:20.003Z lvl=error msg="failed to POST alert data" service=httppost handler=post-interface-loopback-down-alert-duplicate topic=interface err="Post : unsupported protocol scheme \"\""

This is the list of httppost endpoints obtained using REST API: curl kapacitor:9092/kapacitor/v1/config/httppost

{
	"link": {
		"rel": "self",
		"href": "/kapacitor/v1/config/httppost"
	},
	"elements": [{
		"link": {
			"rel": "self",
			"href": "/kapacitor/v1/config/httppost/loopback-interface-alert"
		},
		"options": {
			"alert-template": "",
			"alert-template-file": "/etc/kapacitor/loopback-interface-alert-template.html",
			"basic-auth": true,
			"endpoint": "loopback-interface-alert",
			"headers": {
				"Content-Type": "application/json"
			},
			"row-template": "",
			"row-template-file": "",
			"url": "http://lsc:8181/restconf/operations/jsonrpc:config/configured-endpoints/napalm/yang-ext:mount/ldk-napalm:send-config"
		},
		"redacted": ["basic-auth"]
	}, {
		"link": {
			"rel": "self",
			"href": "/kapacitor/v1/config/httppost/loopback-interface-alert-duplicate"
		},
		"options": {
			"alert-template": "",
			"alert-template-file": "/etc/kapacitor/loopback-interface-alert-template.html",
			"basic-auth": true,
			"endpoint": "loopback-interface-alert-duplicate",
			"headers": {
				"Content-Type": "application/json"
			},
			"row-template": "",
			"row-template-file": "",
			"url": "http://lsc:8181/restconf/operations/jsonrpc:config/configured-endpoints/napalm/yang-ext:mount/ldk-napalm:send-config"
		},
		"redacted": ["basic-auth"]
	}]
}

Steps to reproduce issue:

  1. Start kapacitor using default config (either docker-compose or kubernetes, or just plain vanilla docker container)
  2. Create a http-post endpoint through REST API. Check if it has been created successfully either through REST API or kapacitor cli command
  3. Create a task with some arbitrary rule, which triggers alert to specific topic
  4. Create an http-post topic handler which subscribes to the topic, and calls the endpoint created in step 2. Check the logs to see the response of the POST request. The reason I am creating a defined handler and not calling the endpoint directly from TICKscript is to trigger the alert only when the level is CRITICAL. This can be set only through a defined handler, and not in TICKscript.

pravindamodaran avatar Jun 30 '20 17:06 pravindamodaran

Tried specifying the http-post endpoint directly in TICKscript, getting the same error. Looks like the endpoint created through REST api is not visible to the topic-handler/TICKscript (I get the same error when a non-existing endpoint is specified)

kapacitor_1   | ts=2020-07-01T15:31:20.004Z lvl=error msg="failed to POST alert data" service=httppost task=arista-loopback err="Post : unsupported protocol scheme \"\"" 

pravindamodaran avatar Jul 01 '20 15:07 pravindamodaran