# How to create an alert when apm agent stops working?

**URL:** <https://discuss.elastic.co/t/how-to-create-an-alert-when-apm-agent-stops-working/373618>\
**Category:** APM\
**Tags:** java\
**Created:** [January 24, 2025, 6:15am UTC](https://discuss.elastic.co/t/how-to-create-an-alert-when-apm-agent-stops-working/373618 "2025-01-24T06:15:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![krishnannair87](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krishnannair87/32/140928_2.png) [@krishnannair87](https://discuss.elastic.co/u/krishnannair87)\
**Post date:** [January 24, 2025, 6:15am UTC](https://discuss.elastic.co/t/how-to-create-an-alert-when-apm-agent-stops-working/373618/1 "2025-01-24T06:15:50Z")

</div>

I have multiple elastic apm java agent deployed and i need to create an alert when it stops working. I see one topic relevant to this but I still want to check what is the configuration of alert in case we enable health metrics as suggested in below topic :

> [@I need to create an Alert in case APM stop working. Does Kibana have anything that could help with it?](https://discuss.elastic.co/t/i-need-to-create-an-alert-in-case-apm-stop-working-does-kibana-have-anything-that-could-help-with-it/346070):
>
> I've installed multiple Java APM agents and would like to monitor them in a sense that if any stop responding I get an alert. The same principle would be for the Elastic-Agent. I saw some alerts for metrics and logs threshold but couldn't reach a sense for the way to approach. If anyone could help on this it would be great! Elastic Cloud 8.5.1

Can someone please suggest if they worked on it. I am pretty much new to elastic. Please help.

Elastic version : 8.13.2

Regards,  
Gopikrishnan R.

---

<div class="post-metadata">

**Author:** ![atul\_mohan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/atul_mohan/32/137776_2.png) [@atul\_mohan](https://discuss.elastic.co/u/atul_mohan)\
**Post date:** [January 28, 2025, 1:26am UTC](https://discuss.elastic.co/t/how-to-create-an-alert-when-apm-agent-stops-working/373618/2 "2025-01-28T01:26:16Z")

</div>

```auto
{
  "rule_id": "apm-agent-health-alert",
  "risk_score": 50,
  "severity": "medium",
  "description": "Alert when an APM agent stops sending health metrics",
  "interval": "5m",
  "name": "APM Agent Health Alert",
  "type": "query",
  "from": "now-5m",
  "to": "now",
  "query": {
    "bool": {
      "must_not": [
        {
          "exists": {
            "field": "agent.name"
          }
        }
      ],
      "filter": [
        {
          "range": {
            "@timestamp": {
              "gte": "now-5m",
              "lte": "now"
            }
          }
        }
      ]
    }
  },
  "actions": [
    {
      "action_type_id": ".email",
      "group": "default",
      "params": {
        "to": ["your-email@example.com"],
        "subject": "APM Agent Health Alert",
        "body": "An APM agent has stopped sending health metrics."
      }
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![ashishtiwari1993](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashishtiwari1993/32/135241_2.png) [@ashishtiwari1993](https://discuss.elastic.co/u/ashishtiwari1993)\
**Post date:** [January 28, 2025, 6:13am UTC](https://discuss.elastic.co/t/how-to-create-an-alert-when-apm-agent-stops-working/373618/3 "2025-01-28T06:13:35Z")

</div>

Hi @krishnannair87, Welcome to the Elastic community.

Adding to @atul_mohan suggestion, you can also try to setup [APM Rules and alerts](https://www.elastic.co/guide/en/observability/current/apm-alerts.html) on your data.

---

<div class="post-metadata">

**Author:** ![krishnannair87](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krishnannair87/32/140928_2.png) [@krishnannair87](https://discuss.elastic.co/u/krishnannair87)\
**Post date:** [January 28, 2025, 10:01am UTC](https://discuss.elastic.co/t/how-to-create-an-alert-when-apm-agent-stops-working/373618/4 "2025-01-28T10:01:24Z")

</div>

@atul_mohan @ashishtiwari1993 thanks for your response. I am pretty much beginner in elastic so need some guidance. If I click on option **Alerts and rules** → **Manage rules** → **Create Rule** I only see options to create alert on APM anamoly, failed threshold count, latency etc. how can i create alert on agent status metrics?

Regards,  
Gopikrishnan R.
