Macros

A Macro lets you save any search query in a single name and re-use it in the system. You can use macros with other search queries in the Search, Dashboards, Reports, Alert Rules, Label Packages, Search Packages and Search Templates. You can also add as many macros as needed or update the same macro several times. This lets you use a macro in different settings but update in one place.

Adding Macros

  1. Go to Settings >> Knowledge Base from the navigation bar and click Macros.

  2. Click Add.

../_images/LP_KB_Macros_Add.png

Adding a Macro

  1. Enter a Name for the macro. The field supports alpha-numeric and underscore (_) characters.

  2. In the Query field, enter a complete and valid query. An invalid query results in error. Click the error sign right next to the query bar for details.

  3. Click Submit.

Searching with Macros

In the Search tab of Logpoint, you can search for various types of logs using macros. When you use macros, put a backtick character (`) before and after the macro name. You can use multiple macros in a single search. You can view the search query defined in the macro from the Macros page under Settings >> Knowledge Base from the navigation bar.

../_images/LP_Search_Macro_Query.png

Searching with Macros

Moreover, you can add the macros to the Dashboard, Alert Rule, Labelling Rule, Incident and Public URL by clicking Add Search To. Go to Add Search To for more details.

Updating Macros

When you update a macro, it is auto-updated in all the settings that use the macro.

  1. Go to Settings >> Knowledge Base from the navigation bar and click Macros.

  2. Click the macro to update.

../_images/LP_KB_Macros_Update.png

Updating Macros

  1. Update the Name or Query.

  2. Click Submit.

Deleting Macros

Before deleting a macro, make sure to remove it from all the Setting items.

  1. Go to Settings >> Knowledge Base from the navigation bar and click Macros.

  2. Click the Delete icon under Actions.

../_images/LP_KB_Macros_Delete.png

Deleting Macros

  1. Click Yes.

../_images/LP_KB_Macros_Unable_To_Delete.png

Unable to delete macros

Importing Macros

While importing the Setting items that use macros, make sure the macros are present in the system.

  1. Go to Settings >> Knowledge Base from the navigation bar and click Macros.

  2. Click Import.

../_images/LP_KB_Macros_Import.png

Importing macros

  1. Browse the file to import.

  2. Click Submit.

Exporting Macros

  1. Go to Settings >> Knowledge Base from the navigation bar and click Macros.

  2. Select the macros to export.

  3. Click Export.

../_images/LP_KB_Macros_Export.png

Exporting macros

Examples of Macros

Example 1: Simple search in macros

  1. Create a macro named ip_search with the following query:

device_ip=10.94.1.18 sig_id=500001
  1. In the search query bar, type `ip_search` and click Search.

The above example searches for all the log messages with the device_ip as 10.94.1.18 and sig_id as 500001.

../_images/LP_Search_Macros_Example1.png

Macros Example

Example 2: Aggregation function in macros

  1. Create a macro named users with the following query:

device_ip=10.94.1.18 | chart count() by user
  1. In the search query bar, type `users` and click Search.

The above example searches for all the log messages with the device_ip as 10.94.1.18, group them by user, and displays the count of the log messages for each user.

../_images/LP_Search_Macros_Example2.png

Macros Example

Example 3: Evaluation process command and Aggregation function in macros

  1. Create a macro named eval_revenue with the following query:

| process eval("Revenue=unit_sold*Selling_price") | fields unit_sold, Selling_price, Revenue
  1. In the search query bar, type `eval_addition` and click Search.

The above example calculates the value of Revenue by multiplying the values of unit_sold and Selling_price, and shows the corresponding values of all the three fields in a tabular form.

../_images/LP_Search_Macros_Example3.png

Macros Example

Example 4: Multiple macros in a single search

In the search query bar, type user=Jolly `ip_search` `eval_revenue` and click Search.

The above example first searches for the logs with the user as Jolly. It then searches for the logs with device_ip as 10.94.1.18 and sig_id as 500001 (as defined in the ip_search macro). From these logs, it then calculates the revenue and shows the result in a tabular form (as defined in the eval_revenue macro).

../_images/LP_Search_Macros_Example4.png

Macros Example


Helpful?

We are glad this guide helped.


Please don't include any personal information in your comment

Contact Support