# QueryStringProps

Properties for a QueryString.

Extends: QueryStringProps
Used as props by: QueryString

- Source: [`aws-logs/lib/query-definition.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-logs/lib/query-definition.ts#L12)
- Type last changed: v2.208.0 · 29 Jul 2025

## Example

```ts
new logs.QueryDefinition(this, 'QueryDefinition', {
  queryDefinitionName: 'MyQuery',
  queryString: new logs.QueryString({
    fields: ['@timestamp', '@message'],
    parseStatements: [
      '@message "[*] *" as loggingType, loggingMessage',
      '@message "<*>: *" as differentLoggingType, differentLoggingMessage',
    ],
    filterStatements: [
      'loggingType = "ERROR"',
      'loggingMessage = "A very strange error occurred!"',
    ],
    statsStatements: [
      'count(loggingMessage) as loggingErrors',
      'count(differentLoggingMessage) as differentLoggingErrors',
    ],
    sort: '@timestamp desc',
    limit: 20,
  }),
});
```

## Properties

- `display`: string — Specifies which fields to display in the query results.

  **Default:** no display in QueryString

- `fields`: string[] — Retrieves the specified fields from log events for display.

  **Default:** no fields in QueryString

- `filter`: string — Use `filterStatements` instead

  **Default:** no filter in QueryString

- `filterStatements`: string[] — An array of one or more statements for filtering the results of a query based on a boolean expression.

  **Default:** no filter in QueryString

  Each provided statement generates a separate filter line in the query string.

  Note: If provided, this property overrides any value provided for the `filter` property.

- `limit`: number — Specifies the number of log events returned by the query.

  **Default:** no limit in QueryString

- `parse`: string — Use `parseStatements` instead

  **Default:** no parse in QueryString

- `parseStatements`: string[] — An array of one or more statements for parsing data from a log field and creating ephemeral fields that can be processed further in the query.

  **Default:** no parse in QueryString

  Each provided statement generates a separate
  parse line in the query string.

  Note: If provided, this property overrides any value provided for the `parse` property.

- `sort`: string — Sorts the retrieved log events.

  **Default:** no sort in QueryString

- `stats`: string — Use `statsStatements` instead

  **Default:** no stats in QueryString

- `statsStatements`: string[] — An array of one or more statements for calculating aggregate statistics.

  **Default:** no stats in QueryString

  CloudWatch Logs Insights supports up to two stats commands in a single query.
  Each provided statement generates a separate stats line in the query string.

  Note: If provided, this property overrides any value provided for the `stats` property.
