-
Notifications
You must be signed in to change notification settings - Fork 228
macro Operator docs #4767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
macro Operator docs #4767
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
09cac46
macro Operator docs
JV0812 ef94992
minor formatting
JV0812 14e8306
Update docs/search/search-query-language/search-operators/macro.md
JV0812 5c7cd96
Update docs/search/search-query-language/search-operators/macro.md
JV0812 e38b399
Update docs/search/search-query-language/search-operators/macro.md
JV0812 6a6c7d7
Update docs/search/search-query-language/search-operators/macro.md
JV0812 8bd5ce2
Update docs/search/search-query-language/search-operators/macro.md
JV0812 3fd537e
Update docs/search/search-query-language/search-operators/macro.md
JV0812 46e4b74
Update docs/search/search-query-language/search-operators/macro.md
JV0812 c9fc3a2
Update docs/search/search-query-language/search-operators/macro.md
JV0812 9e1742d
Update macro.md
JV0812 4ef4ad6
Update macro.md
JV0812 f67a26e
Merge branch 'main' into macro-operator-docs
JV0812 7e8900f
Update macro.md
JV0812 8c42dca
minor fix
JV0812 9b6bbe2
added images
JV0812 1cdb94d
Update docs/search/search-query-language/search-operators/macro.md
JV0812 87474bf
Merge branch 'main' into macro-operator-docs
JV0812 142867a
minor fix
JV0812 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
docs/search/search-query-language/search-operators/macro.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| --- | ||
| id: macro | ||
| title: macro Operator | ||
| sidebar_label: macro | ||
| --- | ||
| import useBaseUrl from '@docusaurus/useBaseUrl'; | ||
|
|
||
| With `macro` operator you can reuse the portions of search query language in multiple other queries. This operator also includes arguments and also performs its respective evaluation of the arguments. | ||
|
|
||
| Use backquote (``) character to refer macro operator in the query. Macros referred inside another macro is called **Nested macros**. Macro referred within the context of another macro query of is called **Inner Macro**. The macro where the inner macro is referred is called the **Outer Macro**. | ||
JV0812 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| :::note | ||
| - Only **Administrators** and **Users** with access to **Query Reference** will be able to run queries using macros. | ||
JV0812 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - Only users with **Administrator** access can create or delete the macro. | ||
JV0812 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ::: | ||
|
|
||
| ## Syntax | ||
|
|
||
| ``` | ||
| `<macro name>` | ||
| ``` | ||
|
|
||
| ## Add a macro | ||
|
|
||
| To create a macro follow the steps below: | ||
JV0812 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 1. [**Classic UI**](/docs/get-started/sumo-logic-ui-classic). In the main Sumo Logic menu, select **Manage Data** > **Logs** > **Macros**. <br/> [**New UI**](/docs/get-started/sumo-logic-ui/). In the top menu, select **Manage Date**, and then under **Logs**, select **Macros**. You can also click the **Go To...** menu at the top of the screen and select **Macros**. | ||
| 1. Click **+ Add Macro**.<br/><img src={useBaseUrl('img/search/searchquerylanguage/search-operators/macro-logs-page.png')} alt="macro-logs-page" style={{border: '1px solid gray'}} width="800" /> | ||
| 1. Or, in the log search page, select the part of search query language that needs to be reused and click on **Create Macro**.<br/><img src={useBaseUrl('img/search/searchquerylanguage/search-operators/macro-search-page.png')} alt="macro-search-page" style={{border: '1px solid gray'}} width="800" /> | ||
| 1. **Macro Details**. Enter the name for the macro. Description is optional. | ||
| 1. **Macro Definition**. Enter the definition for the macro. To add arguments use the `{{Arg}}` syntax or select a part of the definition and click on **Add Argument**. | ||
| 1. (Optional)**Arguments**. Enter the name and select the data type for the argument selected. | ||
| 1. (Optional)**Argument Validation**. Define the validation condition and enter the error message that needs to be shown when the validation expression returns false. | ||
JV0812 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 1. **Usage**. Preview of how you use the macro in the log search. | ||
| 1. Click **Submit** to save the macro. | ||
|
|
||
JV0812 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ### Limitations | ||
|
|
||
| - You can create a maximum of 50 macros. | ||
| - You can add a maximum of 5 definitions. | ||
JV0812 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
JV0812 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
JV0812 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ### Example | ||
|
|
||
| Consider the below query that search for the errors with timeslice of 5 minutes. | ||
JV0812 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ``` | ||
| _sourceCategory=error | timeslice 5m | ||
| | count by _timeslice | ||
| ``` | ||
|
|
||
| Now by creating macro for the timeslice field, the query with the `macro` operator is modified as: | ||
JV0812 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ``` | ||
| _sourceCategory=error | `timeslice_macro` | ||
JV0812 marked this conversation as resolved.
Show resolved
Hide resolved
JV0812 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+269 KB
static/img/search/searchquerylanguage/search-operators/macro-logs-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+44.9 KB
static/img/search/searchquerylanguage/search-operators/macro-search-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.