GetQueryResults
Source:
src/AWS/Logs/GetQueryResults.ts
Runtime binding for logs:GetQueryResults (CloudWatch Logs Insights).
Bind this operation to the LogGroup an Insights query was started against
(via StartQuery) to poll for its results.
Logs Insights
Section titled “Logs Insights”Poll Query Results
const getQueryResults = yield* AWS.Logs.GetQueryResults(logGroup);
const response = yield* getQueryResults({ queryId });if (response.status === "Complete") { // response.results is an array of field/value rows}Poll Until Complete
// Bounded, declarative polling — never a while-loop.const results = yield* getQueryResults({ queryId }).pipe( Effect.repeat({ schedule: Schedule.spaced("2 seconds"), until: (r) => r.status === "Complete", times: 15, }),);Wire into a Lambda Function
// Provide the layer on the Function's init Effect, merged with// StartQueryHttp since the two bindings are always used together.export default InsightsFunction.make( { main: import.meta.url, url: true }, Effect.gen(function* () { const logGroup = yield* AWS.Logs.LogGroup("AppLogs", {}); const startQuery = yield* AWS.Logs.StartQuery(logGroup); const getQueryResults = yield* AWS.Logs.GetQueryResults(logGroup); // ... start the query and poll for results in the fetch handler return { fetch: handler }; }).pipe( Effect.provide( Layer.mergeAll(AWS.Logs.StartQueryHttp, AWS.Logs.GetQueryResultsHttp), ), ),);