> For the complete documentation index, see [llms.txt](https://docs.nexthink.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nexthink.com/~/changes/Sh4xqs4GDClkDKT9Hvux/user-guide/alerts-and-diagnostics/managing-alerts/creating-custom-monitors.md). Agents can also search and read this documentation through its [MCP server](https://docs.nexthink.com/~gitbook/mcp).

# Creating custom monitors

Click on the **New monitor** button in the top-right corner of the page to create a new monitor from scratch.

## Defining general information <a href="#creatingcustommonitors-defininggeneralinformation" id="creatingcustommonitors-defininggeneralinformation"></a>

Use the **General** tab to define the new monitor.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-6724b9f9777886c682183986636b88a1ea948e95%2Fimage-20231011-103235.png?alt=media" alt="" width="760"><figcaption></figcaption></figure>

### Type <a href="#creatingcustommonitors-type" id="creatingcustommonitors-type"></a>

Custom monitors offer one detection mode. The **Metric threshold** type compares the value of the NQL query-defined metric to a threshold defined by the user. For example, a monitor triggers an alert when 20% of devices running a binary experienced a crash.

### Name <a href="#creatingcustommonitors-name" id="creatingcustommonitors-name"></a>

Provide a meaningful name for the monitor. The system uses this name to send notifications and visualize monitors on the Alerts overview page.

### NQL ID <a href="#creatingcustommonitors-nqlid" id="creatingcustommonitors-nqlid"></a>

The system generates a unique identifier automatically from the monitor’s name. You can only modify the NQL ID during the monitor creation process using the following characters `a-z, 0-9, _`. You cannot edit this field once you have created the monitor. Use the NQL ID to query this monitor using NQL.

You cannot create a monitor with an NQL ID that was used by a deleted monitor until there are no events in the system still associated with the deleted monitor (30 days max).

### Priority <a href="#creatingcustommonitors-priority" id="creatingcustommonitors-priority"></a>

Set the priority level. The default level is medium.

### Tags <a href="#creatingcustommonitors-tags" id="creatingcustommonitors-tags"></a>

Create custom tags for monitors. This allows you to filter alerts using tags in the Overview dashboard and in the Webhooks integration. Currently, there is a maximum of ten tags per monitor.

## Defining an NQL query <a href="#creatingcustommonitors-definingannqlquery" id="creatingcustommonitors-definingannqlquery"></a>

Use an NQL query to define metrics to monitor. NQL facilitates the selection of one or multiple metrics, helps specify the scope with the `where` clause and defines the right granularity for the alert context using time aggregation and the `by` keyword for grouping. Use the **Show in Investigations** button to view the results of your NQL query in the Investigations module.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-5db04901985b95fc6f298529b88a50592c3d7c38%2Fimage-20231010-123354.png?alt=media" alt=""><figcaption></figcaption></figure>

The NQL query must follow several rules to support monitors:

1. The NQL query for monitors must include a computed or aggregated metric, which means every query requires a `compute` or `summarize` clause to be compatible with a monitor.

```
devices
| with device_performance.system_crashes during past 7d 
| compute 
  total_number_of_system_crashes = number_of_system_crashes.sum()
```

```
execution.crashes during past 24h
| summarize total_number_of_crashes = count()
```

2. Optionally, include more than one computed or aggregated metric in your query to set multiple conditions for the alert to be triggered.

```
execution.crashes during past 24h
| summarize 
  total_number_of_crashes = count(), 
  devices_with_crashes = device.count()
```

3. Use at least one metric to set a threshold for monitoring conditions. Create an additional metric if your original query does not include one.

Not compatible with monitors:

```
devices
| with antiviruses
| where is_up_to_date == no
```

Compatible with monitors:

```
devices
| with antiviruses
| where is_up_to_date == no
| compute device_count = count()
```

4. Do not add conditions to evaluated metrics at the NQL level. Instead, use the [Trigger condition](#creatingcustommonitors-triggercondition) section to define the condition.

Incorrect monitor NQL query:

```
execution.crashes during past 24h
| summarize total_number_of_crashes = count()
| where total_number_of_crashes >= 10
```

Correct monitor NQL query with conditions:

```
execution.crashes during past 24h
| summarize total_number_of_crashes = count()
```

5. Use the `where` clause to narrow the scope of your monitor to specific locations, applications and other categories.

```
execution.crashes during past 24h
| where binary.name == "excel.exe"
| summarize total_number_of_crashes = count()
```

6. Use `summarize... by` to define the right granularity for the alert context. In the following example, a single alert will be triggered per binary name.

```
execution.crashes during past 24h
| summarize total_number_of_crashes = count() by binary.name
```

Refer to the [Detecting issues impacting multiple devices](https://docs.nexthink.com/~/changes/Sh4xqs4GDClkDKT9Hvux/user-guide/alerts-and-diagnostics/managing-alerts/creating-custom-monitors/detecting-issues-impacting-multiple-devices.md) and [Detecting issues impacting a single device or user](https://docs.nexthink.com/~/changes/Sh4xqs4GDClkDKT9Hvux/user-guide/alerts-and-diagnostics/managing-alerts/creating-custom-monitors/detecting-issues-impacting-a-single-device-or-user.md) documentation to learn more about defining the NQL query.

## Defining Trigger conditions <a href="#creatingcustommonitors-definingtriggerconditionstriggercondition" id="creatingcustommonitors-definingtriggerconditionstriggercondition"></a>

Define the condition that triggers an alert. Use each metric computed in the NQL query to narrow down the condition.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-a6d71559b86be76093eeba4d41d26ef9ce372cbb%2Falert-1678876392.png?alt=media" alt="Trigger conditions"><figcaption></figcaption></figure>

## Defining Scheduling frequency <a href="#creatingcustommonitors-definingschedulingfrequencyschdulingfrequency" id="creatingcustommonitors-definingschedulingfrequencyschdulingfrequency"></a>

The scheduling frequency determines how often the system evaluates the trigger condition. The possible timeframes are 15 min, 1 hour, 3 hours, 6 hours, 12 hours, 24 hours, 48 hours and 7 days. However, the availability of these timeframes depends of the `during past` clause and the events queried with the monitor's NQL query.

See the following examples to understand how setting monitor query determines the available scheduling frequency:

<table><thead><tr><th width="428">Monitored events with during past</th><th>Minimum frequency</th><th>Maximum frequency</th></tr></thead><tbody><tr><td><pre class="language-nql_/apigateway/nql-editor"><code class="lang-nql_/apigateway/nql-editor">device_performance.boots during past 24h
</code></pre></td><td>15 min</td><td>7 days</td></tr><tr><td><pre class="language-nql_/apigateway/nql-editor"><code class="lang-nql_/apigateway/nql-editor">device_performance.boots during past 7d
</code></pre></td><td>24 h</td><td>7 days</td></tr><tr><td><pre class="language-nql_/apigateway/nql-editor"><code class="lang-nql_/apigateway/nql-editor">session.events during past 1h
</code></pre></td><td>15 min</td><td>7 days</td></tr><tr><td><pre class="language-nql_/apigateway/nql-editor"><code class="lang-nql_/apigateway/nql-editor">session.events during past 24h
</code></pre></td><td>12h</td><td>7 days</td></tr><tr><td><pre class="language-nql_/apigateway/nql-editor"><code class="lang-nql_/apigateway/nql-editor">execution.events during past 1h
</code></pre></td><td>15 min</td><td>7 days</td></tr><tr><td><pre class="language-nql_/apigateway/nql-editor"><code class="lang-nql_/apigateway/nql-editor">execution.events during past 24h
</code></pre></td><td>12h</td><td>7 days</td></tr><tr><td><pre class="language-nql_/apigateway/nql-editor"><code class="lang-nql_/apigateway/nql-editor">execution.events during past 7d
</code></pre></td><td>7 days</td><td>7 days</td></tr></tbody></table>

## Importing a custom monitor <a href="#creatingcustommonitors-importingacustommonitor" id="creatingcustommonitors-importingacustommonitor"></a>

One way to create monitors is by importing them from a previously exported configuration file.

The system does not allow the import of a monitor with the same NQL ID as a deleted monitor if there are events in the system still associated with that deleted monitor. Alert events are kept in the platform for 30 days maximum.

If the *NQL ID is already used in deleted monitor with existing alerts* message appears during the import of the monitor, please modify the export file to create a new NQL ID.

***

RELATED TOPICS

* [Detecting issues impacting multiple devices](https://docs.nexthink.com/~/changes/Sh4xqs4GDClkDKT9Hvux/user-guide/alerts-and-diagnostics/managing-alerts/creating-custom-monitors/detecting-issues-impacting-multiple-devices.md)
* [Detecting issues impacting a single device or user](https://docs.nexthink.com/~/changes/Sh4xqs4GDClkDKT9Hvux/user-guide/alerts-and-diagnostics/managing-alerts/creating-custom-monitors/detecting-issues-impacting-a-single-device-or-user.md)
* [Nexthink Library](https://docs.nexthink.com/~/changes/Sh4xqs4GDClkDKT9Hvux/user-guide/nexthink-library.md)
* [Product configuration](https://docs.nexthink.com/~/changes/Sh4xqs4GDClkDKT9Hvux/user-guide/administration/system-configuration/product-configuration.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.nexthink.com/~/changes/Sh4xqs4GDClkDKT9Hvux/user-guide/alerts-and-diagnostics/managing-alerts/creating-custom-monitors.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
