Rule Queries
The Query tab holds the
StroomQl
StroomQl
Every row the query returns becomes one detection. This is the single most important thing to understand about a rule. A query that returns a million rows will raise a million detections, so it is worth running the query and looking at the row count before enabling the rule.
See Also
Choosing a Data Source
A rule query can use any data source that a Query document can use, but the choice interacts with the processing type.
- A Scheduled Query rule can query anything, including
Searchables
Searchable
A Searchable is the term given the special searchable data sources that appear at the root of the explorer tree picker when selecting a data source. These data sources are special internal data sources that are not user managed content, unlike an Index. They provide the means to search various aspects of Stroom’s internals, such as the Meta Store or Processor Tasks.Click to see more details... and Lucene indexes.
- A Streaming rule must query a View , because the View’s filter is what decides which streams are fed through the rule.
See Also
Time Ranges and Relative Times
A rule that is going to run repeatedly should express its time range relative to when it runs, not as absolute dates.
When a scheduled rule runs, Stroom sets the reference time for the query to the rule’s effective execution time rather than to the current clock time. Every relative date expression in the query and in the time range is then resolved against that effective time.
This is what makes it possible for a rule to work through history.
A rule whose query says where EventTime >= day() - 1d will, when it runs for an effective time of last Tuesday, select last Monday’s data.
The same query run for an effective time of today selects yesterday’s data.
Note
effectiveExecutionTime and executionTime.
See Also
Columns
The columns your query selects become the content of each detection.
Every column is added to the detection as a name/value pair, using the column’s name as the key, and is available to email templates through the values dictionary.
Two column names are treated specially.
| Column | Treatment |
|---|---|
StreamId |
Used as the streamId of the detection’s linked event rather than added to values. |
EventId |
Used as the eventId of the detection’s linked event rather than added to values. |
Including StreamId and EventId in the query is what allows a detection to link back to the
Event
Event
Warning
Source IP has to be written as values['Source IP'] in a template, whereas SourceIp can be written as values.SourceIp.
See Also
Table Preferences
Some things about a result table cannot be expressed in
StroomQl
StroomQl
For an Analytic Rule these preferences affect only what you see while developing the query. For a Report they also affect the file that is produced, because the report is written from the same table.
Parameters
A rule can define parameters in the same way as a Query document, and refer to them in the query. Parameters are stored on the rule, so a scheduled rule always runs with the values held against it.