@grow-codes/aws-cloudwatch-logs - v0.1.1
    Preparing search index...

    Class CloudWatchLogsClient

    Client for Amazon CloudWatch Logs.

    Index

    The immutable configuration.

    • get sdk(): CloudWatchLogsClient

      The underlying AWS SDK client (for operations this package does not wrap).

      Returns CloudWatchLogsClient

    • Flushes and closes every log client created by logClient, stops live-tail sessions and releases connections. Idempotent; never destroys a caller-supplied SDK client.

      Returns Promise<void>

    • Deletes a log group with its streams and events. Returns false when missing and ignoreMissing.

      Parameters

      Returns Promise<boolean>

    • Deletes a log stream. Returns false when missing and ignoreMissing.

      Parameters

      Returns Promise<boolean>

    • 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.

      Parameters

      • metric: string
      • value: number | readonly number[]
      • dimensions: Readonly<Record<string, string>> = {}
      • options: EmfSendOptions = {}

      Returns Promise<Record<string, unknown>>

    • Creates the log stream when it is missing. A missing group raises NotFoundError unless createGroup is set.

      Parameters

      Returns Promise<{ created: boolean }>

    • 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.

      Parameters

      Returns Promise<{ events: FilteredLogEvent[]; nextToken?: string }>

    • 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.

      Parameters

      Returns AsyncGenerator<StreamLogEvent>

    • 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.

      Parameters

      Returns Promise<HealthStatus>

    • Tags of a log group (ListTagsForResource).

      Parameters

      Returns Promise<Record<string, string>>

    • ARN of a log group (without :*): built from config.accountId and the region when the account is configured, otherwise looked up with DescribeLogGroups.

      Parameters

      Returns Promise<string>

    • Authenticated round trip (DescribeLogGroups {limit: 1}). Returns the latency in ms; AuthenticationError on bad credentials, PermissionDeniedError without logs:DescribeLogGroups.

      Parameters

      Returns Promise<number>

    • 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).

      Parameters

      Returns Promise<PutLogEventsResult>

    • Sets the retention (PutRetentionPolicy); null or 0 removes it (never expire).

      Parameters

      • group: string
      • days: number | null
      • options: CallOptions = {}

      Returns Promise<void>

    • 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.

      Parameters

      Returns Promise<QueryResults>

    • Always UnsupportedError: CloudWatch Logs exposes no server version (see API_VERSION).

      Parameters

      Returns Promise<string>

    • Stops a running query (StopQuery). Returns false when it had already finished.

      Parameters

      Returns Promise<boolean>

    • Adds or overwrites tags of a log group (TagResource).

      Parameters

      • name: string
      • tags: Record<string, string>
      • options: CallOptions = {}

      Returns Promise<void>

    • Removes tags from a log group (UntagResource).

      Parameters

      • name: string
      • keys: readonly string[]
      • options: CallOptions = {}

      Returns Promise<void>