Triggers
Triggers use queries to set off actions when the query produces a result, so you do not have to rely on a routine of checking LogScale and executing queries manually or programmatically, and can detect problems as soon as they occur. There are four types of triggers: Scheduled searches, Aggregate alerts, Filter alerts, and Legacy alerts. The alerts use live queries that run continuously on ingested data, setting off one or more actions when the query returns a result. Scheduled searches use static queries and run on a regular schedule on stored data, setting off one or more actions when the query returns a result. Using triggers enables automation for notifying analysts and administrators through different integrations, such as email or forwarding to another repository.
Tip
If you are just learning about triggers in LogScale, it is a good idea to read General information about triggers.
Click the tabs below to explore each of the trigger types available:
A scheduled search is a static query that is set to run on a schedule. At a scheduled interval, the query runs and if its result is not empty, the scheduled search triggers and executes its associated action(s) once for the whole query result.
When to use scheduled searches
Scheduled searches are a type of trigger, like alerts, and they are able to trigger the same actions as alerts. However, scheduled searches are applicable in other use cases than alerts, such as when:
You need to automatically report some search result on a schedule. For instance, you have stakeholders that expect to get an email every Monday at 10:00 containing the top most important security events for the previous week. If you prefer to deliver the results in a dashboard, use Scheduled PDF Reports.
You need to take delayed action on search results. For instance, if you trigger user bans using an alert, offending users will be banned immediately upon a transgression and can then easily figure out what triggered their ban. Using a scheduled search, you can choose to ban all offending users at the same time every day, as to obscure the conditions of a ban.
You have a query using
join()
ordefineTable()
. When the query returns an aggregate result with one or more rows, the trigger is activated.If your situation requires instant notification about events that do not happen regularly, an alert is a better option. Alerts run as live queries, rather than static ones, which makes them generally more performant.
The humio-activity repository lists all activity logs with a suggestion of how to resolve the issue depending on the level of severity, see Monitor Triggers with humio-activity Repository for more information.
To enable scheduled searches, the environment variable
ENABLE_SCHEDULED_SEARCHES
must be set totrue
on every host in the cluster.Timestamp for scheduled searches
Scheduled searches can be configured to either run on @ingesttimestamp (default) or @timestamp. For more information about what to choose, see Which timestamp to use for trigger.
Ingest delay for scheduled searches
Scheduled searches use the @ingesttimestamp by default, meaning they are only affected by ingest delay inside LogScale. You can configure an amount of time to wait for ingest delay in LogScale to accomodate for that.
If a scheduled search runs on @timestamp, the scheduled search will be affected by ingest delay both inside and outside of LogScale. If you want a scheduled search to find all data, you need to account for ingest delay when configuring the scheduled search. If you have a scheduled search running every hour searching back one hour from when it runs, and the ingest delay is 20 minutes, then all events inside the last 20 minutes of each time window will not be found, as they are not yet searchable in LogScale when the query runs:
In order to handle that, you need to offset the query by the largest ingest delay that you want to accomodate. So instead of running the example scheduled search in the diagrams above from 1h to now, run it with an offset of 20 minutes:
%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% gantt dateFormat HH:mm axisFormat %H:%M tickInterval 1hour todayMarker off section A 1 hour search :a1, 06:40, 60m Offset :active,07:40, 20m section B 1 hour search :a1, 07:40, 60m Offset :active,08:40, 20mTiming scheduled searches
When deciding on the timing for your scheduled searches, it is important to consider the events and what you plan to do with the data.
If the scheduled search is aggregating events, the time window should match the time period you want to aggregate over.
If the scheduled search is correlating events, the time window should be large enough for all events that should be correlated with each other to be within the time window.
If the scheduled search is finding single events, the time window can be set as desired, down to 1 minute.
If you want the scheduled search to search through every period of real time completely and exactly once, the schedule and Time window should match, e.g. running the search every other hour over a 2-hour time window.
Retry for scheduled searches
Scheduled searches automatically retry failed runs, as long as they are not too far behind.
When running on @ingesttimestamp, Max wait time controls for how long to retry. Assuming a scheduled search runs every hour on the hour, fails the run at 13:00, a max wait time of 5 minutes means that the run at 13:00 will be retried until 13:05.
When running on @timestamp, retry is controlled by the Backfill Limit, which sets how many runs the scheduled search is allowed to be behind. Assuming a scheduled search runs every hour on the hour, fails the run at 13:00, a backfill limit of 0 means that the run at 13:00 will be retried until 14:00, at which time the 14:00 run will start. A backfill limit of 2 means that the 13:00 run will be retried until 16:00, at which time there are 3 newer runs (14:00, 15:00, and 16:00), so the 13:00 run will be skipped and the 14:00 one will run next.
Query warnings for scheduled searches
In case of query warnings, scheduled searches will not fail. Query warnings are:
Warnings that are logged and reported in the status of the alert, but otherwise continue despite.
Warnings that are treated as errors, since they mean that the result can be completely wrong.
Warnings about missing data. When running on @timestamp, scheduled searches wait for up to 10 minutes for missing data to become available. When running on @ingesttimestamp they wait up to whatever is set for Max wait time. Delay run does not influence how these warnings are handled.
The humio-activity repository lists all activity logs with a suggestion of how to resolve the issue depending on the level of severity, see Scheduled search errors and solutions for more information.