XPack Alerting :- Get Nodes Stats and Cluster State APIs in http input plugin

Hi,

I want to use both Nodes and Cluster State APIs in http input plugin for alerting.

{
  "trigger": {
    "schedule": {
      "interval": "10s"
    }
  },
  "input" : {
  "http" : {
    "request" : {
      "scheme": "https",
      "host" : "<hostname>",
      "port" : <port>,
      "path" : "/_nodes/stats",
      "params" : {
        "human" : "true" 
      }
    }
  }
},
  "actions": {
  }
}

Now how can I add other API "/_cluster/stats" for input.

I also try chaining -

{
  "trigger": {
    "schedule": {
      "interval": "10s"
    }
  },
  "input" : {
  "chain" : {
    "inputs" : [ 
      {
        "first" : {
            "http" : {
      "request" : {
      "scheme": "https",
      "host" : "<hostname>",
      "port" : 9200,
      "path" : "/_nodes/stats",
      "params" : {
        "human" : "true" 
      }
    }
  }
        }
      },
      {
        "second" : {
    "http" : {
     "request" : {
      "scheme": "https",
      "host" : "<hostname>",
      "port" : 9200,
      "path" : "/_cluster/stats",
      "params" : {
        "human" : "true" 
      }
    }
  }
        }
      }
    ]
  }
}
}

Any luck?

can you provide more context? Does an error occur when you store a watch? Does an error occur when the watch is executed? What error occurs? Is there a stacktrace? Can you provide the full output of the execute watch API?

It's nearly to impossible to help if you just post two JSON snippets without knowing more.

Thank you!

--Alex

Actually my question is , can we read two http input plugins in same watcher and if yes then How.

using the chained input is indeed the way to go. If that does not work, we need the above mentioned information.

--Alex

If I'm not using chaining, then I access value of {{ctx.payload.nodes.gdnF8AEHSXWISPlGy1FOCA.fs.total.available_in_bytes}}

but after enable chaining its coming blank.(Check my first comment for chain json )

yes, because chaining requires you to add the name of the chain, in your example you used first and second

1 Like

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