Accepts a CloudWatchLogsConfig or plain options.
The underlying AWS SDK client (for operations this package does not wrap).
Flushes and closes every log client created by logClient, stops live-tail sessions and releases connections. Idempotent; never destroys a caller-supplied SDK client.
Deletes a log group with its streams and events. Returns false when missing and ignoreMissing.
Deletes a log stream. Returns false when missing and ignoreMissing.
Iterates log groups (sorted by name) across pages.
Iterates the log streams of a group across pages.
Lists recent Logs Insights queries (DescribeQueries).
Builds an Embedded Metric Format document (buildEmf) and sends it as one log event to
group/stream (defaults: config.logGroup / config.logStream). Returns the document sent.
Creates the log group when it is missing (CreateLogGroup), then applies retention and tags.
For an existing group the requested tags are added (never removed) and the retention is
re-applied; a different KMS key raises ConflictError.
Creates the log stream when it is missing. A missing group raises NotFoundError unless
createGroup is set.
A CloudWatchLogsExporter (the LogExporter behind logClient) writing to
group/stream (defaults config.logGroup / config.logStream). CONFIG when no group is
set, VALIDATION for invalid names.
Iterates events matching a filter pattern (FilterLogEvents) across pages until no token is
left (or limit). Within a page, events are ordered by timestamp, then event id.
One FilterLogEvents request. nextToken is undefined at the end; AWS may return empty
pages that still carry a token. Events are ordered by timestamp, then event id.
Iterates the events of one stream (GetLogEvents). startFromHead: true reads oldest → newest
(forward tokens); the default reads the newest page first and then older pages (backward
tokens; events inside a page stay in ascending order). Iteration stops when the
service returns the token that was sent.
Finds a log group by exact name (DescribeLogGroups with the name as prefix).
Reads the status and rows of a Logs Insights query (GetQueryResults).
Liveness via a signed DescribeLogGroups {limit: 1} without retries. Never throws for an
unhealthy or unreachable service (only CANCELLED and CONFIG). The service answering with an
authentication or permission error still counts as healthy (details.auth = "failed");
throttling reports degraded.
Tags of a log group (ListTagsForResource).
A BatchingLogClient that exports to group/stream (defaults config.logGroup /
config.logStream; the stream is created on first use). Records are sent as normalized
LogRecord JSON. close() of this client flushes it too.
ARN of a log group (without :*): built from config.accountId and the region when the
account is configured, otherwise looked up with DescribeLogGroups.
A CloudWatchLogsQueryClient over group (default config.logGroup).
Authenticated round trip (DescribeLogGroups {limit: 1}). Returns the latency in ms;
AuthenticationError on bad credentials, PermissionDeniedError without
logs:DescribeLogGroups.
Sends events with PutLogEvents. Events are sorted, oversized events are truncated / dropped /
rejected per oversizePolicy, and the events are split into batches that respect every service
limit (10 000 events, 1 MiB incl. 26 bytes per event, 24 h span). A missing stream is created
when autoCreate is on. Events the service rejects (too old/new, expired) are reported, never
retried. Throttling and 5xx are retried by the AWS SDK (a lost response may duplicate events).
Sets the retention (PutRetentionPolicy); null or 0 removes it (never expire).
Runs a Logs Insights query to completion: StartQuery, then polls GetQueryResults until a
terminal status. Failed/Unknown → UnavailableError, Timeout → TimeoutError,
Cancelled → CancelledError (message includes the query id). When timeoutMs passes or
the caller cancels, the query is stopped best-effort.
Always UnsupportedError: CloudWatch Logs exposes no server version (see API_VERSION).
Starts a Live Tail session (StartLiveTail) and calls onEvent for every event. Resolves once
the session has started (sessionStart), with a handle to stop it. On AWS the session streams
new events for up to 3 hours; the Moto emulator replays matching existing events once and ends.
Starts a Logs Insights query (StartQuery) and returns its id.
Stops a running query (StopQuery). Returns false when it had already finished.
Adds or overwrites tags of a log group (TagResource).
Removes tags from a log group (UntagResource).
StaticfromBuilds a client from GROW_AWS_CLOUDWATCH_LOGS_* and the standard AWS environment variables.
Client for Amazon CloudWatch Logs.