# How to prevent duplicate alerts from Security Analytics Detector

**URL:** <https://forum.opensearch.org/t/how-to-prevent-duplicate-alerts-from-security-analytics-detector/27549>\
**Category:** Security Analytics\
**Created:** [November 26, 2025, 5:43pm UTC](https://forum.opensearch.org/t/how-to-prevent-duplicate-alerts-from-security-analytics-detector/27549 "2025-11-26T17:43:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![plane636](https://avatars.discourse-cdn.com/v4/letter/p/5f9b8f/32.png) [@plane636](https://forum.opensearch.org/u/plane636)\
**Post date:** [November 26, 2025, 5:43pm UTC](https://forum.opensearch.org/t/how-to-prevent-duplicate-alerts-from-security-analytics-detector/27549/1 "2025-11-26T17:43:36Z")

</div>

Hello,

I have a problem with my Security Analytics Detector configuration.

**My Goal:** I want to detect a specific command (`input: 'rz'`) in **new logs only**.

**My Setup:**

- I am using the **Security Analytics** plugin.

- My Detector is scheduled to run **every 1 minute**.

**The Problem:** Every minute when the detector runs, it appears to re-scan **all historical logs** in my index. It’s not just checking the “latest” logs.

This causes the system to find the same old `rz` logs from hours (or days) ago and send me the **exact same duplicate alert, every single minute.**

**My Question:** How can I configure my Detector (or its Rule) to **only check the newest logs** (e.g., only data from the last 1-2 minutes) and stop it from scanning all of history?

I just want to be alerted for _new_ events, not old ones repeatedly.

Thank you.

---

<div class="post-metadata">

**Author:** ![Anthony](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/anthony/32/9939_2.png) [@Anthony](https://forum.opensearch.org/u/Anthony)\
**Post date:** [November 26, 2025, 7:15pm UTC](https://forum.opensearch.org/t/how-to-prevent-duplicate-alerts-from-security-analytics-detector/27549/2 "2025-11-26T19:15:23Z")

</div>

@plane636 I don’t think there is a way to add period in the SA alerts. For the use case you mentioned you should be using alerting module instead of security analytics, which runs using detection rules.

The alert can be configured in the following way:

First create the destination id:

```auto
POST _plugins/_notifications/configs
{
  "config": {
    "name": "slack_security_alerts",
    "description": "Security Analytics alerts to Slack",
    "config_type": "slack",
    "is_enabled": true,
    "slack": {
      "url": "https://hooks.slack.com/services/T06F0G89N84/B07E2ES9WLR/xzxb3o8EUvxGCAFZQ....."
    }
  }
}

```

Then using the destination ID create the alert. Note the timestamp range filter.

```auto
POST _plugins/_alerting/monitors
{
  "name": "Failed logins in last minute (security-auditlog)",
  "type": "monitor",
  "enabled": true,
  "schedule": {
    "period": {
      "interval": 1,
      "unit": "MINUTES"
    }
  },
  "inputs": [
    {
      "search": {
        "indices": [
          "security-auditlog-2025.11.26"
        ],
        "query": {
          "size": 0,
          "query": {
            "bool": {
              "filter": [
                {
                  "range": {
                    "@timestamp": {
                      "gte": "{{period_end}}||-1m",
                      "lte": "{{period_end}}",
                      "format": "epoch_millis"
                    }
                  }
                },
                {
                  "term": {
                    "audit_category.keyword": "FAILED_LOGIN"
                  }
                }
              ]
            }
          }
        }
      }
    }
  ],
  "triggers": [
    {
      "name": "Any failed login in last minute",
      "severity": "2",
      "condition": {
        "script": {
          "lang": "painless",
          "source": "return ctx.results[0].hits.total.value > 0;"
        }
      },
      "actions": [
        {
          "name": "Send to Slack – Security Alerts",
          "destination_id": "QmiMwZoBWMHgRWmXgI5A",
          "message_template": {
            "lang": "mustache",
            "source": "*FAILED_LOGIN detected in the last minute*\nCluster: {{ctx.monitor.name}}\nHits: {{ctx.results[0].hits.total.value}}\nPeriod end: {{ctx.periodEnd}}"
          },
          "throttle_enabled": false
        }
      ]
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/3/33547ea01a5b12dcca2958411d3edd97ae2ea8c1.png) [@system](https://forum.opensearch.org/u/system)\
**Post date:** [January 25, 2026, 7:16pm UTC](https://forum.opensearch.org/t/how-to-prevent-duplicate-alerts-from-security-analytics-detector/27549/3 "2026-01-25T19:16:08Z")

</div>

Closed on January 25, 2026, 7:16pm UTC

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