Skip to content

Expose CloudWatch Logs Insights query statistics via API

0

I’m using the start_query and get_query_results APIs from Cloud Watch Logs Insights to run programmatic queries. While this works for fetching log results, it does not return important query statistics like:

  1. Total records matched

  2. Records scanned

  3. Bytes scanned

  4. Execution duration

  5. Throughput (records/s, kB/s)

    These are visible in the CloudWatch Console UI (e.g., "13,356 records matched, 11.1 MB scanned in 24.4s @ 752 records/s (466.3 kB/s)"), but they are not included in the API response from get_query_results.

Is there a supported way to retrieve these metrics programmatically? Any guidance or workaround would be appreciated.

1 Answer
0
Accepted Answer

The get_query_statistics API returns: recordsMatched: Number of records that matched your query recordsScanned: Total number of records scanned bytesScanned: Total bytes scanned You can calculate additional metrics like throughput. On console as well you will find these statistics only.

Reference. https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/logs/client/get_query_results.html

AWS

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.