# Target with multiple ips and alert only if all fail testing

**URL:** <https://community.netbeez.net/t/target-with-multiple-ips-and-alert-only-if-all-fail-testing/120>\
**Category:** General\
**Created:** [October 13, 2023, 6:14am UTC](https://community.netbeez.net/t/target-with-multiple-ips-and-alert-only-if-all-fail-testing/120 "2023-10-13T06:14:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![999cgm](https://avatars.discourse-cdn.com/v4/letter/9/82dd89/32.png) [@999cgm](https://community.netbeez.net/u/999cgm)\
**Post date:** [October 13, 2023, 6:14am UTC](https://community.netbeez.net/t/target-with-multiple-ips-and-alert-only-if-all-fail-testing/120/1 "2023-10-13T06:14:03Z")

</div>

Hi,  
Please let me know how I can do this 🙂

---

<div class="post-metadata">

**Author:** ![panickos](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.netbeez.net/panickos/32/8_2.png) [@panickos](https://community.netbeez.net/u/panickos)\
**Post date:** [October 17, 2023, 10:02pm UTC](https://community.netbeez.net/t/target-with-multiple-ips-and-alert-only-if-all-fail-testing/120/2 "2023-10-17T22:02:32Z")

</div>

@999cgm, welcome to the community!

Here are three key concepts in NetBeez:

1. **Alerts:** Triggered when specific alert conditions are met. These conditions are assessed on a per-test basis.
2. **Incidents:** Triggered when alerting thresholds surpass a per-entity limit, such as Agent, Target, or Wifi network.
3. **Notifications:** Sent to configured channels (e.g., email, Slack, Splunk, MS Teams, Pagerduty) when an Alert or Incident is activated.

For Incidents, Agent and Wifi incidents are assessed on a per test-type basis (e.g., all ping tests are grouped). However, Target incidents are evaluated on a per-test-template basis (e.g., all ping tests to [google.co.uk](http://google.co.uk) are grouped separately from those to [google.com](http://google.com)).

From your query, it seems you want to tally tests of a target on a per test-type basis, as done for Agents and Wifi, and apply this only for specific targets, retaining the default functionality for others.

Currently, our frontend doesn’t offer this feature. However, I discovered it’s feasible via the backend. If you’re acquainted with our backend, follow these steps:

**Step 1:** Establish a new Target Incident Detector for per-test-type incident evaluation.

Enter the rails console:

```bash
# as root:
$ dxec docker-compose_nb-api_1 bundle exec rails c

```

then within the console:

```ruby
> incident_detector = IncidentDetector.create(name: "Target Incident Detector by TestType", threshold_mix: {merge: [{filter: [{filter: [{var:""},{'==':[{var:"test_type_id"}, 1]}]}, {'>=': [{var:"percentage_alerting"}, 0.8]}]}, {filter: [{filter: [{var:""},{'==':[{var:"test_type_id"}, 2]}]}, {'>=': [{var:"percentage_alerting"}, 0.8]}]}, {filter: [{filter: [{var:""},{'==':[{var:"test_type_id"}, 3]}]}, {'>=': [{var:"percentage_alerting"}, 0.8]}]}, {filter: [{filter: [{var:""},{'==':[{var:"test_type_id"}, 4]}]}, {'>=': [{var:"percentage_alerting"}, 0.8]}]}]}, group_by_clause: ["test_type_id"], incident_reporting_entity_type: "NbTarget")
> incident_detector.id
=> 4

```

This command provides the id for the incident detector, activating when 80% of similar tests signal an alert.

**Step 2:** Modify the Incident Detector for the desired target.

```ruby
> target = NbTarget.find_by_name("My target name")
> target.incident_detector_instances.last.update(incident_detector_id: 4)

```

**Step 3:** Reboot the message server service to apply the change.

```bash
$ nb-docker-compose up -d --force-recreate --no-deps nb-msgsrv nb-commsrv

```

If you need assistance, DM me or submit a support ticket. We’re here to help.

Regards,  
Panickos
