Skip to content

FilterLogEvents

Source: src/AWS/Logs/FilterLogEvents.ts

Runtime binding for logs:FilterLogEvents.

Bind this operation to a LogGroup inside a function runtime to get a callable that searches log events across all streams of the group, automatically injecting the log group name.

Search for a Marker

const filterLogEvents = yield* AWS.Logs.FilterLogEvents(logGroup);
const response = yield* filterLogEvents({
filterPattern: '"ERROR"',
limit: 100,
});

Wire into a Lambda Function

// Provide the FilterLogEventsHttp layer on the Function's init Effect.
export default SearchFunction.make(
{ main: import.meta.url, url: true },
Effect.gen(function* () {
const logGroup = yield* AWS.Logs.LogGroup("AppLogs", {});
const filterLogEvents = yield* AWS.Logs.FilterLogEvents(logGroup);
return {
fetch: Effect.gen(function* () {
const response = yield* filterLogEvents({ filterPattern: '"ERROR"' });
return HttpServerResponse.json({ events: response.events });
}),
};
}).pipe(Effect.provide(AWS.Logs.FilterLogEventsHttp)),
);