| 1 | import type * as Logs from "@distilled.cloud/aws/cloudwatch-logs"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { LogGroup } from "./LogGroup.ts"; |
| 5 | |
| 6 | export interface GetLogGroupFieldsRequest extends Omit< |
| 7 | Logs.GetLogGroupFieldsRequest, |
| 8 | "logGroupName" | "logGroupIdentifier" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `logs:GetLogGroupFields` (CloudWatch Logs Insights). |
| 13 | * |
| 14 | * Bind this operation to a `LogGroup` inside a function runtime to discover |
| 15 | * the fields present in the group's recent log events (and the percentage of |
| 16 | * events each field appears in), automatically injecting the log group name. |
| 17 | * Useful for building Insights queries dynamically. |
| 18 | * ### Logs Insights |
| 19 | * **Example:** Discover Fields in a Log Group |
| 20 | * ```typescript |
| 21 | * const getLogGroupFields = yield* AWS.Logs.GetLogGroupFields(logGroup); |
| 22 | * |
| 23 | * const { logGroupFields } = yield* getLogGroupFields(); |
| 24 | * // e.g. [{ name: "@timestamp", percent: 100 }, { name: "@message", ... }] |
| 25 | * ``` |
| 26 | * |
| 27 | * @binding |
| 28 | */ |
| 29 | export interface GetLogGroupFields extends Binding.Service< |
| 30 | GetLogGroupFields, |
| 31 | "AWS.Logs.GetLogGroupFields", |
| 32 | <G extends LogGroup>( |
| 33 | logGroup: G, |
| 34 | ) => Effect.Effect< |
| 35 | ( |
| 36 | request?: GetLogGroupFieldsRequest, |
| 37 | ) => Effect.Effect< |
| 38 | Logs.GetLogGroupFieldsResponse, |
| 39 | Logs.GetLogGroupFieldsError |
| 40 | > |
| 41 | > |
| 42 | > {} |
| 43 | export const GetLogGroupFields = Binding.Service<GetLogGroupFields>( |
| 44 | "AWS.Logs.GetLogGroupFields", |
| 45 | ); |