---
title: Create a custom parser
description: Create a custom parser in the UI or in YAML to schematize a log source that no built-in Lakewatch parser covers, then attach and test it.
canonical_url: https://docs.databricks.com/aws/en/lakewatch/ingest-data/custom-logs/create-a-custom-parser
---

# Create a custom parser

> [!NOTE]
> **Beta**
>
> Lakewatch is in [Beta](https://docs.databricks.com/aws/en/release-notes/release-types.md). Workspace admins can control access to this feature from the **Previews** page. See [ Manage workspace-level previews](https://docs.databricks.com/aws/en/admin/workspace-settings/manage-previews.md#workspace).

Lakewatch has [built-in parsers](https://docs.databricks.com/aws/en/lakewatch/ingest-data/supported-logs/index.md) for common security log sources. Write a *custom parser* when you ingest a source that no built-in parser covers, or when you want to tailor the columns, validators, or observables a built-in parser produces.

A parser is a versioned specification that describes the output columns of a log source. You build it in the parser editor in either **UI** mode (a guided, point-and-click builder) or **YAML** mode, and it's created in your current Lakewatch [environment](https://docs.databricks.com/aws/en/lakewatch/admin/access-control/access-control-model.md#environments-and-folders). For the full syntax (field attributes, types, timestamps, validators, and observables), see the [Parser reference](https://docs.databricks.com/aws/en/lakewatch/ingest-data/custom-logs/parser-reference.md).

## Open the parser editor

From the Lakewatch sidebar, select **Parsers**, then select **Create parser**. The parser list also shows every built-in and custom parser in your environment, with its type, attached datasources, and latest version.

To start from a built-in parser instead of a blank one, find it in the list, open its ![Kebab menu icon.](https://docs.databricks.com/aws/en/images/product-icons/OverflowIcon.svg) kebab menu, and select **Clone**. Cloning copies the definition into a new, editable custom parser (version 1) and leaves the built-in parser unchanged.

## Define the parser

On the **Add new parser** page, give the parser a **Parser name** and an optional **Description**. The name can't contain spaces, periods, or forward slashes, and no other parser in the default datasource folder can have the same name.

Build the output columns under **Fields & Observables**, in either **UI** or **YAML** mode. You can switch between them at any time.

### Choose sample data

To base the fields on real data, select **Choose sample data** and then the raw records this parser is for. You can sample from a **Datasource**, **External location**, **Volume**, or **Table**.

With sample data chosen, optionally select **Build parser with Genie**: Genie reads the sample and drafts the event time and fields for you to review and adjust.

Inference needs a SQL warehouse selected in the top bar and access to the sample files. If inference fails, Lakewatch shows **Inference failed or timed out. Check storage access and your warehouse, retry with a narrower folder, or set input options manually.**

If you sample a broad location, the preview shows **This root may contain many files or different formats. Choose a narrower prefix when possible. A small preview does not limit how many files must be discovered.** A broad location can take longer to preview.

### Set the event time and fields

* **Event time** (required): The timestamp of each event. Every parser needs one before it can be saved. In YAML, this is the top-level `time` block (not a field), because it drives clustering and query performance. See [Event time](https://docs.databricks.com/aws/en/lakewatch/ingest-data/custom-logs/parser-reference.md#event-time).
* **Fields**: The columns of the parsed table and where each one is read from. For each field, set `name`, `type`, and (when the source key differs from the column name) `path`; mark fields that must be present with `required: true`; add `validate` to constrain a `STRING` field, and `observables` to extract values (such as `ip` or `email`) into the shared `lw_observables` column. Express nested objects as `VARIANT` with inner `fields`, and lists as `ARRAY` with an `element`.

Define your fields carefully. During [classification](https://docs.databricks.com/aws/en/lakewatch/ingest-data/custom-logs/parser-reference.md#classification), an event matches only when its required fields are present, its typed fields convert to the declared types, and all validators pass. An event that matches no attached parser isn't written to any parsed table, but the pipeline doesn't fail. The datasource counts these events under **Unmatched rows**, and Lakewatch raises a [system error](https://docs.databricks.com/aws/en/lakewatch/system-health/system-errors.md) for each run that drops events.

### Preview and save

In the **Data preview** pane, select **Preview** to run the parser against your sample data and confirm the columns, types, and extracted observables are what you expect. When it looks right, select **Save**. Saving stores the definition as version 1, records you as its owner, and creates the parser in your current environment. A parser document is at most 256 KiB.

## Attach the parser to a datasource

Attach the custom parser to a datasource the same way you attach a built-in parser. You can attach more than one parser to a datasource; incoming events are matched in declaration order and land in the first parser they match. See [Parsers](https://docs.databricks.com/aws/en/lakewatch/ingest-data/datasources/index.md#parsers).

## Test and iterate

After the datasource runs, confirm the parser behaves as expected:

* Query the parsed table to verify the columns, types, and extracted observables match what you defined.
* Check **Unmatched rows** on the datasource's **Parsers** tab. An event is unmatched when it doesn't match any attached parser: usually because a `required` field is missing, a value doesn't convert to its declared type, or a validator fails.

To refine the parser, edit it and save. You must own the parser or have the `MANAGE` privilege on its folder. Editing appends a new immutable version; earlier versions are never changed and version numbers are never reused. A new version keeps the parser's name and changes only the definition. A datasource pins a specific version, so update the datasource to pick up your new version. See [Change parsers on a datasource](https://docs.databricks.com/aws/en/lakewatch/ingest-data/datasources/index.md#change-parsers-on-a-datasource). If the new version changes which events the parser matches, the datasource reprocesses recent raw data, which can produce duplicate rows. Otherwise, existing parsed data isn't reprocessed, and the new version applies to events ingested after you save the change.

## Additional resources

* [Parser reference](https://docs.databricks.com/aws/en/lakewatch/ingest-data/custom-logs/parser-reference.md): the complete YAML syntax
* [Create and manage datasources](https://docs.databricks.com/aws/en/lakewatch/ingest-data/datasources/index.md): attach, change, and manage parsers on a datasource
* [Supported logs](https://docs.databricks.com/aws/en/lakewatch/ingest-data/supported-logs/index.md): the sources covered by built-in parsers
