# New Records Returned by CloudWatch Logs Insights Query — AWS

> Executes a CloudWatch Logs Insights query on a schedule, and emits the records as invidual events (default) or in batch

- Key: `aws-new-records-returned-by-cloudwatch-logs-insights-query`
- Type: Trigger (Polling)
- Version: 0.2.3
- App: AWS (`aws`) — https://pipedream.com/apps/aws.md
- This page (HTML): https://pipedream.com/apps/aws/triggers/new-records-returned-by-cloudwatch-logs-insights-query
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/aws/sources/new-records-returned-by-cloudwatch-logs-insights-query/new-records-returned-by-cloudwatch-logs-insights-query.mjs

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `region` | `string` | Yes | The AWS region Options are loaded from the connected account. |
| `logGroupNames` | `string[]` | Yes | The log groups you'd like to query Options are loaded from the connected account. |
| `queryString` | `string` | Yes | The query you'd like to run. See this AWS doc for help with query syntax |
| `emitResultsInBatch` | `boolean` | No | If true, all events are emitted as an array, within a single Pipedream event. If false, each row of results is emitted as its own event. Defaults to true |
| `timer` | `$.interface.timer` | Yes | How often you want to query CloudWatch Logs Insights for results |

## Returns

Events emitted by AWS.

## Run it

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const deployed = await pd.triggers.deploy({
  id: "aws-new-records-returned-by-cloudwatch-logs-insights-query",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    aws: { authProvisionId: "apn_xxxxxxx" },
    region: "AWS Region",
    logGroupNames: ["CloudWatch Log Groups"],
  },
  webhookUrl: "https://example.com/webhooks/aws",
})

console.log(deployed.id)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/triggers/deploy \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "aws-new-records-returned-by-cloudwatch-logs-insights-query",
    "webhook_url": "https://example.com/webhooks/aws",
    "configured_props": {
      "aws": { "authProvisionId": "apn_xxxxxxx" },
      "region": "AWS Region",
      "logGroupNames": ["CloudWatch Log Groups"]
    }
  }'
```

**MCP**

MCP servers expose AWS actions as on-demand tools.

New Records Returned by CloudWatch Logs Insights Query is an event source, so your application deploys it with the Connect SDK or API and then either receives each event at a webhook URL or retrieves events on demand with the trigger events API.

## Event delivery

Every event is sent to the HTTP endpoint you choose when you deploy the source. Or: no webhook required — your app or agent can fetch recent events from the [trigger events API](https://pipedream.com/docs/connect/api-reference/list-trigger-events.md) instead.

---

- App: https://pipedream.com/apps/aws.md · All apps: https://pipedream.com/apps
