Skip to main content
Sumo Logic

Dynamic Parsing

Dynamic parsing allows automatic field extraction from your JSON log messages when you run a search. This allows you to view fields from JSON logs without having to manually specify parsing logic.

Dynamic parsing extracts JSON fields when you run a query, at search time (run time). Dynamic Parsing for JSON can be thought of as a Run Time FER. To use dynamic parsing you simply need a Run Time field extraction rule (FER) that tells Sumo which data sources to apply dynamic parsing. By default, your account is given one Run Time FER that encompasses all of your data.

Default Run Time FER.png

With this FER defined, any search on JSON data will automatically parse out its JSON fields, which you can then use within your search query, exactly like any other field.

You have a choice of two modes on the Search Page that allow you to control dynamic parsing. Dynamic Parsing is activated when a search is run in Auto Parse Mode, more details about the modes can be found in using dynamic parsing.

dynamic parsing mode options.png

Advantages of using dynamic parsing

  • Unlike Ingest Time FERs, where fields are persistent even when the FERs are edited or deleted, Run Time FERs and its corresponding parsed fields can be updated or removed at any given time. 
  • Dynamic parsing is helpful when your log schema changes frequently, like if fields are added or removed frequently, which is especially true for custom application logs. Sumo automatically detects the change in your schema and is able to adjust the output accordingly.
  • You won't run into any field extraction limits using Run Time FERs. Sumo can handle JSON data sources with hundreds of fields without any issue.

Set up dynamic parsing

By default, your account is configured with a Run Time FER that is applied to all of your data. The default Run Time FER named JSON Auto Parsing - All Sources can not be edited or deleted. With this FER configured, you don't have to set up anything to use dynamic parsing. However, having one FER applied to all of your data may not be optimal for your needs as it would be applied for every search query (including ones that may not query any JSON logs). Further details can be found in best practices for designing Rules.

To optimize search performance you can set up dynamic parsing manually by defining your own Run Time FERs and their scope.

Run Time FERs have a scope, exactly like an Ingest Time FER, that defines which searches are applicable to dynamic parsing Auto Parse Mode. For dynamic parsing to work your query needs to have a scope that is defined in a Run Time FER, otherwise Auto Parse Mode will not be applicable.

  1. Go to Manage Data > Settings > Field Extraction Rules.

  2. Click the + Add button on the top right of the table to create an FER.

  3. The following form appears:
    Create Field extraction rule with dynamic parsing.png

  4. Enter the following options:

    • Rule Name. Type a name that makes it easy to identify the rule.

    • Applied At. Select Run Time.

    • Scope. Select Specific Data and define the scope of your JSON data. You can define your JSON data source as a Partition Name(index), sourceCategory, Host Name, Collector Name, or any other metadata that describes your JSON data. Think of the Scope as the first portion of an ad hoc search, before the first pipe ( | ). You'll use the Scope to run a search against the rule. You cannot use keywords like “info” or “error” in your scope.

      Best Practices for setting up Scope
      Below are the recommended approaches to set up dynamic parsing of JSON:
      1. If you are not using Partitions we recommend using metadata fields like _sourceCategory, _sourceHost or _collector to define the scope.
      2. We recommend creating a separate Partition for your JSON dataset and use that Partition as the scope for run time field extraction. For example, let's say you have AWS Cloudtrail logs, and they are stored in _view=cloudtrail Partition in Sumo. You can create a Run Time FER with the scope _view=cloudtrail. Creating a separate Partition and using it as scope for a run time field extraction ensures that auto parsing logic only applies to necessary Partitions.
  5. Review your form inputs and when satisfied click Save.

Now that you have at least one Run Time FER created you can start querying your JSON data and the fields inside those JSON payloads will be automatically extracted.

Use dynamic parsing

While the Run Time FERs are set to run automatically, you can selectively choose to apply these to your search queries in the log search query page. To use dynamic parsing select Auto Parse Mode from the dropdown below the Time Range field, outlined in red in the screenshot below.

dynamic parsing mode options.png

The two modes available are:

  • Auto Parse Mode
    • Will parse out all fields detected in your JSON data source, irrespective of whether you are using them in your query or not.
    • Supported in dashboards and scheduled searches.
  • Manual Mode
    • Fields won't be parsed out automatically unless defined in an Ingest Time FER. Users have to manually specify further parsing logic.
    • This mode is for advanced users who are interested in the best performance and know how to parse out the fields they need.

Reference parsed JSON fields

Besides the standard methods of working with parsed fields, the field browser and search results messages table have a few improvements that are available with dynamic parsing. 

Field Browser:

  • A search input field allows you to search for fields by name.

        field browser search field.png
  • JSON structures are nested with expand and collapse options.

        Field browser expand collapse JSON.png
  • A copy button is available to the right of each field allowing you to easily copy a field name.

        field browser copy field.png

Search results table:

  • You can copy field names from JSON structures. After selecting (click and highlight) a JSON structure in the results table, right click and select Copy field name. See modifying a search from the messages tab for details on the other provided options.

    JSON right click copy options.png

    Copying a field name using this option will automatically format field names that have special characters. For example, the field name shown in the screenshot is total time-series, it would be automatically formatted to %"total time-series" to work properly in a search query.
     
  • A copy button is available to the right of each column (field) name allowing you to easily copy a field name.

    copy button messages table.png

Limitations

Limitations around the number of fields
  1. Dynamic parsing only extracts up to 100 fields per message. This 100 field count includes all built-in and parsed fields.
  2. Total fields shown in the field browser consist of all the fields extracted across log lines.
  3. The Field Browser displays the count of the fields as well as the distribution of values of each field. These calculations are only done for the first 200 fields that are parsed by a run-time FER.
Limitations around how dynamic parsing is applied
  1. Run Time FERs are only applied to logs that match the scope of the query. When a search query is run, it is first determined if any of the Run Time FERs match the scope of the query. Those Run Time FERs with a matching scope are applied. Run Time FERs are applied per log line only if the log contains a JSON element.

    For example, a Run Time FER with the scope: _sourcecategory = A

    • The query _sourcecategory = B is not applied since the scope does not overlap with the Run Time FER scope.
    • The query _sourcecategory = A or _sourcecategory = B is applied, only within the log lines that fall within _sourcecategory = A, while the remaining log lines are not parsed by this Run Time FER.
  2. If a field does not exist in the schema of the log message, null results will be displayed for the field (instead of erroring out).