# systemd alert for nginx service

**URL:** <https://community.netdata.cloud/t/systemd-alert-for-nginx-service/4624>\
**Category:** Help\
**Tags:** configuration, agent, alerts\
**Created:** [August 30, 2023, 9:25am UTC](https://community.netdata.cloud/t/systemd-alert-for-nginx-service/4624 "2023-08-30T09:25:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![avrapal](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.netdata.cloud/avrapal/32/3119_2.png) [@avrapal](https://community.netdata.cloud/u/avrapal)\
**Post date:** [August 30, 2023, 9:25am UTC](https://community.netdata.cloud/t/systemd-alert-for-nginx-service/4624/1 "2023-08-30T09:25:38Z")

</div>

Hello Netdata Gurus,

I have a few questions that I am hoping someone can help with:

I am trying to create an email alert using `systemd` to check if the `nginx` service is running.  
This is my alert configuration:

```auto
  ## Service units
  template: systemd_service_unit_failed_state_nginx
        on: systemd.service_unit_state
     class: Errors
      type: Linux
 component: Systemd units
    module: !* *
    lookup: sum -5s unaligned of nginx.service
     units: state
     every: 10s
      warn: $this != nan AND $this == 1
      info: systemd service unit in the failed state
        to: sysadmin

```

I see no errors in the `error.log` when I do a `netdatacli reload-health`. The log only shows `COMMAND: Reloading HEALTH configuration`

The alert does not show in `http://localhost:19999/api/v1/alarms?all`

Please can you help me debug this. Are there any tools that can help me check if my alert is working?

Is `health-cmdapi-test.sh` something that I can use. The documentation is very sparse and the script crashes out for me with the error:

```auto
netdata@debian:/etc/netdata$ /usr/libexec/netdata/plugins.d/health-cmdapi-test.sh
Cmd 'cmd=RESET'
  Expecting 'All health checks and notifications are enabled' : Success
  Check: 'Default State' in 1 sec
  ERROR: Unexpected response stored in /tmp/resp-21810.json
/usr/libexec/netdata/plugins.d/health-cmdapi-test.sh: line 60: RESET-list.json: Permission denied
ERROR: the files RESET-list.json and expected_list/RESET-list.json does not match.

```

The user `netdata` has access to my API key.

---

<div class="post-metadata">

**Author:** ![avrapal](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.netdata.cloud/avrapal/32/3119_2.png) [@avrapal](https://community.netdata.cloud/u/avrapal)\
**Post date:** [August 30, 2023, 11:21am UTC](https://community.netdata.cloud/t/systemd-alert-for-nginx-service/4624/2 "2023-08-30T11:21:50Z")

</div>

I figured this out by using an `alarm` not `template.`

```auto
    alarm: systemd_service_unit_failed_state_nginx_status
        on: systemdunits_service-units.unit_nginx_service_state
     class: Errors
      type: Linux
 component: Nginx unit
    lookup: sum -5s unaligned of inactive,failed
     units: state
     every: 10s
      crit: $this > 0
      info: systemd service unit in the failed state
        to: sysadmin

```
