Start Simple
Begin with basic rules. Keep rules simple and focused on what you need to detect.Always Validate & Test
Use validate and dry-run before deploying rules.Use Testing Directory for Development
Create new rules inrules/testing/ first, then test them with dry-run before moving to production:
-
Create rule in testing directory:
-
Test it safely:
-
Move to production when ready:
rules/testing/ are NEVER loaded in production (when running blocklight start). The dry-run command automatically includes them for testing purposes, ensuring you can test rules safely without generating alerts or affecting your monitoring system.
Caching
Caching is always enabled in Blocklight for optimal performance. Configure appropriate TTL values in analysis config based on your use case.Reuse Components
Use lists and macros to keep rules maintainable. Important:lists and macros are defined at the file level (not inside rules), allowing you to create reusable building blocks that multiple rules in the same file can share.
File Organization: When grouping multiple rules in the same file, ensure they are related to each other (e.g., same category, threat type, or protocol). While lists and macros can be shared across rules in the same file, mixing unrelated rules can make maintenance complex. Organize rules by category, threat type, or protocol to keep your rule base maintainable. See Rule Structure for more details.
Secure Your Secrets
Use${ENV_VARS} in alert configuration. Never commit secrets.