6.2. Defining Search Criteria

Search criteria specify which log data a search or monitoring run retrieves and shows in the result table. They reduce the data to the log entries you need. Retrospective has text and date/time criteria, and a filter for Windows event properties.

A new search tab holds one text search criterion. If Show by default is selected on the Search/Monitor preferences page, it also holds one date/time criterion of the Default type. Add further criteria to make the search definition more precise.

A new search tab with a single text search criterion

Fig. 6.7 A new search tab with a single text search criterion.

To change the type of a single text criterion, click i-search-criteria-type Choose the criterion type left of the search text field and choose another type. When there is more than one criterion of any kind, or you choose a type other than Contains, a drop-down list replaces the button.

The drop-down list switches to another text type, such as Not contains, Starts with or Ends with. The toggle buttons right of the text field specify whether the text is a regular expression and whether it is case-sensitive.

Two text search criteria combined with a date/time search criterion

Fig. 6.8 Two text search criteria combined with a date/time search criterion.

Compose the search criteria as follows.

  1. Click i-add-text-criteria Add text search criterion to add a text criterion. To remove a criterion, click i-remove-criteria Remove search criterion next to it.

  2. Select how the criteria are combined:

    Match all (AND)

    Keeps log entries that match all criteria.

    Match any (OR)

    Keeps log entries that match any criterion.

  3. Select the type, for example Not contains.

  4. If needed, select i-regex Interpret search text as a regular expression (Regex) or i-case-insensitive Make search text case-sensitive.

  5. Enter the search text or regular expression, or set the date/time values.

  6. Click i-start-search Start Search, or press Ctrl+Enter (on macOS, Cmd+Enter). With a single text criterion and no date/time criterion, Enter in the search text field also starts the search.

6.2.1. Text Search Criteria

A search tab always holds at least one criterion. Click i-add-text-criteria Add text search criterion to add a text criterion, and i-remove-criteria Remove search criterion to remove one. Under Match all (AND), the last text criterion cannot be removed. Under Match any (OR), you can remove it while another criterion remains.

Under Match any (OR), an empty text criterion would make every other criterion useless. When you start such a search, the Empty Search Criterion warning appears and the search does not start.

Text search criteria fields appear together with the following toggle buttons.

i-regex Interpret search text as a regular expression (Regex)

Interprets the search text as a regular expression. While selected, the tooltip reads Interpret search text as plain text. Available for Contains and Not contains only.

i-case-insensitive Make search text case-sensitive

Matches upper and lower case exactly. While selected, the button shows i-case-sensitive and the tooltip reads Make search text case-insensitive.

The drop-down list offers the text types in the table below. Enter a search phrase. If the regex toggle is selected, enter a regular expression instead.

Type

Description

Contains

Keeps log entries that contain the phrase or match the regular expression. With the regex toggle selected, the collapsed summary shows Matches.

Not contains

Keeps log entries that do not contain the phrase and do not match the regular expression. With the regex toggle selected, the summary shows Not matches.

Starts with

Keeps log entries that begin with the phrase.

Most log entries start with a timestamp, so this type is rarely useful. Use a regular expression or a date/time criterion instead.

Ends with

Keeps log entries that end with the phrase.

When the regex toggle is not selected, you can use one or several wildcard characters to locate a specific log entry without knowing the exact phrase to be searched.

Wildcards are special characters that can represent unknown characters in a text. They help you locate log entries with similar, but not identical, data. You can use them anywhere in a text search criterion.

  • The asterisk (*) matches any number of characters.

  • The question mark (?) matches a single character at a specific position. When used alone, it matches any entry that is not empty or blank.

Retrospective treats * and ? as wildcards. To search for them, put a backslash (\) before them.

  • To search for asterisk (*), type \*.

  • To search for question mark (?), type \?.

  • To search for backslash (\), type \\. A single backslash that does not precede another backslash, an asterisk or a question mark is refused: the field is marked as invalid and the search cannot start.

For regular expressions, consult the Java regular expression reference and its summary of regular expression constructs.

6.2.2. Date/Time Search Criteria

If Show by default is selected on the Search/Monitor preferences page, a new search tab starts with one date/time criterion of the Default type, above the text criteria.

Note

In search mode, a tab accepts several date/time criteria only under Match any (OR). Under Match all (AND), one date/time criterion is allowed. Switching to Match all (AND) with several date/time criteria shows Invalid Operation, and the option stays unchanged. A restored or reopened search whose criteria already combine several date/time criteria with Match all (AND) shows the same message when you start it, and does not start.

Monitoring allows no date/time criteria. When you switch to Monitor, Retrospective removes them, and restores them when you switch back to Search.

Click i-add-datetime-criteria Add time search criterion to add a date/time criterion. A pop-up opens with four sections: Predefined, Relative, Date Frame and Date/Time Frame. Click a section title to open it; one section is open at a time, and the section you used last opens first. To close the pop-up without a choice, click i-cancel-popup Cancel (Esc) or press Esc.

6.2.2.1. Predefined Date/Time Search Criteria

This section offers predefined criteria relative to the current time: the Last entries (15 and 60 minutes, 4 and 24 hours, 7 and 30 days), the Current entries and the Previous entries. The Start of time unit toggle below the grid applies to the Last entries only. It is selected by default, and Retrospective remembers your choice until you close the application.

The Predefined section of the date/time criteria pop-up

Fig. 6.9 Predefined date/time search criteria.

After you choose a predefined criterion, you can still change it in its row. Choose another entry from the drop-down list to change the time unit.

For a Last criterion you can also:

  • select or clear the start-of-unit toggle i-start-of-time-unit (tooltip Disable ‘Start of time unit’ while selected, Enable ‘Start of time unit’ while cleared);

  • edit the number of time units: ↑ / ↓ and + / - change it between 1 and 9999.

Click i-configure-datetime Change time search criterion to replace this criterion with another one from the pop-up.

6.2.2.2. Relative Date/Time Search Criteria

This section defines a criterion relative to the current time. Enter the number and choose the unit; the default is 1 day. The toggle labelled with the unit, for example Start of day, starts the range at the beginning of that unit. It is selected by default, and Retrospective remembers your choice, separately from the Predefined section, until you close the application. Then click i-accept-popup Accept search criteria.

The Relative section of the date/time criteria pop-up

Fig. 6.10 Relative date/time search criteria.

You can still change the criterion in its row: select or clear the start-of-unit toggle, edit the number of units, or choose another unit from the drop-down list.

Unit list of a Last criterion

Fig. 6.11 Time units of a Last criterion.

Click i-configure-datetime Change time search criterion to replace this criterion with another one from the pop-up.

6.2.2.3. Date Frame Search Criteria

This section offers date frame criteria, also called date ranges. The entries read Since, Between and Before, each with its unit in parentheses (days, months or years). The unit sets the precision and format of the date fields.

The Date Frame section of the date/time criteria pop-up

Fig. 6.12 Date frame search criteria.

You can still change the criterion in its row. Choose Since, Between or Before, or change the boundaries. To change the precision, choose another entry from the pop-up.

Frame mode list

Fig. 6.13 Since, Between and Before.

To change the display format, change Date format on the Date/Time preferences page.

Click i-configure-datetime Change time search criterion to replace this criterion with another one from the pop-up.

6.2.2.4. Date/Time Frame Search Criteria

This section offers date/time frame criteria, also called date/time ranges. The entries read Since, Between and Before, each with its unit in parentheses (milliseconds, seconds, minutes or hours). The unit sets the precision and format of the date/time fields.

A new frame starts with valid boundaries. The upper boundary is the start of the current unit. The lower boundary is earlier by 1 hour for milliseconds to minutes, 1 day for hours, 3 days for days, 3 months for months and 1 year for years.

The Date/Time Frame section of the date/time criteria pop-up

Fig. 6.14 Date/time frame search criteria.

You can still change the criterion in its row. Choose Since, Between or Before, or change the boundaries. To change the precision, choose another entry from the pop-up.

To change the display format, change Date/Time format on the Date/Time preferences page.

Click i-configure-datetime Change time search criterion to replace this criterion with another one from the pop-up.

Note

Since and the relative criteria use the moment the search starts (now) as their upper boundary. Between and Before use the upper boundary you enter, so make sure it is not later than now.

This reduces a race condition that occurs when files or container log streams change during the search. Text criteria cannot prevent it: you cannot predict which final parts of a changing file or log stream the search reads.

6.2.2.5. Date/Time Frame Types

The drop-down list of date and date/time frame search criteria lets you choose the following criteria types.

Type

Description

Since

Keeps log entries created from the lower boundary (inclusive) up to the moment the search starts (exclusive). This prevents the race condition described above, so the lower boundary must not be in the future. Otherwise the field shows The begin time must not be in the future.

When the search starts, the row shows and before <date/time> after the field: the moment used as the exclusive upper boundary.

Between

Keeps log entries created from the lower boundary (inclusive) to the upper boundary (exclusive).

Before

Keeps log entries created before the upper boundary (exclusive).

The i-boundary-info icon next to each field shows whether that boundary is inclusive or exclusive in its tooltip.

6.2.2.6. Relative Date/Time Criteria Types

Unit list of a Current criterion

Fig. 6.15 Time units of a Current criterion.

When a relative date/time criterion is in the search definition, its row has a drop-down list of time units. Last offers seven units, Current and Previous offer six each. The tables below describe the resulting types. The examples use the format yyyy.MM.dd HH:mm:ss,SSS; the format you see depends on the Date/Time format preference.

Type

Keeps log entries created

Last n years

From n years before the search starts (inclusive) up to the moment it starts (exclusive).

Last n months

From n months before the search starts up to the moment it starts.

Last n weeks

From n weeks before the search starts up to the moment it starts.

Last n days

From n days before the search starts up to the moment it starts.

Last n hours

From n hours before the search starts up to the moment it starts.

Last n minutes

From n minutes before the search starts up to the moment it starts.

Last n seconds

From n seconds before the search starts up to the moment it starts.

When the start-of-unit toggle is selected, the lower boundary moves back to the start of its unit: the start of the year, month, week, day, hour, minute or second. Where a week starts depends on First day of week on the Date/Time preferences page.

In the following examples, Start Search is clicked at 2024.05.04 15:34:27,512. That moment is always the upper boundary, and it is excluded. The lower boundary is included. The week example assumes Monday as First day of week.

Entered

From, toggle cleared

From, toggle selected

2 years

2022.05.04 15:34:27,512

2022.01.01 00:00:00,000

3 months

2024.02.04 15:34:27,512

2024.02.01 00:00:00,000

2 weeks

2024.04.20 15:34:27,512

2024.04.15 00:00:00,000

2 days

2024.05.02 15:34:27,512

2024.05.02 00:00:00,000

5 hours

2024.05.04 10:34:27,512

2024.05.04 10:00:00,000

10 minutes

2024.05.04 15:24:27,512

2024.05.04 15:24:00,000

30 seconds

2024.05.04 15:33:57,512

2024.05.04 15:33:57,000

A Current type keeps the current unit up to the moment the search starts. A Previous type keeps the whole unit before the current one. The table shows the boundaries for the same click moment; the week rows again assume Monday.

Type

From (inclusive)

To (exclusive)

Current year

2024.01.01 00:00:00,000

2024.05.04 15:34:27,512

Current month

2024.05.01 00:00:00,000

2024.05.04 15:34:27,512

Current week

2024.04.29 00:00:00,000

2024.05.04 15:34:27,512

Today

2024.05.04 00:00:00,000

2024.05.04 15:34:27,512

Current hour

2024.05.04 15:00:00,000

2024.05.04 15:34:27,512

Current minute

2024.05.04 15:34:00,000

2024.05.04 15:34:27,512

Previous year

2023.01.01 00:00:00,000

2024.01.01 00:00:00,000

Previous month

2024.04.01 00:00:00,000

2024.05.01 00:00:00,000

Previous week

2024.04.22 00:00:00,000

2024.04.29 00:00:00,000

Yesterday

2024.05.03 00:00:00,000

2024.05.04 00:00:00,000

Previous hour

2024.05.04 14:00:00,000

2024.05.04 15:00:00,000

Previous minute

2024.05.04 15:33:00,000

2024.05.04 15:34:00,000

6.2.2.7. Using a Date/Time Field

A date/time field holds one value that is built from subfields such as year, month, day, hour, minute and second. Which subfields appear depends on the precision of the search criteria.

Editing with the keyboard and mouse

  • Click into a subfield, such as the day or the seconds, and type its digits. The first digit replaces the subfield. Once the subfield has all its digits, for example two for the seconds or four for the year, the caret moves on to the next subfield. So you can type a whole date digit by digit. A value the subfield cannot take, such as 75 seconds or month 13, is refused and the subfield keeps its value. After Tab has selected the whole field, the first digit goes to the first number subfield.

  • The field always keeps its date/time format. Other characters, as well as Backspace and Delete, are refused. Subfields shown as text, such as a month name, are skipped while typing; change them with ↑ and ↓ or the calendar.

  • The left and right arrow keys move the caret through the value. While one whole subfield is selected, they select the previous or next subfield.

  • Double-click a subfield, such as the year or the milliseconds, to select just that subfield.

  • The ↑ and ↓ arrow keys change the subfield the caret sits in. ↑ increases that subfield, ↓ decreases it. They start from the value on screen, including a date you have typed but not yet confirmed. While the typed text is not a valid date/time, they do not change it.

  • The digit to the right of the caret sets the step. In the milliseconds 400, the caret before the 4 steps by 100 and before the first 0 by 10. Before the last 0, or right after the last digit, it steps by 1. This works for every subfield except the year, which always steps by 1. A selected subfield steps by 1 and stays selected.

  • + and - do the same as ↑ and ↓. While a subfield is selected, they step it. Over any other selection, or while the typed text is not a valid date/time, they count as typed characters: - then moves past a - separator, anything else is refused. While an input method is composing text, + and - go into the composition and then count as typed characters. To use them as steps, switch the input method to direct input, or use ↑ and ↓. Full-width digits from an input method are typed as digits.

  • Ctrl+A, Ctrl+C and Ctrl+V select, copy and paste the whole value of the field, as in any other text field. A pasted value is taken when it is a whole date/time, or digits that fit the subfields from the caret on.

On macOS, use Cmd instead of Ctrl.

Retrospective marks the field when its value is not valid, and the search cannot start until you correct it. The field’s tooltip shows Invalid date/time format, for example for the 30th of February, The begin time must be before the end time, or The begin time must not be in the future. Date/time values are in the local time zone of your computer, as in the result table.

Choosing a date from the calendar

  • Click i-calendar Choose a date inside the field to open the picker. For month or year precision, it shows a month or year picker instead, and the tooltip reads Choose a month or Choose a year. Click a day to accept it, or click Today. Esc or a click outside closes the picker without a change. The picker sets the date only; the time of day keeps its value.

Calendar picker for choosing a date

Fig. 6.16 Choosing a date from the calendar picker.

6.2.3. Event Log Search Criteria

Windows event records carry structured properties that plain log lines do not have, and Retrospective can filter on them. The i-event-log-filter-add Add event-log filter button is in the search-criteria toolbar. It is available when the selected profile contains a Windows Event Log and the criteria are combined with Match all (AND). Only one event-log filter is allowed. The filter then has its own row in the search definition. Click the row’s i-event-log-filter-active Edit event-log filter to change it, or i-remove-criteria Remove search criterion to remove it.

The event-log filter pop-up

Fig. 6.17 The event-log filter pop-up, here with two levels selected.

The machine that holds the event log applies the filter before it sends anything back. The filter has three properties:

Property

Description

Event ID

A single event identifier from 0 to 65535, the fastest way to find a known event, for example a service crash. The field accepts digits only. A larger value is marked as an error, and Accept stays unavailable until you correct it.

Levels

The event’s severity property. Information also selects the events with level 0 (LogAlways), which Windows shows as information. Verbose also selects the levels an event provider defines above 5. Success selects level 16 in the Microsoft-Windows-HelloForBusiness/Operational and Microsoft-Windows-WebAuthN/Operational logs. In every other log, level 16 is Verbose.

Keywords

The event’s keyword property, such as Audit Success and Audit Failure.

Click i-accept-popup Accept to apply the filter, or i-cancel-popup Cancel to leave it unchanged. Accepting with every field empty removes the filter.

Switching to Match any (OR) while an event-log filter exists shows Invalid Operation: Windows Event Log search criteria and other criteria can be combined with AND only. The option stays unchanged. If you select a profile without a Windows Event Log, the filter row is hidden but the filter is kept.

Note

The criterion tests a property that only Windows event records carry. It applies to Windows Event Logs only. The other sources in the profile are unaffected by it. When it is the only criterion you set, those sources return all of their log entries. Add a text or time criterion to narrow them.

Note

As in the Windows Event Viewer, Information also selects the events with level 0 (LogAlways). Almost every Security event has this level, for example a failed logon (event ID 4625). By default, the result table shows the audit events among them as Audit Success or Audit Failure.

Levels and Keywords can still exclude each other. The Security log’s reserved keywords Audit Success and Audit Failure belong almost exclusively to level 0 events. Combine them with no level or with Information only.

In the Security log, Critical, Error and Warning find few events, if any. The event log service writes such events itself, for example the event with ID 1101 and level 2 (Error). Event 1101 also carries the Audit Success keyword. The result table therefore shows it as Audit Success if Report keywords in ‘Level’ column is selected, see Event Format.

6.2.4. Refining Event Log Searches

Reading a whole Windows Event Log can take long. When you start a search on a profile that contains a Windows Event Log, Retrospective checks the criteria first. If there is no event-log filter and not exactly one date/time criterion, the Refine Search Criteria dialog suggests adding them. Click Yes to return to the criteria, or No to start the search unchanged. Select Don’t show again to skip the question until you close Retrospective. Show dialogs again on the General preferences page brings it back. The dialog never appears for monitoring.