[ALERTING] Malfored URLs when trying to create a chained input watch


#1

I am trying to create a chained input for watcher that involves reading response from an API and making another another API call to the service mentioned in the body of the first request. Here's what the input looks like:

"inputs": [
        {
          "first": {
            "http": {
              "request": {
                "host": "localhost",
                "port": 1200,
                "path": "/status/service/myservice",
                "params": {
                  "somevar": "somevalue"
                }
              }
            }
          }
        },
        {
          "second": {
            "http": {
              "request": {
                "url": "http://{{ctx.payload.first.data[0].ip}}:{{ctx.payload.first.data.port}}/somepath/inservice/status"
              }
            }
          }
        }

But when trying to create the watch, I get the error:

{
  "error": {
    "root_cause": [
      {
        "type": "parse_exception",
        "reason": "Malformed URL ["http://{{ctx.payload.first.data[0].ip}}:{{ctx.payload.first.data.port}}/somepath/inservice/status]"
      }
    ],
    "type": "parse_exception",
    "reason": "could not parse [http] input for watch [second]. failed to parse http request template",
    "caused_by": {
      "type": "parse_exception",
      "reason": "Malformed URL ["http://{{ctx.payload.first.data[0].ip}}:{{ctx.payload.first.data.port}}/somepath/inservice/status]"
    }
  },
  "status": 400
}

Also, I see that String values are not allowed in the request.port and hence the long format for definition of the http request will also not work.
Is this not supported in X-Pack Alerting even in the latest versions? Or I have to upgrade?
Elasticsearch Version: 5.4.2


(Alexander Reelsen) #2

The url field from the request is not templateable, you would need to use the host, port, path and port fields, which are.

Hope this helps!


#3

I think even the port field is not templatable. When I do,

{
  "host": "localhost",
   "port": "{{ctx.payload.first.data.port}}",
   "path": "/status/service/myservice",
   "params": {
     "somevar": "somevalue"
    }
}

I get a validation error from Elasticsearch saying port cannot be a string. Also, just using "port": {{ctx.payload.first.data.port}} is bad json. I am not sure how to proceed with this.


(Alexander Reelsen) #4

Hey,

indeed, I stand corrected here. I just checked the source and only path, headers, params and the body are templetable for now.

--Alex


#5

This actually limits the use of chained input. Is there a place where I can raise this issue?


(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.