Class CloudWatchLogsQueryClient
java.lang.Object
codes.grow.packages.cloudwatchlogs.CloudWatchLogsQueryClient
- All Implemented Interfaces:
LogQueryClient
LogQueryClient over one log group (SPEC section 4, DECISIONS 2). search uses
FilterLogEvents: SortOrder.ASC reads natively (oldest first, cursor = the service
token); SortOrder.DESC (default) walks the time window backwards in slices (5 minutes,
each 4 times wider), from one hour before the group's creation time (else 30 days), newest slice
first, and sorts each slice newest first. tail uses Live Tail; listStreams uses
DescribeLogStreams; listLabels is unsupported (no label inventory).-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringAttribute holding the event id of a record.static final StringAttribute holding the log group of a plain live-tail record.static final StringAttribute holding the log stream of a record.static final longLook-back of a descending search without start when the creation time is unknown (30 d).static final intLargest page size ofsearch.static final longFirst time slice of a descending search (5 minutes); each further slice is 4 times wider.static final longLargest time slice of a descending search (30 days).static final intEvents read per slice before the slice is narrowed (newest half kept). -
Method Summary
Modifier and TypeMethodDescriptionstatic LogRecordConverts aFilterLogEventsevent to a record (seemessageToRecord(java.lang.String, java.time.Instant, java.time.Instant)) with the attributesaws.log.streamandaws.event.id.static StringfilterPattern(String query) Converts a search query to a CloudWatch filter pattern: empty matches everything; a query that starts with{,?group()Returns the log group searched.Always throws: CloudWatch Logs has no label inventory.Names of the streams of the group (DescribeLogStreams, all pages).static LogRecordConverts a live-tail event to a record (seemessageToRecord(java.lang.String, java.time.Instant, java.time.Instant)) with the attributeaws.log.streamand, for plain messages,aws.log.group.static LogRecordmessageToRecord(String message, Instant timestamp, Instant ingestionTime) Normalizes a CloudWatch message: a normalized LogRecord JSON document (withtimestampandbody) is decoded; any other message becomes an INFO record with the message as body,timestampas time andingestionTimeas observed time.search(String query, SearchOptions options) Searches records matching a service query (full text or the service's query language).tail(String query, Consumer<LogRecord> onRecord, TailOptions options) Streams records with Live Tail (filter pattern built likesearch(java.lang.String, codes.grow.packages.cloudwatchlogs.logging.SearchOptions)).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface codes.grow.packages.cloudwatchlogs.logging.LogQueryClient
listLabelsAsync, listStreamsAsync, search, searchAsync, waitForLog, waitForLog, waitForLogAsync
-
Field Details
-
ATTR_LOG_STREAM
Attribute holding the log stream of a record.- See Also:
-
ATTR_EVENT_ID
Attribute holding the event id of a record.- See Also:
-
ATTR_LOG_GROUP
Attribute holding the log group of a plain live-tail record.- See Also:
-
DEFAULT_SEARCH_LOOKBACK_MS
public static final long DEFAULT_SEARCH_LOOKBACK_MSLook-back of a descending search without start when the creation time is unknown (30 d).- See Also:
-
SEARCH_FIRST_SLICE_MS
public static final long SEARCH_FIRST_SLICE_MSFirst time slice of a descending search (5 minutes); each further slice is 4 times wider.- See Also:
-
SEARCH_MAX_SLICE_MS
public static final long SEARCH_MAX_SLICE_MSLargest time slice of a descending search (30 days).- See Also:
-
SEARCH_SCAN_CAP
public static final int SEARCH_SCAN_CAPEvents read per slice before the slice is narrowed (newest half kept).- See Also:
-
MAX_SEARCH_LIMIT
public static final int MAX_SEARCH_LIMITLargest page size ofsearch.- See Also:
-
-
Method Details
-
group
Returns the log group searched.- Returns:
- the group
-
filterPattern
Converts a search query to a CloudWatch filter pattern: empty matches everything; a query that starts with{,?,[,-or"is passed through as a native pattern; anything else becomes an exact phrase ("…", inner quotes escaped).- Parameters:
query- the query- Returns:
- the filter pattern
-
messageToRecord
Normalizes a CloudWatch message: a normalized LogRecord JSON document (withtimestampandbody) is decoded; any other message becomes an INFO record with the message as body,timestampas time andingestionTimeas observed time.- Parameters:
message- the messagetimestamp- event timeingestionTime- ingestion time, may be null- Returns:
- the record
-
filteredEventToRecord
Converts aFilterLogEventsevent to a record (seemessageToRecord(java.lang.String, java.time.Instant, java.time.Instant)) with the attributesaws.log.streamandaws.event.id.- Parameters:
e- the event- Returns:
- the record
-
liveTailEventToRecord
Converts a live-tail event to a record (seemessageToRecord(java.lang.String, java.time.Instant, java.time.Instant)) with the attributeaws.log.streamand, for plain messages,aws.log.group.- Parameters:
e- the event- Returns:
- the record
-
search
Description copied from interface:LogQueryClientSearches records matching a service query (full text or the service's query language).- Specified by:
searchin interfaceLogQueryClient- Parameters:
query- query textoptions- range, limit, order, cursor- Returns:
- one page of records
-
tail
Streams records with Live Tail (filter pattern built likesearch(java.lang.String, codes.grow.packages.cloudwatchlogs.logging.SearchOptions)). Errors and the end of the session are reported tooptions.onError;startandintervaldo not apply (the service pushes events).- Specified by:
tailin interfaceLogQueryClient- Parameters:
query- search queryonRecord- called for every recordoptions- error callback- Returns:
- a handle that stops the session
-
listStreams
Names of the streams of the group (DescribeLogStreams, all pages).- Specified by:
listStreamsin interfaceLogQueryClient- Returns:
- the stream names
-
listLabels
Always throws: CloudWatch Logs has no label inventory.- Specified by:
listLabelsin interfaceLogQueryClient- Returns:
- never returns
- Throws:
UnsupportedException- always
-