Watcher index action not able to save

We are using elastic cloud and elasticsearch and kibana 6.6.1. When I try to create an advanced watcher with an index action, it is not possible to save. There is an error in the browser console:

Error: Attempted to create unknown action type index.
    at JsonWatch.createAction (kibana.bundle.js:2)
    at kibana.bundle.js:2
    at Array.forEach (<anonymous>)
    at JsonWatchEditController.createActionsForWatch (kibana.bundle.js:2)
    at WatchEditTitleBarController.JsonWatchEditController._this.onWatchSave (kibana.bundle.js:2)
    at fn (eval at compile (vendors.bundle.dll.js:434), <anonymous>:4:212)
    at callback (vendors.bundle.dll.js:434)
    at Scope.$eval (vendors.bundle.dll.js:434)
    at Scope.$apply (vendors.bundle.dll.js:434)
    at HTMLButtonElement.<anonymous> (vendors.bundle.dll.js:434)
    at HTMLButtonElement.dispatch (vendors.bundle.dll.js:149)
    at HTMLButtonElement.elemData.handle (vendors.bundle.dll.js:149)

The action should be according to documentation:

"index_payload": {
  "transform": {
    "script": "return [ 'inAlert' : ctx.vars.fails_check ]"
  },
  "index": {
    "index": "{{ctx.metadata.alertindex}}",
    "doc_type": "{{ctx.metadata.alerttype}}",
    "doc_id": "{{ctx.metadata.alertid}}"
  }
}

Any ideas what I'm doing wrong?

And this is the entire watcher definition:

{
  "trigger": {
    "schedule": {
      "interval": "1m"
    }
  },
  "input": {
    "chain": {
      "inputs": [
        {
          "alert": {
            "search": {
              "request": {
                "search_type": "query_then_fetch",
                "indices": ["watcheralerts"],
                "types": [],
                "body": {
                  "query": {
                    "bool": {
                      "must": [
                        {
                          "term": {
                            "_id": "{{ctx.metadata.alertid}}"
                          }
                        },
                        {
                          "term": {
                            "inAlert": true
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        {
          "check": {
            "search": {
              "request": {
                "search_type": "query_then_fetch",
                "indices": ["heartbeat-*"],
                "types": [],
                "body": {
                  "query": {
                    "bool": {
                      "filter": [
                        {
                          "term": {
                            "monitor.status": {
                              "value": "down"
                            }
                          }
                        },
                        {
                          "range": {
                            "@timestamp": {
                              "gte": "now-1m"
                            }
                          }
                        },
                        {
                          "term": {
                            "monitor.name": "{{ctx.metadata.heartbeatname}}"
                          }
                        }
                      ]
                    }
                  },
                  "sort": "@timestamp"
                }
              }
            }
          }
        }
      ]
    }
  },
  "condition": {
    "script": {
      "source": "ctx.vars.fails_check = ctx.payload.check.hits.total != 0 && ctx.payload.check.hits.hits[0]._source.monitor.status != 'up'; ctx.vars.not_resolved = ctx.payload.alert.hits.total == 1;if (ctx.vars.fails_check && ctx.vars.not_resolved){return false;} else {return ctx.vars.fails_check || ctx.vars.not_resolved;}",
      "lang": "painless"
    }
  },
  "actions": {
    "log": {
      "transform": {
        "script": {
          "source": "return ['status': ctx.vars.fails_check ? 'down' : 'up']",
          "lang": "painless"
        }
      },
      "logging": {
        "level": "info",
        "text": "{{ctx.metadata.heartbeatname}} is {{ctx.payload.status}}"
      }
    },
    "slack_1": {
      "transform": {
        "script": {
          "source": "return ['status': ctx.vars.fails_check ? 'down' : 'up']",
          "lang": "painless"
        }
      },
      "slack": {
        "message": {
          "to": ["#web-api-notifications"],
          "text": "{{ctx.metadata.heartbeatname}} is {{ctx.payload.status}}"
        }
      }
    },
    "index_payload": {
      "transform": {
        "script": "return [ 'inAlert' : ctx.vars.fails_check ]"
      },
      "index": {
        "index": "{{ctx.metadata.alertindex}}",
        "doc_type": "{{ctx.metadata.alerttype}}",
        "doc_id": "{{ctx.metadata.alertid}}"
      }
    }
  },
  "metadata": {
    "heartbeatname": "[CRM] GET /index.html",
    "heartbeatindex": "heartbeat-*",
    "alertid": "crm_get_index.html",
    "alertindex": ".watcheralerts",
    "alerttype": "doc",
    "tz": "Europe/Oslo"
  }
}

This is a bug. Could you please file an issue in the Kibana Github repo? https://github.com/elastic/kibana/issues

Ok, added the issue here https://github.com/elastic/kibana/issues/32517

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