Watcher post data

Hi All,

I am executing a watcher which post data to an API. In it self this works fine, however the data format is something I am struggling with. My watcher looks like this.

  "trigger": {
    "schedule": {
      "cron": "0 */15 * * * ?"
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
        "types": [],
        "body": {
          "_source": [
          "query": {
            "bool": {
              "must": [
                  "query_string": {
                    "query": "source_affiliate:nlmail AND dw002:true",
                    "analyze_wildcard": true,
                    "default_field": "*"
                  "range": {
                    "@timestamp": {
                      "gte": "now-15m",
                      "lte": "now"
              "filter": [],
              "should": [],
              "must_not": []
  "condition": {
    "script": {
      "source": "boolean trigger=false;ArrayList offenders = new ArrayList();for(int i=0;i<ctx.payload.hits.hits.size();i++){offenders.add(i, ctx.payload.hits.hits[i]._source);}ctx.vars.offenders=offenders;trigger=true;return trigger;",
      "lang": "painless",
      "params": {
        "dw002": 1
  "actions": {
    "xredir_post": {
      "webhook": {
        "scheme": "http",
        "host": "",
        "port": 80,
        "method": "post",
        "path": "/v1/block_dw002",
        "params": {},
        "headers": {
          "Content-Type": "application/json"
        "auth": {
          "basic": {
            "username": "admin",
            "password": "::es_redacted::"
        "body": "{{ctx.vars.offenders}}"

The data it posts looks like this.

"{0={dw002=true, ip=, block_reason=botnetloginfrom,, block_data=,}, 1={ip=, dw002=true, block_reason=botnetloginfrom,, block_data=,}, 2={ip=, dw002=true, block_reason=botnetloginfrom,, block_data=,}, 3={ip=, dw002=true, block_reason=botnetloginfrom,, block_data=,}, 4={dw002=true, ip=, block_reason=botnetloginfrom,, block_data=,}, 5={ip=, dw002=true, block_reason=botnetloginfrom,, block_data=,}, 6={ip=, dw002=true, block_reason=botnetloginfrom,, block_data=,}, 7={dw002=true, ip=, block_reason=botnetloginfrom,, block_data=,}}"

I basically need to send a array with the _source to the API but I seem to do something wrong..

I hope somebody can give me some advice.


Please remove references to invaluement's host names from your comments (or anywhere). (1) those are old host names that are on their way out - only a handful of our customers still use those (2) normally queries to these are blocked unless they come from specific IPs that belong to paying customers (3) however, they were recently opened up for a short time in jan/2019 - but that won't last long (4) SOON - AFTER WE MIGRATE OUR LAST CUSTOMERS AWAY FROM USING THESE OLD HOST NAMES - WE WILL START "BLACKLISTING THE WORLD" ON THOSE HOST NAMES.

Again, we haven't official used these in years, only a few customers still use those, and attempted use of these by non-customers is unauthorized and abusive. And will be very dumb very soon since ALL queries to those will start answering in the very near future. So by publishing that here - you're leading others off a cliff. So please delete those host names from your code. (unless you just LIKE leading others off a cliff - if so, then keep it as is - and hopefully they'll read my warning so that they'll understand what to expect.)
Thanks for your help with this!
Rob McEwen, CEO of

Hi Rob,

  1. I should have anonymized that data better. My apologies for that, I will do that.
  2. Your making the assumption that I am not a paying customer and there for I am a abuser, this is not the case.
  3. How does you reply help my problem? it does not..
  4. You don't have to SHOUT.


ps. You could have contacted me trough a private message, would have been a lot nicer..

Paul, Thanks for the fast response. Sorry if I came across as a jerk - I just wanted anyone reading this to understand and take seriously the potential damage that would happen if they started using those invaluement host names - especially if we end up "listing the world" after we soon migrate away from those particular host names. Also, I STILL have no idea who you are. I have no idea what company you represent. You could be some "Paul" I've talked to before a dozen times! (but maybe I just never had your last name?) or you could be an employee of a company we do business with - but I never worked with you directly? I can't find a reference to ANY person I've exchanged emails with who goes by the name "Paul Janzen" - or any "janzen" in my customer database or in any emails I've sent or received. Forgive me if I'm overlooking something? But from my perspective, I didn't know you were a customer since I couldn't find anything recognizable from your post. While I don't doubt what you're saying - I can't read minds and I still don't know who you are or what company you represent. ("Paul" alone isn't specific enough, and I can't find any references to "Janzen"). I wasn't trying to be mean - but sometimes when our host names are published online - many organizations can pick up on that and it can slowly turn into the equivalent of a denial of service attack. Since I didn't know who you were, I needed to word that strongly and clearly to make sure the message was getting across. I hope you understand. And thanks for going back and editing your previous comment.
PS - Please send me an email so that i can connect-the-dots as to who you are and/or who you represent - the suspense is killing me! Thanks!
--Rob McEwen

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