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


(Shivanshu Bagga) #1

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?


(Alexander Reelsen) #2

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


(Shivanshu Bagga) #3

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


(Alexander Reelsen) #4

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

--Alex


(Shivanshu Bagga) #5

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 )


(Alexander Reelsen) #6

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


(system) #7

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