After you enable the indexing feature and configure indexes for a Logstore, you can query and analyze the logs that are stored in the Logstore in real time.
- Logs are collected. For more information, see Data collection overview. Important If you want to analyze logs, you must store the logs in a standard Logstore. For more information, see Manage a Logstore.
- Indexes are created. For more information, see Create indexes.
If you want to analyze logs, you must create field indexes.
- Log on to the Log Service console.
- In the Projects section, click the project that you want to view.
- Choose . On the Logstores tab, click the Logstore that you want to view.
- Enter a query statement in the search box.
A query statement consists of a search statement and an analytic statement in the Search statement|Analytic statement format. For more information, see Search syntax and SQL syntax and functions.
- Click 15Minutes(Relative) to specify a time range.
You can also specify a closed time interval in an analytic statement by using the __time__ field. Example:
* | SELECT * FROM log WHERE __time__>1558013658 AND __time__< 1558013660.The time range that you specify by using one of the preceding methods is accurate to minutes. The query and analysis results may contain logs that are generated 1 minute earlier or later than the specified time range. If you want to specify a time range that is accurate to seconds, you must use the from_unixtime function or to_unixtime function to convert the time format when you specify the time range in an analytic statement. Examples:
Note If you specify a time range in an analytic statement, the time range is used for query and analysis.
* | SELECT * FROM log WHERE from_unixtime(__time__) > from_unixtime(1664186624) AND from_unixtime(__time__) < now()
* | SELECT * FROM log WHERE __time__ > to_unixtime(date_parse('2022-10-19 15:46:05', '%Y-%m-%d %H:%i:%s')) AND __time__ < to_unixtime(now())
- Click Search & Analyze to view the query and analysis results.
Manage query and analysis results
- Log distribution histogram The log distribution histogram displays the distribution of query and analysis results in different time ranges.
- If you move the pointer over a green rectangle, you can view the time range that is represented by the rectangle and the number of logs that are obtained within the time range.
- If you click the green rectangle, you can view a more fine-grained log distribution. You can also view the query and analysis results on the Raw Logs tab.
- Raw Logs tab On the Raw Logs tab, you can view the logs that match your search conditions. You can click Table or Raw Data to view the logs and perform the following operations:
- Quick analysis: You can use this feature to analyze the distribution of a specific field within a specific period of time. For more information, see Quick analysis. You can click the icon to specify whether to show the names or aliases of fields. You can specify aliases when you configure indexes. For example, if you set the alias of the host_name field to host, host is displayed in the Quick Analysis list after you select Show Field Aliases.Note If you do not specify an alias for a field, the field name is displayed after you select Show Field Aliases.
- Contextual query: On the Raw Data tab, you can find a log and click the icon to view the context of the log in the raw log file. For more information, see Context query. Important The contextual query feature supports only the log data that is collected by Logtail.
- LiveTail: On the Raw Data tab, you can find a log and click the icon to monitor logs in real time and extract important information from the logs. For more information, see LiveTail. Important LiveTail can monitor and extract only the log data that is collected by Logtail.
- Tag configurations: On the Raw Data tab, you can click the icon and select Tag Configurations to hide fields that are less important.
- Column settings: On the Table tab, you can click the icon and select Column Settings to specify the columns that you want to display in the table. The column names are field names, and the column content is used as field values.
- JSON configurations: On the Table or Raw Data tab, you can click the icon and select JSON Configurations to specify the level for JSON expansion.
- Event settings: On the Table or Raw Data tab, you can click the icon and select Event Settings to configure events for raw logs. For more information, see Configure events.
- Log download: On the Table or Raw Data tab, you can click the icon to download logs. You can specify the method that is used to download logs and the range of logs to download. For more information, see Download logs.
- Quick analysis: You can use this feature to analyze the distribution of a specific field within a specific period of time. For more information, see Quick analysis.
- Graph tab After you execute a query statement, you can view the query and analysis results on the Graph tab.
- View query and analysis results: Log Service renders the results of query statements into charts. Log Service provides multiple chart types, such as tables, line charts, and bar charts. Log Service provides the following versions of charts: Pro and Standard. For more information, see Overview of charts (Pro) and Chart overview.
- Log Service allows you to create dashboards to perform real-time data analysis. You can click Add to New Dashboard to save query and analysis results as charts to a dashboard. For more information, see Overview of visualization.
- Configure interaction occurrences: Interaction occurrences are important for data analysis. You can use interaction occurrences to switch between the levels of data dimensions and the analysis granularities to obtain more detailed information. For more information, see Drill-down events.
- LogReduce tab
On the LogReduce tab, you can click Enable LogReduce to cluster similar logs. For more information, see LogReduce.
On the Search & Analysis page, you can choose Configure an alert monitoring rule in Log Service.to configure an alert rule based on the query and analysis results. For more information, see
- Saved searches
On the Search & Analysis page, you can click Save Search to save a query statement as a saved search. For more information, see Saved search.