--- id: logcompare title: LogCompare description: LogCompare allows you to easily compare log data from different time periods to detect major changes or anomalies. slug: /help/docs/search/behavior-insights/logcompare/ canonical: https://www.sumologic.com/help/docs/search/behavior-insights/logcompare/ --- import useBaseUrl from '@docusaurus/useBaseUrl'; LogCompare allows you to easily compare log data from different time periods to detect major changes or anomalies. LogCompare runs a delta analysis that helps you troubleshoot and discover root causes. For example, you could determine what was different right before a failure compared to the previous day or previous week. Or, you could easily check if a new release introduced a new issue by reviewing the difference in log streams across time. ## How LogCompare works LogCompare creates a baseline (historical) query and compares it to a target (current) query. Logs from each query are clustered into patterns, called signatures, then compared and ranked based on the significance of change. For example, a 24-hour LogCompare, which is the default time shift, allows you to pinpoint the major changes in your log messages compared to the same time on the previous day. LogCompare reports the variance between the baseline and the target, allowing you to see the change in patterns of log messages over time. This way, you can compare log messages from today with the same time range from yesterday, and see the percentage of changes in your log message signatures, as well as new signatures that have appeared, and signatures that are now gone. ### Search time Depending on the time range you have selected for the search, the LogCompare operation may take a long time to complete, due to the multiple operations it is performing. For this reason, we suggest that you select as small a time range as practical. If the baseline query does not finish within two hours, it will timeout. ### Compare vs. LogCompare The [`compare`](/docs/search/time-compare) and `logcompare` operators are very similar in syntax and functionality, but they handle different types of data: * `compare` is used for aggregated numeric data, such as analyzing results from a [group by](/docs/search/search-query-language/group-aggregate-operators) query or a query with aggregation operators like `count`, `sum`, and `avg`. * `logcompare` is used for log signature counts based on your raw log data. ## Use LogCompare LogCompare is an operator available in log searches. You can manually add it to a query or use the built-in button provided on the **Messages** tab after running a non-aggregate query. ### LogCompare button First, run a non-aggregate search, then the **LogCompare** button in the **Messages** tab can be quickly pressed to run the baseline (historical) query 24 hours in the past. However, you can easily change the baseline query time range by clicking the dropdown arrow to the right of the button. LogCompare button Once clicked, a new search is opened with the `logcompare` operator and the specified `timeshift` added to your query, for example: ```sumo * | logcompare timeshift -24h ``` A new tab labeled **Signatures** is provided with the compared results. Signatures tab #### Custom option Click the dropdown arrow next to the **LogCompare** button and select **Custom**. <custom LogCompare In the **Custom LogCompare** dialog, you can specify the target and baseline query independently, including their time ranges. LogCompare custom * **Baseline Query** is your historical query. * **Time Shift** is the Time Shift of the Baseline Query, and it controls when the Baseline Query runs. If the Time Shift is -2d, that means that it will run for the exact Time Range duration (1 minute, in this query), but two days in the past. :::note The Time Shift can take a single value, such as -2d, or it can take a range. It must be a valid range, with a start date older or smaller than the end date. ::: * **Target Query.** Originally, the Target Query is the same as the Baseline Query. But you can edit it to compare against a new target. Here we’ve added `_sourceCategory=analysis` to compare it to `_sourceCategory=stream`. * **Time Range.** The Time Range pertains to both the Target Query and the Baseline Query. You can enter a preconfigured, relative, or absolute time range, similar to the time range on the Search page. The Time Range can be specified by timeshift (start_time = now - timeshift) or (start_time + end_time). * For the target, if the end_time is not specified, it is implicitly set to now if not specified. * For the baseline, if the end_time is not specified, it is implicitly set as: (`end_time = start_time + range_length`). The (`range_length = end_time - start_time`) using the target times. :::note See the [Time Shift versus Time Range example](#time-shift-versus-time-range-example) for a table showing how these settings affect the Target and Baseline queries. ::: Click **Run** to add the logcompare operator, timeshift, and baseline to your query, for example: `_sourceCategory=analysis | logcompare timeshift -2d baseline (_sourceCategory=stream)` Results appear in the **Signatures** tab. ### LogCompare operator The LogCompare operator is used the same as a search operator. This section explains how to manually add LogCompare to a query, the [LogCompare button](#logcompare-button) simply does this for you. #### Syntax ` | logcompare timeshift