Watcher actions body

Watcher actions body How to save search query
watcher configure:

{
  "trigger": {
    "schedule": {
      "interval": "10s"
    }
  },
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "logstash-*"
        ],
        "rest_total_hits_as_int": true,
        "body": {
          "query": {
            "bool": {
              "must": {
                "match": {
                  "path": "/api/v1"
                }
              },
              "filter": {
                "range": {
                  "@timestamp": {
                    "from": "{{ctx.trigger.scheduled_time}}||-5m",
                    "to": "{{ctx.trigger.triggered_time}}"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "condition": {
    "compare": {
      "ctx.payload.hits.total": {
        "lt": 10
      }
    }
  },
  "actions": {
    "ops": {
      "webhook": {
        "scheme": "http",
        "host": "xxx",
        "port": 5000,
        "method": "post",
        "path": "/xxx",
        "body": "{{#toJson}}ctx{{/toJson}}"
      }
    }
  }
}

I'am want to add input search query or kibana search query url in webhook body, How?

The search results are available in the ctx.payload variable. If you need to modify the data before sending it somewhere else, you can use a transform script to do so.

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