Create a spike rule
How to create a spike rule by choosing what to watch and how sensitive it is, with a preview of what it would have alerted on last week.
A spike rule defines which traffic to watch, how much deviation is abnormal and who receives the alert. On the create screen, you choose what to watch and a sensitivity level, and check in the preview how many alerts the rule would have fired last week. Creating, editing and duplicating rules requires the spikes.rules.write permission, included in the Tenant Admin role.
Before you start
- Connect your Cloudflare account. Refer to Connect Cloudflare.
- To receive alerts, set up your notification locations before you create the rule.
Create the rule
- Go to Detecção de Picos (Spike Detection) > Regras (Rules).
- Select Nova regra (New rule). The Nova regra de pico (New spike rule) page opens.
- In O que você quer vigiar? (What do you want to watch?), enter the name, choose the goal and select the zones.
- In Quão sensível? (How sensitive?), choose a level and check the preview.
- (Optional) Open Ajustes finos (Fine tuning), right below the preview chart, to change values, times and the evaluation schedule. You can also drag the chart's lines. Refer to Adjust by dragging on the chart.
- In Então avise… (Then alert…), choose who receives the alert.
- In Status, confirm whether the rule starts active and in observation mode.
- Select Criar regra (Create rule).
Advisor shows the message Regra criada… Ela dispara depois que o baseline aquecer. (Rule created… It fires once the baseline warms up.) On creation, Advisor pulls the last 7 days from Cloudflare so the rule starts with a baseline.
O que você quer vigiar? (What do you want to watch?)
| Field | Use |
|---|---|
| Nome da regra (Rule name) | Up to 120 characters. Shown in the list and in the alert (email and Slack). |
| Goal | Single-choice card: Erros no site (Site errors), Site fora do ar (Site down) or IP abusivo (Abusive IP). Replaces the former Tipo (Type) selector. |
| Zonas (Zones) | Multi-select. Choosing N zones creates N rules, shown as one row in the list. |
The goals:
| Goal | What it watches | Equivalent type |
|---|---|---|
| Erros no site | 5xx responses above normal. | Pico de status (Status spike) |
| Site fora do ar | 2xx/3xx responses below normal. | Queda de status (Status drop) |
| IP abusivo | One IP making too many requests. Opens one incident per IP. | Pico por IP (Spike by IP) |
When you change the goal, the sensitivity returns to the Equilibrada (Balanced) level of the new goal, because the percentage for a spike does not fit a drop.
Recorte avançado: status, filtro e agrupamento (Advanced scope: status, filter and grouping)
The collapsible Recorte avançado: status, filtro e agrupamento block narrows the traffic the rule watches. Left unchanged, the rule watches the whole zone.
Status inicial (Start status) and Status final (End status) appear for Erros no site and Site fora do ar. An empty field uses the default: 500 to 599 for Erros no site and 200 to 399 for Site fora do ar.
To filter the traffic:
- Select Adicionar condição (Add condition).
- Choose the field, the operator and the value.
- Repeat for more conditions and choose E (AND) or OU (OR). The combiner applies to the whole expression.
- Check the expression in the filter's own Prévia (Preview) box.
Available fields: Host, Caminho (path) (Path), Status da resposta (Response status), IP do cliente (Client IP), País (Country), ASN, Método HTTP (HTTP method), User agent, Ação de segurança (Security action) and ID da Regra (Rule ID: the ID of the Cloudflare security rule that acted on the request).
| Field type | Operators |
|---|---|
| Text | é igual a (equals), é diferente de (does not equal), contém (contains), não contém (does not contain), começa com (starts with), está na lista (is in list), não está na lista (is not in list) |
| Numeric | é igual a, é diferente de, maior ou igual a (greater than or equal to), menor ou igual a (less than or equal to), entre (between), está na lista, não está na lista |
Agrupar por (Group by) sets the incident's subject: one incident per value of the field, for example one per IP. The default is Zona inteira (um alvo) (Whole zone, one target). Any field from the list above can be used, except User agent.
Quão sensível? (How sensitive?)
Each level adjusts the deviation, the time and the minimum volume of the rule at once. There are five levels, from the one that alerts least to the one that alerts most:
- Muito conservadora (Very conservative)
- Conservadora (Conservative)
- Equilibrada (Balanced, the default)
- Sensível (Sensitive)
- Muito sensível (Very sensitive)
Above each level, a bar shows how many alerts it would have fired on the zone last week. Select a bar, or use the Sensibilidade (Sensitivity) control, to choose the level. Before the preview loads, the bars show a dash (–). When a more sensitive level alerts less than the previous one, the button's tooltip explains it: with the lower threshold, the incident takes longer to close and nearby spikes become a single alert.
Below the bars, a sentence describes the rule in plain language, with values such as the percentage, the time and the minimum volume. The sentence updates with every change. When you change a value in Ajustes finos, or drag a line on the preview chart, and it no longer matches a level, the sentence ends with (ajustado à mão) (hand-tuned) and no bar is highlighted.
The preview
The Se esta regra existisse na última semana (If this rule had existed last week) preview draws the zone's chart with the alerts the rule would have fired. Advisor fetches the data directly from Cloudflare, for any zone on the connection, without waiting for the rule's collection. The preview also works for rules with a custom filter and with a grouping of their own, and it updates when you change the level or the fine tuning.
The numbers are estimated from Cloudflare's sampling, like the rule's own. The chart shows the last week, and Advisor fetches more days to form the comparison, up to Cloudflare's 30-day limit: 7 evaluated days plus the days of Comparar com os últimos (Compare with the last). With 28 days of comparison, the start of the week uses fewer days, and the preview warns A comparação usa N dias no início — limite de 30 dias da Cloudflare (The comparison uses N days at the start — Cloudflare's 30-day limit).
| Selector | When it appears |
|---|---|
| Zona da prévia (Preview zone) | The rule has more than one zone. |
| IP da prévia (Preview IP) | The goal is IP abusivo, or the rule groups by IP. The first option is Todos os IPs (visão geral) (All IPs, overview); the others are the IPs with the highest peak. |
| Caminho da prévia (Preview path), for example | The rule groups by another field. The selector carries the field name, and the first option is, for example, Todos os caminhos (visão geral) (All paths, overview). |
Single-subject chart
For rules with no grouping, or with an IP (or another value) chosen in the selector, the preview shows that subject's series, with the time-of-day median, the threshold and the alerts.
The legend explains the chart: Requisições na janela (Requests in the window), Limiar do alerta (mediana do horário + %) (Alert threshold: time-of-day median + %, with a minus sign for Site fora do ar), Mediana do horário (normal) (Time-of-day median, normal), Piso de volume (Volume floor), Janela anômala (Anomalous window), Aviso (a regra disparou) (Alert: the rule fired) and Do início do desvio até a recuperação (From the start of the deviation to recovery). With Eu fecho (I close it) under Quem fecha o incidente (Who closes the incident), the legend includes Incidente aberto até alguém fechar (Incident open until someone closes it), drawn as a thin strip at the top of the chart.
When the zone's baseline is still warming up, the preview warns that the most recent windows do not have enough history to be evaluated and that the rule would not have fired on them.
IP overview
For grouped rules, the preview opens on Todos os IPs (visão geral). Instead of one line per IP, which would be unreadable with thousands of IPs, the chart groups IPs into categories by each IP's normal volume and draws one line per category:
| Category | IP's normal volume (requests per 5 min) |
|---|---|
| até 100 req. (up to 100) | Under 100. A new IP with no history falls here. |
| 100–200 req. | 100 to 199. |
| 200–500 req. | 200 to 499. |
| 500–1 mil req. (500 to 1 thousand) | 500 to 999. |
| 1 mil–5 mil req. (1 to 5 thousand) | 1,000 to 4,999. |
| 5 mil+ req. (5 thousand+) | 5,000 or more. |
Categories with no IP do not appear. Grouping by normal volume, not by the window's volume, keeps a small IP that fires from disappearing behind the large ones.
How to read the chart:
- Solid line: the highest value among the category's IPs in each 5-minute window.
- Dashed line in the same color: the category's threshold (% above normal; for Site fora do ar, below).
- Gray dotted line: the volume floor, labeled piso N (floor N).
- Red dots: alerts, when an IP in the category fired.
The legend under the chart names these elements: volume da categoria (maior IP) (category volume, largest IP), limiar da categoria (% acima do normal) (category threshold, % above normal; or abaixo, below), piso de volume (volume floor) and aviso (um IP da categoria disparou) (alert: an IP in the category fired).
Above the chart, each category is a legend button with its number of IPs (N IPs) and alerts (N avisos). Select a category to hide or show it. The Escala (Scale) control switches between Logarítmica (Logarithmic, the default) and Linear: the logarithmic scale keeps categories of very different volumes visible in the same chart. On hover, the tooltip shows, for each category, the window's value and the threshold (/ limiar N, threshold N), and lists under Aviso: (Alert) the IPs that fired. The alert count is per window, as in the rule's aggregated alert.
Ver como tabela (View as table) opens the same data with the columns Categoria (Category), IPs, Máximo da semana (Maximum of the week) and Avisos (Alerts).
Below the chart and Ajustes finos, the IPs que teriam disparado (IPs that would have fired) ranking lists each IP with Categoria, Avisos and Pico (req./5 min) (Peak, requests per 5 min). Select an IP to open its individual chart; to go back, choose Todos os IPs (visão geral) in the selector. When no IP would have fired, the ranking says Nenhum IP teria disparado com estes ajustes. (No IP would have fired with these settings.) For other groupings, the names follow the field, for example Todos os caminhos (visão geral) and Caminhos que teriam disparado (Paths that would have fired).
Adjust by dragging on the chart
On both charts, the single-subject one and the IP overview, the rule's lines can be dragged. The screen shows the hint Arraste a linha tracejada ou a do piso para ajustar. (Drag the dashed line or the floor line to adjust.)
- The dashed threshold line changes the % acima do normal field (% abaixo do normal for Site fora do ar).
- The floor line changes the Piso de volume field.
Each line has a marker at the right edge with its current value, for example piso 120 (floor 120), +150% or −45%. The marker is also the line's handle. While you drag, the chart, the alerts, the sensitivity bars, the sentence and the Ajustes finos controls update immediately, and the sentence gains (ajustado à mão). The value follows the same steps and limits as the Ajustes finos controls.
The markers are keyboard-focusable, named Piso de volume no gráfico (Volume floor on the chart) and % acima do normal no gráfico (% above normal on the chart; % abaixo do normal no gráfico for Site fora do ar):
| Key | Effect |
|---|---|
| ↑ / ↓ | One step: 10 at a time for the floor, 5 at a time for the percentage. |
| PageUp / PageDown | Ten steps. |
| Home / End | The lowest and highest allowed value. |
Preview notices and states
When the direct query to Cloudflare is not possible, Advisor falls back to the history it has already collected for the zone. In that case, the preview and the IP overview keep working, and a single notice appears above the chart, with Tentar de novo (Try again) and the reason:
| Reason shown in the Prévia com o histórico já coletado (Preview with the history already collected) notice | Meaning |
|---|---|
| A consulta direta à Cloudflare demorou demais nesta zona. (The direct query to Cloudflare took too long on this zone.) | Zones with a lot of traffic can take longer. |
| A Cloudflare limitou as consultas agora. (Cloudflare limited queries just now.) | Preview queries share Cloudflare's limit with collection. |
| O limite de consultas da prévia nesta conexão foi atingido; renova em alguns minutos. (The preview query limit on this connection was reached; it renews in a few minutes.) | The connection used up its preview query budget. |
The collected history can be shorter than the full one. In the overview, the fallback shows the note Mostrando os 50 IPs de maior pico. (Showing the 50 IPs with the highest peak.) under the ranking when there are more IPs than shown.
Other notices that appear above the chart without blocking the preview:
| Notice | Meaning |
|---|---|
| A comparação usa N dias no início — limite de 30 dias da Cloudflare | Comparar com os últimos asks for more days than Cloudflare keeps for the query. The start of the week uses fewer comparison days. The rule you create uses the full baseline as collection builds up history. |
| A consulta atingiu o limite de requisições (The query reached the request limit) | Cloudflare did not return every IP. Only those with at least the volume stated in the notice appear; the smaller ones were left out. Appears only on the direct query. |
States that take the chart's place, when not even the fallback has data:
| State | Cause | How to fix |
|---|---|---|
| A Cloudflare limitou as consultas agora; tente em N s (Cloudflare limited queries just now; try in N s), or tente de novo em instantes (try again shortly) | Preview queries share Cloudflare's limit with collection. | Select Tentar de novo after the stated time. Nothing was lost. |
| O limite de consultas da prévia nesta conexão foi atingido; renova em alguns minutos (The preview query limit on this connection was reached; it renews in a few minutes) | The connection used up its preview query budget. | Wait a few minutes and select Tentar de novo. |
| A consulta à Cloudflare demorou demais nesta zona (The query to Cloudflare took too long on this zone) | The query timed out, and the collected history had no data. | Try again shortly; zones with a lot of traffic can take longer. Select Tentar de novo. |
| Não foi possível montar a visão geral agora (The overview could not be built right now) | The response came without the set of IPs. | Select Tentar de novo or choose an IP in the selector to see its individual chart. |
| Não foi possível ler esta zona com a conexão atual (This zone could not be read with the current connection) | The connection has no access to the zone, or its traffic analytics is disabled in Cloudflare. | Check the connection's access and the traffic analytics in Cloudflare. You can save the rule anyway. |
| Prévia pausada (Preview paused) | A value is out of range, for example Comparar com os últimos outside 3 to 30 days, or the percentage is empty. | Correct the value named in the message. |
| Não foi possível carregar a prévia (The preview could not be loaded) | Failure while fetching the data. | Select Tentar de novo. |
| Escolha uma zona (Choose a zone) | No zone selected. | Select at least one zone in O que você quer vigiar?. |
| Prévia indisponível para filtro customizado (Preview unavailable for a custom filter) | Rare case: Cloudflare limited the queries and the history already collected does not cover the scope (filter or grouping of its own). | Try again shortly. You can save the rule and follow the chart on its detail page. |
| Zona ainda sem histórico coletado (Zone with no collected history yet) | Fallback state, rare: collection has not closed the zone's first windows yet. | Save the rule: it starts warming up the baseline. |
Ajustes finos (Fine tuning)
The collapsible Ajustes finos block sits right below the preview chart, before IPs que teriam disparado. It shows the values behind the chosen level, in practical units (minutes, requests). % acima do normal and Piso de volume can also be set by dragging the chart's lines, and the two fields follow the drag. Each time option has shortcuts and an Outro valor (Other value) field for an exact value within Advisor's limits.
| Field | Default in a new rule | Use |
|---|---|---|
| % acima do normal (% above normal; % abaixo do normal (% below normal) for Site fora do ar) | From the Equilibrada level | Deviation from the time-of-day median over the past days. Required. |
| Piso de volume (Volume floor) | From the Equilibrada level | Minimum volume per 5-minute window to evaluate. For drops, it applies to the baseline median. |
| Durante pelo menos (For at least) | 5 min (1 window) | How long in a row the deviation must last for the rule to alert. Shortcuts: 5, 10, 15, 20 and 30 min. |
| Depois de avisar, silêncio de (After alerting, stay silent for) | 30 min (6 windows) | Interval during which the same subject does not alert again. Shortcuts: 5 min, 15 min, 30 min, 1 h and 2 h. |
| Quem fecha o incidente (Who closes the incident) | Eu fecho | Eu fecho (I close it) or Fecha sozinho (It closes itself). |
| Fechar quando o tráfego ficar normal por (Close when traffic stays normal for) | 15 min (3 windows) | Appears with Fecha sozinho. Consecutive windows within normal before the incident closes. Shortcuts: 5, 15 and 30 min. |
| Liberar um novo aviso depois de tráfego normal por (Allow a new alert after traffic stays normal for) | 15 min (3 windows) | Appears with Eu fecho. Does not close the incident; it only lets the rule alert again. |
| Comparar com os últimos (Compare with the last) | 7 days | Days of history that form the normal for each time of day. Shortcuts: 3, 7, 14 and 28 days. |
| Avaliar (Evaluate) | Sempre (Always) | Time range when the rule evaluates. Options: Sempre, 08h às 20h (8 am to 8 pm), 22h às 06h (10 pm to 6 am) and Personalizado (Custom). Outside the range, evaluation pauses. |
With Personalizado, the Ativa a partir de (Active from) and Ativa até (Active until) fields set the time range. With Eu fecho, the screen warns that the incident stays open until someone resolves it on the incidents screen, even after traffic returns to normal, and that no resolution alert is sent either. If the spike returns while the incident is open, the new alert joins the same incident.
Under Outro valor, the fields use 5-minute windows (Persistência (janelas) (Persistence, windows), Cooldown (janelas) and Recuperação (janelas) (Recovery, windows)) and days (Baseline (dias) (Baseline days)). The accepted ranges:
| Field | Range |
|---|---|
| Baseline (dias) | 3 to 30 |
| Persistência (janelas) | 1 to 288 |
| Cooldown (janelas) | 0 to 2016 |
| Recuperação (janelas) | 1 to 288 |
A value outside the range is not saved. The form names the field and the accepted range, for example Baseline: informe um número inteiro de 3 a 30 dias. (Baseline: enter a whole number from 3 to 30 days.) In an Outro valor field left empty, the rule uses the service default (2 persistence windows, 6 cooldown windows, 3 recovery windows and 7 baseline days).
Equilibrada level defaults
A new rule starts at the Equilibrada level of the chosen goal:
| Goal | Deviation | Durante pelo menos | Volume floor | Silence |
|---|---|---|---|---|
| Erros no site | 150% above normal | 5 min | 120 requests | 30 min |
| Site fora do ar | 45% below normal | 5 min | 700 requests | 30 min |
| IP abusivo | 500% above normal | 5 min | 150 requests | 30 min |
The other levels change the deviation, the time, the floor and the silence together. The conservative levels require larger deviations, for longer, with a longer silence; the sensitive levels do the opposite.
Então avise… (Then alert…)
| Field | Use |
|---|---|
| Locais de notificação (Notification locations) | Checklist of email lists and Slack channels. Gerenciar locais (Manage locations) opens the setup and Recarregar lista (Reload list) refreshes the options. |
| E-mails avulsos (Individual emails) | Addresses outside the locations. Use Adicionar destinatário (Add recipient), or Receber eu também (Send to me too) to include yourself. If your address is already included, the form shows Você já recebe (You already receive it). |
| Quando notificar (When to notify) | Sempre que disparar (Every time it triggers, the default) or Só quando a IA confirmar ataque e o incidente for escalado (Only when the AI confirms an attack and the incident is escalated). |
With Só quando a IA confirmar ataque e o incidente for escalado, the trigger alert (email, Slack and in-app notification) is held until the incident is escalated, by automatic triage or by hand. Triggers judged Benigno (Benign) or Inconclusivo (Inconclusive) alert nobody, and resolving an incident that never alerted sends no alert either. On escalation, the Advisor bell shows a single notification, Incidente escalado (Incident escalated); email and Slack receive the spike alert.
When several targets of the same rule leave the normal pattern in the same window, for example several IPs, Advisor sends a single aggregated alert on each channel (email, Slack and the bell). The alert shows the number of targets, the ones with the highest volume and e mais N (and N more) for the rest. The resolution of several targets in the same window also arrives as a single alert.
The choice of who closes the incident is in Ajustes finos, in the Quem fecha o incidente field. The Resolver o incidente automaticamente quando o tráfego normalizar (usa a janela de recuperação acima) (Resolve the incident automatically when traffic returns to normal, using the recovery window above) checkbox no longer exists; the Fecha sozinho option replaces it.
Status
| Option | Use |
|---|---|
| Regra ativa (Rule active) | Ativa (Active) or Pausada (Paused). A rule created as Pausada is saved paused. |
| Começar em modo observação (Start in observation mode) | On by default in a new rule. Evaluates and records incidents, but sends no alerts (no email, no Slack). When editing, the label is Modo observação (Observation mode). |
Edit a rule
In the rule list, select Editar (Edit). The Editar regra de pico (Edit spike rule) page opens with the same fields, filled in with the rule's values. Select Salvar (Save) to store the changes.
Duplicate a rule
In the rule list, select Duplicar (Duplicate). The Duplicar regra de pico (Duplicate spike rule) page opens with the fields filled in. Adjust the fields as needed and select Criar cópia (Create copy). The copy always starts in observation mode.