View parsers
Select from the following methods to view and order available parsers. Parsers display in match order.- Web
- Chronoctl
- Terraform
- API
To view parsers:
- In the navigation menu, click Go to Admin and then select Control > Logs Parsing and Mapping. All parsers display, including plain-text and field parsers.
- To view the code definition for all configured parsers, click the Code Config tab.
Create parsers
Parsers operate on both plain-text logs and individual fields. All configured parsers are included in a single definition, and evaluated in match order. Observability Platform applies the first parser in the definition that matches a log, and ignores any subsequent parsers. Although you can define parsers in the Observability Platform web interface, you must use the Code Config tool to apply the definition.Create plain-text parsers
Plain text parsers run against all ingested logs with theplaintext mimetype, and
apply parsing logic to modify the original record. These parsers affect the entire
log. Use field parsers to operate on individual fields within a log.
Select either a regular expression or a key/value matching pattern to parse logs.
When using a key/value pattern, you can extract any number of key value pairs from a
plain text log. Plain text parsers also have an option to keep the original log after
applying parsing logic.
Plain text parsers apply only when the media type is set to plaintext for logs.
Regular expressions for the matching type use
RE2 syntax and named capture
groups. Each named capture group becomes the key name in the structured log.
Observability Platform requires at least one named capture group in the regular
expression.
Use one of the following methods to create plain text parsers.
- Web
- Chronoctl
- Terraform
- API
Define the plain text parser definition in Observability Platform, and then
use the Code Config tool to apply the definition.
- In the navigation menu, click Go to Admin and then select Control > Logs Parsing and Mapping.
- In the Plaintext Parsers section, click Create plaintext parser.
- Enter a name for the parser.
- Select the matching type for the parser:
- REGEX: Use a regular expression to match logs. In the Template field, select the regular expression template to apply to your logs. Use a predefined template such as Nginx, or specify a Custom template.
- Key/value: Use a specified pattern to separate key/value pairs in log data.
Enter the following values:
- Pair separator: Specifies the character used to split matching pairs into
its key and value. For example, a colon (
:) if your data is in the formatkey: value. - Delimiter: Specifies the character used to split the input log data into
key/value pairs. For example, a comma (
,) if your data is in the formatkey: value, key: value. - Trim set: Identifies the leading and trailing characters to trim from the
key/value pairs. For example, a space (
" ") between key/value pairs if your data is in the formatkey: value, key: value.
- Pair separator: Specifies the character used to split matching pairs into
its key and value. For example, a colon (
- If you want to keep the original log after parsing, select the corresponding checkbox.
- Click Save to save the parser definition.
- On the Logs Parsing and Mapping page, click View code config.
- In the Code Config tab, use the Code Config tool to apply the definition.
Create field parsers
Field parsers operate on an individual field within a log, and run on all ingested logs, including JSON and plain text logs. Field parsers run after plain text parsers. When defining a field parser, choose which matching pattern to apply and specify the destination of the parsed field.- Web
- Chronoctl
- Terraform
- API
Define the field parser definition in Observability Platform, and then
use the Code Config tool to apply the
definition.
- In the navigation menu, click Go to Admin and then select Control > Logs Parsing and Mapping.
- In the Field Parsers section, click Create field parser.
-
Enter a source field for the parser to operate on, such as
message. -
Enter a destination for the parsed data, which can be one of these locations:
- Use the same field name, which overwrites the existing field data with the parsed data.
- Specify a new field name to contain the parsed data.
- Leave the destination field empty, which populates the parsed data to the top level of your logs.
-
Select the matching type for the parser.
- JSON matches on valid JSON logs.
- REGEX uses a regular expression to match logs. In the Template field, select the regular expression template to apply to your logs. Use a predefined template such as Nginx, or specify a Custom template.
- Key/value uses a specified pattern to separate key/value pairs in log data.
Enter the following values:
- Pair separator is the character used to split matching pairs into its key
and value. For example, a colon (
:) if your data is in the formatkey:value. - Delimiter is the character used to split the input log data into key/value
pairs. For example, a comma (
,) if your data is in the formatkey: value, key: value. - Trim set identifies the leading and trailing characters to trim from the
key/value pairs. For example, a space (
" ") between key/value pairs if your data is in the formatkey: value, key: value.
- Pair separator is the character used to split matching pairs into its key
and value. For example, a colon (
- Click Save to save the parser definition.
- On the Logs Parsing and Mapping page, click View code config.
- In the Code Config tab, use the Code Config tool to apply the definition.
Edit parsers
When creating or editing a parser, you can use the Code Config tool to view code representations of a parser. The displayed code also responds to changes you make in the Visual editor tab. Select from the following methods to edit parsers.- Web
- Chronoctl
- Terraform
- API
- In the navigation menu, click Go to Admin and then select Control > Logs Parsing and Mapping.
- In the row of the parser you want to edit, click the three vertical dots icon and then click Edit parser.
- In the Edit parser drawer, make changes to your parser, and then click Save.
Delete parsers
Select from the following methods to delete parsers.- Web
- Chronoctl
- Terraform
- API
- In the navigation menu, click Go to Admin and then select Control > Logs Parsing and Mapping.
- In the row of the parser you want to edit, click the three vertical dots icon and then click Delete parser.
Examples
The following example shows how to apply both plain text and field parsers to create structured output from an unstructured log record. Consider the following input log data. The record is a single string that contains multiple key/value pairs in a singlemessage field. In this state, querying the data is
difficult, and you can’t complete aggregations or transformations.
metadata field, and
is structured as shown in the following example. The new field includes key/value
pairs that can be queried in Logs Explorer and
used in aggregations and transformations.