On the Search page, you can add comments, or even comment out lines of your search query using comment formatting, as follows:
- // - Comments out a single line of the query, or a part of a single line.
- /* */ - Creates a multiple line comment.
Comments can be useful for the following use cases:
- Add comments to your search query in order to add context for users who may want to use or edit your queries at a later date.
- Comment out single lines or multiple lines to troubleshoot your query while you are writing it.
When you comment out a line of your search query, the user interface displays the commented text as grey and italic. See the following example of commenting out a single line in a query:
If the query is valid without the line that is commented out, it will still run when you click Start.
For example, in the Logins query above, we have commented out the where statement, so the results returned will include all results, not just those for the US.
The following is a multi-line comment.
Pro Tip: Sumo Logic App Queries as Examples
As a tip, Sumo Logic Apps are a great resource of example search queries. You can review and even run searches from Sumo Logic Apps without installing them. To view available Sumo Logic Apps, click the Library icon at the top of the UI (Library > Apps in the classic UI). You can also copy content from the Library, and use it as a starting point to create your own queries. When you do that, you can comment out the aggregation lines of the query and replace them with your own. You can also delete them of course, but commenting them out instead would make them available for reference later.