Searching for Logs (Old Edition)
Follow the directions below to search logs by keyword and time range:
- Log in to the LTS console and choose Log Management.
- In the log group list, click the name of a log group.
- In the log stream list, click the name of a log stream.
Alternatively, click Search in the Operation column of the target log stream.
- In the upper right corner, select a time range.
- There are two ways to conduct searches.
- Enter a keyword or select a keyword from the drop-down list box in the search box, and click
. Log events that contain the keyword are displayed.
If logs have been structured, the drop-down list box displays both the built-in fields and fields extracted from log structuring.
- Click
next to a log event to expand the event details. Click a field value in blue, and the field value will be used as a filter and log events that meet the filter will be displayed.
- Enter a keyword or select a keyword from the drop-down list box in the search box, and click
- Export the returned log events.
Click
and select Export .csv or Export .txt, depending on which format you prefer.
- If you select Export .csv, the logs are exported in the key-value format.
- If you select Export .txt, the raw logs are exported.
- Up to 5000 log events can be exported at once, regardless of the format.
Syntax and Examples of Log Searching
Search syntax:
| Syntax | Description |
|---|---|
| Exact search by keyword | LTS searches for logs containing the exact keyword (case-sensitive) that you specify. A keyword refers to a word between two adjacent delimiters. You can enclose a keyword with wildcards (*), for example, *error* to tell LTS to return results that match your keyword exactly. |
| Exact search by phrase | LTS searches for logs containing the exact phrase (case-sensitive) that you specify. |
| && | Intersection of search results. |
| || | Union of search results. |
| AND | Intersection of search results. |
| NOT | Logs that contain the keyword after NOT are excluded. |
| * | Fuzzy search. The wildcard (*) can be put only at the end of a keyword to replace an unspecified number of characters. |
| ? | Fuzzy search. The question mark (?) can be put in the middle or at the end of a keyword to replace exactly one character. |
If raw logs contain operators, such as &&, ||, AND, NOT, *, ? or :, these operators cannot be used to search for logs.
The rules of log searching are as follows:
- Fuzzy search is supported.
For example, if you enter error*, log events containing error will be displayed and words beginning with the error characters will be highlighted.
- Searching using multiple key-value pairs is supported. The format is key1:value1 key2:value2. After you search with key1:value1, you can add key2:value2 in the search box to apply both key-value pairs as filters.
Search examples:
- start searches for log events containing start.
- start to refresh searches for log events containing start to refresh.
- start && unexpected or start AND unexpected searches for log events containing both start and unexpected.
- start || unexpected searches for log events containing start or unexpected.
- start NOT unexpected searches for log events containing start but not unexpected.
- error* does a fuzzy search for log events containing error.
- er?or searches for log events containing a word that starts with er followed by a single character, and ends with or.
- query1 AND query2 NOT query3 searches for log events that meet both query1 and query2 but not query3.
- Searching is case-sensitive.
- The wildcard (*) and question mark (?) do not match special characters such as hyphens (-) and spaces.
Last Article: Log Search and View
Next Article: Viewing Logs in Real Time
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.