# Watcher Actions

**URL:** <https://discuss.elastic.co/t/watcher-actions/212396>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [December 18, 2019, 7:59pm UTC](https://discuss.elastic.co/t/watcher-actions/212396 "2019-12-18T19:59:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mord](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@mord](https://discuss.elastic.co/u/mord)\
**Post date:** [December 18, 2019, 7:59pm UTC](https://discuss.elastic.co/t/watcher-actions/212396/1 "2019-12-18T19:59:17Z")

</div>

I work with Watcher and I want to create alerts. my want is to check if the "\_id" parameter exists in index-2 from index-1.  
If it does not exist in, It should copy the log to that index (from 1 to 2).

For example, at the table below we check every "\_id" in index-1 and want to copy "333" because it does not exist in index-2.  
on the other hand, "222" parameter from index-1 already exists in index-2, therefore nothing should be done.

index-1(\_id field) | index-2 (\_id field)  
111 | 111  
222 | 222  
222 | 333  
333 | 444  
222 |  
444 |

```
{
  "trigger": {
    "schedule": {
      "interval": "1m"
    }
  },
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "*"
        ],
        "rest_total_hits_as_int": true,
        "body": {
          "query": {
            "bool": {
              "filter": [
                {
                  "range": {
                    "@timestamp": {
                      "from": "now-1m"
                    }
                  }
                }
              ]
            }
          }
        }
      }
    }
  },
  "condition": {
    "compare": {
      "ctx.payload.hits.total": {
        "gt": 0
      }
    }
  },
  "actions": {
    "index_payload": {
      "index": {
        "index": "check",
        "doc_id": "{{ctx.payload._id}}"
      }
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [December 19, 2019, 9:07am UTC](https://discuss.elastic.co/t/watcher-actions/212396/2 "2019-12-19T09:07:53Z")

</div>

this requires you to scroll through your data using a scroll search. That however is not supported by any watcher action or input.

Can you maybe take a step back and explain the full use-case, maybe there is another solution we can find. Why do you need the same data in two indices to start with?

--Alex

---

<div class="post-metadata">

**Author:** ![mord](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@mord](https://discuss.elastic.co/u/mord)\
**Post date:** [December 19, 2019, 9:43am UTC](https://discuss.elastic.co/t/watcher-actions/212396/3 "2019-12-19T09:43:08Z")

</div>

Hi,

I'm using in Symantec WSS to getting logs to my logstash,  
I got logs, but for safety, those logs are duplicates from there service.

Downloading the logs and replacing the current logs with the new one

 ![this form index-2 - I didn't get _id log](https://us1.discourse-cdn.com/elastic/original/3X/8/6/868736c03b8bd5980b3f72d26d5f9393b005b677.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 16, 2020, 9:43am UTC](https://discuss.elastic.co/t/watcher-actions/212396/4 "2020-01-16T09:43:08Z")

</div>

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