Security Detection Rule Management
ElasticOfficialCreated by elastic
- Skill
- Tool integration
- Security
- Apache-2.0
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured approach to managing Elastic Security detection rules, including SIEM and Endpoint behavior rules. It enables users to identify noisy rules, investigate false positives, and apply tuning strategies such as adding exceptions, patching queries, or adjusting thresholds. The skill utilizes the Kibana Detection Engine API to perform operations, ensuring consistent rule management and coverage maintenance.
What it does
- Finds and lists existing detection rules using KQL filters.
- Analyzes noisy rules to identify false positive patterns.
- Creates new detection rules with custom queries and MITRE ATT&CK mappings.
- Patches existing rules to update queries, severity, or risk scores.
- Adds scoped exceptions to SIEM and Endpoint behavior rules.
- Validates query syntax locally before applying changes to the cluster.
When to use it
- When you need to reduce alert fatigue by tuning noisy detection rules.
- When you need to create new detection rules for emerging threats or coverage gaps.
- When you need to add specific exceptions for known-legitimate processes or users.
- When you need to manage rule lifecycle operations like enabling, disabling, or deleting rules via API.
Advantages
- Automates repetitive rule management tasks via the Kibana API.
- Provides a consistent workflow for investigating and tuning false positives.
- Includes validation tools to prevent invalid query syntax in production.
- Supports both standard SIEM rules and specialized Endpoint behavior exceptions.
Usage examples
- “Find the noisiest detection rules from the last 7 days and help me tune one.”
- The agent will list the top noisy rules by alert volume and guide you through investigating the alerts to determine the best tuning strategy.
- “Add an exception to exclude SCCM from the suspicious PowerShell rule.”
- The agent will identify the rule, verify the exception criteria, and apply the exception to the rule to suppress future false positives.
- “Create a new detection rule for certutil URL download or decode.”
- The agent will validate the provided query and create a new detection rule with the specified severity, risk score, and MITRE tags.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/elastic/security-detection-rule-management/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip security-detection-rule-management.zip -d .agents/skills
Documentation by elastic
Detection Rule Management
Create new detection rules for emerging threats and coverage gaps, and tune existing rules to reduce false positives.
All operations use the Kibana Detection Engine API via rule-manager.js.
Execution rules
Start executing tools immediately — do not read SKILL.md, browse the workspace, or list files first.
Report tool output faithfully. Copy rule IDs, names, alert counts, exception IDs, and error messages exactly as returned by the API. Do not abbreviate rule UUIDs, invent rule names, or round alert counts.
When a tool returns an error (rule not found, API failure), report the exact error — do not guess at alternatives.
Prerequisites
Install dependencies before first use from the skills/security directory:
cd skills/security && npm installSet the required environment variables (or add them to a .env file in the workspace root):
export ELASTICSEARCH_URL="https://your-cluster.es.cloud.example.com:443"
export ELASTICSEARCH_API_KEY="your-api-key"
export KIBANA_URL="https://your-cluster.kb.cloud.example.com:443"
export KIBANA_API_KEY="your-kibana-api-key"Common multi-step workflows
| Task | Tools to call (in order) |
|---|---|
| Tune noisy SIEM rule | rule_manager find/noisy-rules → run_query (investigate FPs) → rule_manager patch or add-exception |
| Add endpoint behavior exception | fetch_endpoint_rule (get rule definition from GitHub) → add_endpoint_exception (scoped to rule.id) |
| Create new detection rule | run_query (test query against data) → rule_manager create |
| Investigate rule alert volume | rule_manager get → run_query (query alerts index) |
For endpoint behavior rules, always fetch the rule definition first to understand query logic and existing exclusions
before adding an exception. For SIEM rules, always investigate alert patterns with run_query before tuning.
Critical: For endpoint behavior rules, always use fetch_endpoint_rule (not shell or direct script calls) to get
the rule definition, then use add_endpoint_exception to add the exception. These are dedicated tools — do not invoke
the underlying scripts manually.
Workflow: Tune a rule for false positives
Steps 1–2: Identify noisy rules and analyze false positives
Find noisy rules with noisy-rules or find, then get the rule definition and investigate alerts:
node skills/security/detection-rule-management/scripts/rule-manager.js noisy-rules --days 7 --top 20
node skills/security/detection-rule-management/scripts/rule-manager.js find --filter "alert.attributes.name:*Suspicious*" --brief
node skills/security/detection-rule-management/scripts/rule-manager.js get --id <rule_uuid>
node skills/security/alert-triage/scripts/run-query.js "kibana.alert.rule.name:\"<rule_name>\"" --index ".alerts-security.alerts-*" --days 7 --fullLook for patterns: same process/user/host → exception candidate; broad pattern → tighten query; legitimate software → exception; too broad → rewrite or adjust threshold.
Step 3: Choose a tuning strategy
In order of preference:
Add exception — Best for specific known-good processes, users, or hosts. Does not modify the rule query. Use when the rule is correct in general but fires on known-legitimate activity.
Tighten the query — Patch the rule's query to exclude the FP pattern. Best when the false positives stem from the query being too broad.
Adjust threshold / alert suppression — For threshold rules, increase the threshold value. For any rule type, enable alert suppression to reduce duplicate alerts on the same entity.
Reduce risk score / severity — Downgrade the rule's priority if it generates many low-value alerts but still has some detection value.
Disable the rule — Last resort. Only if the rule provides no value or is completely redundant with another rule.
Steps 4–5: Apply tuning, verify, and document
Add exception (single/multi-condition, wildcard via matches):
node skills/security/detection-rule-management/scripts/rule-manager.js add-exception \
--rule-uuid <rule_uuid> \
--entries "process.executable:is:C:\\Program Files\\SCCM\\CcmExec.exe" "process.parent.name:is:CcmExec.exe" \
--name "Exclude SCCM" --comment "FP: SCCM deployment" --tags "tuning:fp" "source:soc" --yesPatch query, threshold, severity, or disable:
node skills/security/detection-rule-management/scripts/rule-manager.js patch --id <rule_uuid> --query "process.name:powershell.exe AND NOT process.parent.name:CcmExec.exe" --yes
node skills/security/detection-rule-management/scripts/rule-manager.js patch --id <rule_uuid> --max-signals 50 --yes
node skills/security/detection-rule-management/scripts/rule-manager.js patch --id <rule_uuid> --severity low --risk-score 21 --yes
node skills/security/detection-rule-management/scripts/rule-manager.js disable --id <rule_uuid> --yesWrite operations (patch, enable, disable, delete, add-exception, bulk-action) prompt for confirmation by
default. Pass --yes to skip the prompt (required when called by an agent).
Verify with rule-manager.js get --id <rule_uuid>. Update triage cases via the case-management skill.
Workflow: Create new detection rule
Steps 1–2: Define the threat, data sources, and fields
Specify MITRE ATT&CK technique(s), required data sources (Endpoint, Network, Cloud), and malicious vs legitimate
behavior. Common indexes: logs-endpoint.events.process-*, logs-endpoint.events.network-*,
.alerts-security.alerts-*, logs-windows.*, logs-aws.*. Key fields: process.name, process.command_line,
process.parent.name, destination.ip, winlog.event_id, event.action. Verify data with run-query.js:
node skills/security/alert-triage/scripts/run-query.js "process.name:certutil.exe" --index "logs-endpoint.events.process-*" --days 30 --size 5Step 3: Write and test the query
Rule types: query (KQL field matching), eql (event sequences), esql (aggregations), threshold (volume-based),
threat_match (IOC correlation), new_terms (first-seen). Test against Elasticsearch before creating:
node skills/security/alert-triage/scripts/run-query.js "process.name:certutil.exe AND process.command_line:(*urlcache* OR *decode*)" \
--index "logs-endpoint.events.process-*" --days 30For EQL, use --query-file to avoid shell escaping issues.
Validate query syntax before creating or patching a rule. The validate-query command catches common errors locally
— escaped backslashes, mismatched parentheses, unbalanced quotes, and duplicate boolean operators:
node skills/security/detection-rule-management/scripts/rule-manager.js validate-query \
--query "process.name:taskkill.exe AND process.command_line:(*chrome.exe* OR *msedge.exe*)" --language kueryThe create and patch commands also run validation automatically and reject invalid queries. Pass --skip-validation
only if you are certain the query is correct despite triggering a check.
Common KQL syntax mistakes:
Escaped forward-slashes — KQL wildcards use plain text. Write
*/IM chrome.exe*, not*\/IM chrome.exe*.Mismatched parentheses — every
(must have a matching).Unbalanced quotes — every
"must be paired.Duplicate operators —
AND ANDorOR ORis always an error.
Step 4: Create the rule
node skills/security/detection-rule-management/scripts/rule-manager.js create \
--name "Certutil URL Download or Decode" \
--description "Detects certutil.exe used to download files or decode Base64 payloads, a common LOLBin technique." \
--type query \
--query "process.name:certutil.exe AND process.command_line:(*urlcache* OR *decode*)" \
--index "logs-endpoint.events.process-*" \
--severity medium --risk-score 47 \
--tags "OS:Windows" "Tactic:Defense Evasion" "Tactic:Command and Control" \
--false-positives "IT administrators using certutil for legitimate certificate operations" \
--references "https://attack.mitre.org/techniques/T1140/" \
--interval 5m --disabledFor complex rules (EQL sequences, MITRE mappings, alert suppression), use create --from-file rule_definition.json and
--threat-file. See references/detection-api-reference.md for schema.
Step 5: Monitor and iterate
Monitor alert volume with noisy-rules --days 3 --top 10 and tune false positives as needed.
Workflow: Endpoint behavior rules tuning
Tune Elastic Endpoint behavior rules by adding Endpoint exceptions scoped to specific rules. Endpoint exceptions live in Security → Exceptions → Endpoint Security Exception List, not under individual SIEM rules.
Key principles: Always fetch the rule definition from protections-artifacts first. Always scope exceptions to the
rule (rule.id or rule.name). Use full paths over process names. Run the mandatory entity cross-check (Step 4b)
before any exception. Simulate impact (Step 5b) and aim for ≥60% noise reduction.
Scripts: fetch-endpoint-rule-from-github.js (get rule TOML by id), add-endpoint-exception.js (add to Endpoint
Exception List; rule.id/rule.name required), check-exclusion-best-practices.js.
For the full step-by-step workflow (Steps 1–6), queries, and simulation templates, see references/endpoint-behavior-tuning-workflow.md. For exclusion best practices, see references/endpoint-rule-exclusion-best-practices.md.
Tool reference
rule-manager.js
All commands are run from the workspace root. All output is JSON unless noted.
| Command | Description |
|---|---|
find | Search/list rules with optional KQL filter |
get | Get a rule by --id or --rule-id |
create | Create a rule (inline flags or --from-file) |
patch | Patch specific fields on a rule |
enable | Enable a rule |
disable | Disable a rule |
delete | Delete a rule |
export | Export rules as NDJSON |
bulk-action | Bulk enable/disable/delete/duplicate/edit |
add-exception | Add an exception item to a rule |
list-exceptions | List items on an exception list |
create-shared-list | Create a shared exception list |
noisy-rules | Find noisiest rules by alert volume |
validate-query | Check query syntax before create/patch |
Endpoint behavior tuning: fetch-endpoint-rule-from-github.js (get rule TOML by id), add-endpoint-exception.js
(add to Endpoint Exception List; rule.id/rule.name required), check-exclusion-best-practices.js.
Exception entry format
Pass entries as field:operator:value. Operators: is, is_not, is_one_of, is_not_one_of, exists,
does_not_exist, matches, does_not_match. Example: process.name:is:svchost.exe,
file.path:matches:C:\\Program Files\\*.
Additional resources
For full API schema details, see references/detection-api-reference.md
For endpoint behavior tuning: references/endpoint-exceptions-guide.md, references/endpoint-rule-exclusion-best-practices.md
For alert investigation during tuning, use the
alert-triageskillFor documenting tuning actions in cases, use the
case-managementskill
Examples
"Find the noisiest detection rules from the last 7 days and help me tune one"
"Add an exception to exclude SCCM from the suspicious PowerShell rule"
"Create a new detection rule for certutil URL download or decode"
Guidelines
Report only tool output. When summarizing results, quote or paraphrase only what the tools returned. Do not invent IDs, hostnames, IPs, scores, process trees, or other details not present in the tool response.
Preserve identifiers from the request. If the user provides specific hostnames, agent IDs, case IDs, or other values, use those exact values in tool calls and responses — do not substitute different identifiers.
Confirm actions concisely. After executing a tool, confirm what was done using the tool's return data. Do not fabricate internal IDs, metadata, or status details unless they appear in the tool response.
Distinguish facts from inference. If you draw conclusions beyond what the tools returned (e.g., suggesting a MITRE technique based on observed behavior), clearly label those as your assessment rather than presenting them as tool output.
Start executing tools immediately. Do not read SKILL.md, browse directories, or list files before acting.
Report tool output verbatim. Copy rule IDs, names, alert counts, and error messages exactly as returned. Do not abbreviate UUIDs or round numbers.
Production use
All write operations (
create,patch,enable,disable,delete,add-exception,bulk-action,add-endpoint-exception) prompt for confirmation. Pass--yesor-yto skip when called by an agent.Endpoint exceptions suppress detections globally. Always scope exceptions to a specific rule using
rule.idorrule.namein the entries. A broad, unscoped exception can silently reduce detection coverage.Verify environment variables point to the intended cluster before running any script.
Use
--dry-runwithbulk-actionto preview impact before executing bulk changes.
Environment variables
| Variable | Required | Description |
|---|---|---|
ELASTICSEARCH_URL | Yes | Elasticsearch URL (for noisy-rules aggregation) |
ELASTICSEARCH_API_KEY | Yes | Elasticsearch API key |
KIBANA_URL | Yes | Kibana URL (for rules API) |
KIBANA_API_KEY | Yes | Kibana API key |
Files
- ATTRIBUTION.mdAdded by AutoGineer997 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md15.2 KiB
- references/detection-api-reference.md7.9 KiB
- references/endpoint-behavior-tuning-workflow.md6.3 KiB
- references/endpoint-exceptions-guide.md3.8 KiB
- references/endpoint-rule-exclusion-best-practices.md6.3 KiB
- scripts/add-endpoint-exception.jsScript5.5 KiB
- scripts/check-exclusion-best-practices.jsScript2.1 KiB
- scripts/es-client.jsScript1.8 KiB
- scripts/fetch-endpoint-rule-from-github.jsScript3.8 KiB
- scripts/kibana-client.jsScript6.7 KiB
- scripts/rule-manager.jsScript21.1 KiB
references/endpoint-behavior-tuning-workflow.md
Endpoint Behavior Rules Tuning Workflow
Analyze alerts from Elastic Endpoint behavior rules and add Endpoint exceptions to reduce false positives.
Endpoint exceptions live in Security → Exceptions → Endpoint Security Exception List (/app/security/exceptions),
not under individual SIEM rules. Use the scripts in this skill for rule lookup, GitHub rule fetch, and adding endpoint
list items.
Reference: Add and manage exceptions (Endpoint). Rule logic: protections-artifacts/behavior/rules or Kibana rule get by ID.
Critical principles (endpoint behavior)
Start with rule definition from protections-artifacts (Step 1b) to understand query logic and exclusions; avoid broad exclusions.
When in doubt, do not add an exception — return your conclusion and let the user confirm.
Always scope to the rule: Include
rule.id:is:<uuid>orrule.name:is:<name>first; otherwise the exception applies to all rules.Use full path over process name (e.g.
C:\Python39\python.exe); wildcards only for variable segments. See endpoint-rule-exclusion-best-practices.md.Step 4b is mandatory: Run entity cross-check before any endpoint exception; skipping can exclude true positives.
Validate before applying: Simulate (Step 5b); aim for ≥60% noise reduction.
Endpoint tuning progress
- [ ] Step 1: Identify the noisy rule and get definition (Kibana)
- [ ] Step 1b: Pull rule content from GitHub (query + exclusions)
- [ ] Step 2: FP likelihood (host/user spread, 24h)
- [ ] Step 3: Top noisy patterns (ES|QL)
- [ ] Step 4: Single-host entity_id check
- [ ] Step 4b: Single-host deep investigation (entity cross-check) — MANDATORY; do not skip
- [ ] Step 5: Design exception (aligned with rule logic; use full path for resilience)
- [ ] Step 5b: Simulate exception impact (before/after)
- [ ] Step 6: Add endpoint exception and verifyStep 1 & 1b: Identify rule and pull from GitHub
Endpoint behavior rule definitions live in the protections-artifacts repo, not in Kibana. To get the rule id (UUID) and the rule definition:
Get rule.id from the alerts index by querying with the rule name (from noisy-rules or the UI). Replace
<rule_name>with the exact behavior rule name (e.g.Suspicious PowerShell Execution):
FROM .alerts-security.alerts-*
| WHERE rule.name == "<rule_name>"
| STATS count = COUNT(*) BY rule.id
| SORT count DESC
| LIMIT 1Fetch the rule definition from protections-artifacts using the rule id:
node skills/security/detection-rule-management/scripts/fetch-endpoint-rule-from-github.js --rule-id <rule_id>Use the printed query from GitHub to see fields and existing exclusions; then proceed to Step 2–5b. For SIEM rules
(not endpoint behavior), use rule-manager.js find --filter "alert.attributes.name: ..." to look up by name on the
stack.
Step 2–4b: FP likelihood, patterns, entity cross-check
When searching the alerts index for endpoint rules, use rule.name (e.g. in ES|QL
rule.name == "Suspicious PowerShell Execution" or in KQL rule.name:<name>). Use rule.id in aggregations once you
have it from a sample alert.
Step 2: ES|QL on
.alerts-security.alerts-*withrule.name == "<rule_name>"(orrule.id == "<rule_id>") and@timestamp >= now() - 24 hours;STATS n_hosts = COUNT_DISTINCT(host.id), n_users = COUNT_DISTINCT(user.name) BY rule.id. ≥10 hosts or ≥5 users → likely broad FP.Step 3: Top patterns by
process.executable,process.parent.executable,user.name,host.name(filter byrule.nameorrule.id).Step 4: For single host, check
process.entity_idacross alerts:WHERE process.entity_id == "<id>"andSTATS ... BY rule.id, event.code.Step 4b (mandatory — do not skip): Single-host deep investigation. Take one sample alert; run entity cross-check by
rule.nameandevent.code. If the sameprocess.entity_idorprocess.parent.entity_idappears in other rules or event types (e.g. memory_signature, shellcode_thread, ransomware) → treat as TP, do not add exception. You must complete this step before adding any endpoint exception. Entity cross-check query:
FROM .alerts-security.alerts-*
| WHERE (process.entity_id == "<entity_id>" OR process.parent.entity_id == "<entity_id>")
AND @timestamp >= NOW() - 7 days
| STATS alert_count = COUNT(*) BY rule.name, event.code
| SORT alert_count DESCStep 5 & 5b: Design exception and simulate impact
Match the rule's event type and exclusion style. Use full path when known; wildcards only for variable segments. For
LOLBins use path + args. Simulate before applying: baseline count, then same query with
AND NOT (process.executable LIKE "..."). Aim for ≥60% reduction.
Baseline query:
FROM .alerts-security.alerts-*
| WHERE rule.name == "<rule_name>"
AND @timestamp >= NOW() - 24 hours
| STATS alert_count = COUNT(*), distinct_hosts = COUNT_DISTINCT(host.id)After-exception query (add your exclusion condition):
FROM .alerts-security.alerts-*
| WHERE rule.name == "<rule_name>"
AND @timestamp >= NOW() - 24 hours
AND NOT (process.executable LIKE "<exception_pattern>")
| STATS alert_count = COUNT(*), distinct_hosts = COUNT_DISTINCT(host.id)Step 6: Add endpoint exception
Only after Step 5b shows meaningful reduction and you are confident the pattern is FP. Always include rule scope
(rule.id or rule.name first):
node skills/security/detection-rule-management/scripts/add-endpoint-exception.js \
--name "Exclude <short description> (<rule name>)" \
--entries "rule.id:is:<rule_uuid>" "process.executable:matches:C:\\Program Files\\Vendor\\*\\agent.exe" \
--comment "FP: Legitimate agent; path + parent verified" \
--os-types windowsVerify in Kibana: Security → Exceptions → Endpoint Security Exception List.
For full workflow detail, event-type strategies (single-event vs API/call stack), and LOLBin guidance, see endpoint-exceptions-guide.md and endpoint-rule-exclusion-best-practices.md.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an API key, Needs Node.js
The author says: Requires Node.js 22+, network access to Kibana and Elasticsearch. Environment variables: KIBANA_URL plus KIBANA_API_KEY or KIBANA_USERNAME/KIBANA_PASSWORD; ELASTICSEARCH_URL or ELASTICSEARCH_CLOUD_ID plus ELASTICSEARCH_API_KEY or ELASTICSEARCH_USERNAME/ELASTICSEARCH_PASSWORD.
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- elastic
- Publisher
- Elastic (Official)
- Source
- elastic/agent-skills · skills/security/detection-rule-management · commit 09d879d
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Also distributed in
- elastic/agent-skills
AutoGineer is not affiliated with or endorsed by elastic.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download security-detection-rule-management.zip