Skip to main content

Create and edit a Detection Rule

This page walks through the rule editor. You open it from Create rule to make a rule, or from Edit rule settings to change one.

Role needed: An Admin or Super Admin account opens the Detection Rules screen. Saving a rule also needs Settings access with Trigger Rules: Set, which Admin and Super Admin accounts have. See Detection Rules.

Creating a rule has four steps in a flyout titled Create new rule. Select Continue to confirm each step. A confirmed step collapses to a summary, and you can reopen it with Edit. Editing an existing rule, in a flyout titled Edit rule settings, shows the same sections as tabs: Definition, About, Schedule and Actions, plus Rule exceptions. Select Save changes when you are done.

The rule type is chosen in the first step and cannot be changed afterwards.

Create a rule​

  1. Select Settings, then Detection Rules in the Detections group.
  2. Select Create rule.
  3. Work through the four steps below.
  4. In the last step, select Create & enable rule, or Create rule without enabling it to switch it on later.

A message confirms Rule created or Rule created and enabled.

Step 1: Define rule​

Choose a Rule type card: Match, Query, Sequence or New terms. The Indicator type is not offered when you create a rule. See Rule types for what each detects.

What you fill in depends on the type.

Match. Under Rule Set, add the conditions an event must meet. Each condition has a field, a function and a value. Select Add to add it.

FunctionValue
IS, IS NOT, CONTAINS, STARTS WITH, GREATER THANA value typed in.
IN (comma-separated)A list of values separated by commas.
IN REFERENCE LISTA Reference List.
IN LOOKUP FILEA column of a lookup file.

An event raises an alert when it meets every condition. Switch Builder to Expression to write the conditions as one expression instead. It is a ThreatVIS PPL where condition and may use and, or, not, in, like, regexp, cidrmatch and in list(...) for a Reference List. The editor checks it as you type and shows where an error is. For example:

event.code in (1, 4688) and process.command_line like '%-EncodedCommand%'
and not user.name = 'svc_backup'

An expression that uses or or not groups cannot be shown in the builder, so you keep editing it as an expression.

Query. Write a PPL search in PPL query. Each row the search returns is an alert for one entity. Name the column that holds the entity in Entity column. To use a saved Filter Query, type $filter( and choose one from the suggestions. A threshold is a query that counts and then filters on the count:

$filter("Logon Failure")
| stats count() as failures, dc(user.name) as users by source.ip
| where failures >= 20 and users >= 3

Under the editor the page reads the query back to you, for example Threshold per source.ip, or tells you why it is not a threshold.

Sequence. Choose a kind:

  • Detections, then an event. Under Earlier steps, add up to 10 steps. Each step names the rules (or Reference Lists) that must have detected the entity, and the Event field that identifies it. Then say which event follows, under Then this event. Within is the span in seconds, up to 30 days. Leave it empty to use how long each step's rule keeps an entity detected.
  • Ordered events. Choose one to three Join on fields, a Within span in seconds (up to 30 days), and from 2 to 10 steps. Each step is an Expression or a Rule, and Runs says how many events in a row it needs (1 to 100). Switch on Until an event cancels it to drop partial sequences when a cancelling event arrives.

New terms. Write a PPL search that only selects events, using where, eval, rename or fields. Then choose one to three Fields, a History window (up to 365 days) and the Entity field, which must be one of those fields. The rule alerts once for each value, or combination of values, that the history window did not contain. The history window must reach further back than the rule's look-back.

Every type except Indicator also has Suppress alerts by. Choose up to three fields. Alerts with the same values are folded into one, and the alert shows how many it absorbed. Choose Per rule execution (scheduled rules only) or Per time period with a window. Then choose what happens to an event that lacks one of the fields: Suppress and group alerts for events with missing fields, or Do not suppress alerts for events with missing fields. Match and Sequence rules check each event as it arrives, so they suppress per time period only.

A Match or Sequence rule also needs an Entity field: the field whose value each alert, and its Case, is about.

Rule preview sits beside the form. For a Match rule it counts how many stored events in a timeframe you choose would raise an alert. For a scheduled rule, select Preview entities to run the search once and list the entities it would alert on. A condition that reads live detection state cannot be previewed on stored events, and the panel says so.

Step 2: About rule​

FieldNotes
Name and DescriptionBoth are required.
CategoryChoose one, or type a new name and select Add to create it.
Default severityLow, Medium, High or Critical.
Severity overrideSwitch on to give an alert a different severity when an event field holds a value you choose.
Default risk scoreA whole number from 0 to 100, which is how much each alert adds to its entity's risk score. Leave it empty to use the severity's default: 21, 47, 73 or 99.
Risk score overrideSwitch on to take the risk score from a numeric event field.
TagsOptional. Choose tags.

Under Advanced settings you can add Reference URLs (they must start with http:// or https://), False positive examples, MITRE ATT&CK threats (see MITRE ATT&CK mapping), an Investigation guide that appears on each Case the rule opens, a Setup guide, Author, License, and Shared exception lists. Scheduled rules also have Max alerts per run (1 to 10,000, default 1,000) and Timestamp override, the field the search uses as the event time instead of when the event was indexed.

Building block is also here. Tick Mark all generated alerts as building block alerts to make the rule a building-block rule.

Step 3: Schedule rule​

A Match, Sequence or Indicator rule shows that it evaluates every event as it arrives and has no schedule. A Query or New terms rule has three settings:

SettingMeaningNew rule
Runs everyHow often the search runs, in seconds, minutes or hours. At least 5 seconds.5 minutes
Additional look-back timeExtra time added to the search window, so that late events are not missed.1 minute
Indexing graceSeconds each search waits for late events before it reads them.15 seconds

Step 4: Rule actions​

Open Case​

Each alert of the rule opens a Case, or joins the open Case for the same entity. This panel decides how long a Case keeps collecting alerts. It is not shown for a building-block rule, which opens no Case.

ControlEffect
Group by alert fieldThe rule's entity field. Alerts with the same value go to the same Case. It is read-only here and set in Define rule. With no entity field there is one Case for the rule.
Time windowHow long a Case collects alerts, counted from when it was opened. After that the next alert opens a new Case. From 5 minutes to 365 days, in minutes, hours or days. A new rule starts with 7 days.
No time limit: one case for as long as it is openThe Case collects alerts until it is closed.
Reopen when the case is closedOff by default. When on, a new alert inside the time window reopens the closed Case instead of opening another.

See How Cases are raised and extended for what analysts see.

Actions on the alert​

Add actions here when you create the rule. To add, change or remove a rule's actions afterwards, edit the Action Rule named after it on the Actions tab. A rule that is a building block shows A building block raises no alerts in Cases, so it runs no actions. See Action Rules.

When you edit a rule, this tab also holds Mute and the Enabled switch.

Check that the rule raises a Case​

  1. If you chose Create rule without enabling it, switch the rule on in the Enabled column of Installed rules when it is ready.
  2. Produce an event the rule should match, for example by repeating the activity it looks for on a test account or host, or wait for one. Before you rely on a Match rule, Rule preview in the editor shows how many stored events it would have alerted on. For a Query or New terms rule, you can instead run it over a past period that holds matching events with Manual run; see Monitor rules.
  3. On Installed rules, check that Last run has a time and Last response is Succeeded. A scheduled rule first runs at its next Runs every interval.
  4. Select the rule's name, then the Alerts tab. The alert the event raised is listed.
  5. Select Case Management in the navigation menu. A Case for the rule and the alert's entity is listed, or the alert has joined the Case already open for that entity. See How Cases are raised and extended.

If no alert or Case appears, see A Case was not raised.

Edit a rule​

  1. On Installed rules, select Edit rule settings in the row, or open the rule and select Edit rule settings.
  2. Change the tabs you need.
  3. Select Save changes. A message confirms Detection rule saved.

If you close the flyout with unsaved changes, the console asks you to confirm.

Editing a built-in rule is allowed. The rule then shows a Modified badge in the list, and the tooltip says This built-in rule has been changed since it was installed.

Problems saving​

The console blocks a save, and names the first problem, when a required part is missing. The common ones:

MessageFix
Name is required, Description is requiredFill in the About step.
Add at least one conditionAdd a condition to the Rule Set, or write an expression.
Choose the entity field the alert is aboutChoose the Entity field of a Match or Sequence rule.
Name the column of the query's results that holds the entityFill in Entity column for a Query rule.
The rule must run every 5 seconds or moreRaise Runs every.
The time window must be between 5 minutes and 365 daysCorrect the Open Case window.
Risk score must be a whole number from 0 to 100, or emptyCorrect Default risk score.

Next steps​