risk
Score each row for risk-based alerting: a 0-100 score, the entity it belongs to, and the reason.
Use risk to attach a score, entity, and reason to each result row. In a detection rule, those scores contribute to risk-based alerting so multiple weak signals for one entity can raise an alert.
Syntax
... | risk score=<0-100 | expression> [entity=<field> | field=<field>] [factor=<text | expression> | type=<text>] [weight=<0.0-1.0>]Parameters may come in any order.
| Parameter | Description |
|---|---|
score | Required. A literal from 0 to 100, or an eval expression such as if(http_response.code>=400, 60, 10) or traffic.bytes_out/1000000. Expression results are rounded to an integer and clamped to 0–100. |
entity (alias field) | The field holding the entity that carries the risk. Without it, the entity is unknown, or the entity of an earlier risk stage. |
factor (alias type) | A label for why the row is risky. A quoted string, or an expression. Defaults to risk_assigned. |
weight | Overrides the global risk weight for this rule, 0.0 to 1.0. See Risk scoring settings. |
Output
| Column | Meaning |
|---|---|
risk_score | The row's score, 0–100 |
risk_entity | Value of the entity field (unknown if empty). Later commands can use risk_entity. |
risk_factors | Array of factor labels |
raw_risk_score | The same score before weighting; detections score findings from it |
risk_weight | The weight you set, if any |
Several risk stages in one pipeline accumulate: each adds its score to risk_score (still clamped to 100) and appends its factor to risk_factors. A stage without entity= keeps the previous stage's entity.
Examples
Score failed logons against the source IP:
class_uid=3002 status_id=2 | risk score=10 entity=src_endpoint.ip factor="failed logon"Scale the score with the number of failures per user:
class_uid=3002 status_id=2 | stats count as failures by user.name | where failures > 5 | risk score=failures*5 entity=user.name factor="repeated logon failures"Score HTTP errors higher than successes:
class_uid=4002 | risk score=if(http_response.code>=400, 60, 10) field=src_endpoint.ip type="http_error"Stack two signals on the same host:
class_uid=1007 process.name="powershell.exe" | risk score=20 entity=device.hostname factor="powershell" | where process.cmd_line LIKE "%-enc%" | risk score=40 factor="encoded command"Down-weight a noisy rule:
class_uid=1001 | risk score=30 entity=actor.user.name factor="file write" weight=0.5Notes
riskcompiles into the ClickHouse query, and it is also one of the commands that still work after alookup,prevalence,inputlookup,resolve_identity,aiorlateralstage, so "enrich, then score" pipelines work (example below).- In a search,
riskonly annotates the rows. Scores are recorded against entities when a detection rule that usesriskruns in alerting mode, and the Risk page applies your decay settings to them. See Risk-Based Alerting. metadata.log_source=riskin a search is shorthand for detection findings that carry a risk score (metadata.log_source="findings" AND risk_score>0).
Enrich, then score:
class_uid=1007 | prevalence hash_prevalence <= 3 | risk score=50 entity=device.hostname factor="rare process hash"What's next
- prevalence: score rare artifacts
- eval: build score inputs
- stats: aggregate before scoring