Skip to content

list_log_groups_for_query

list_log_groups_for_query(
    query_id: QueryId,
    *,
    config_overrides: Optional[CloudWatchLogsClientConfig] = None,
    next_token: Optional[NextToken] = None,
    max_results: Optional[ListLogGroupsForQueryMaxResults] = None,
) -> ListLogGroupsForQueryResponse

Returns a list of the log groups that were analyzed during a single CloudWatch Logs Insights query. This can be useful for queries that use log group name prefixes or the filterIndex command, because the log groups are dynamically selected in these cases.

For more information about field indexes, see Create field indexes to improve query performance and reduce costs.

Parameters:

Raises:

Source code in docs_src/capo_cloudwatch_logs/_services/cloud_watch_logs.py
def list_log_groups_for_query(
    self,
    query_id: "capo_cloudwatch_logs.types.query_id.QueryId",
    *,
    config_overrides: Optional[CloudWatchLogsClientConfig] = None,
    next_token: Optional["capo_cloudwatch_logs.types.next_token.NextToken"] = None,
    max_results: Optional[
        "capo_cloudwatch_logs.types.list_log_groups_for_query_max_results.ListLogGroupsForQueryMaxResults"
    ] = None,
) -> "capo_cloudwatch_logs.types.list_log_groups_for_query_response.ListLogGroupsForQueryResponse":
    """<p>Returns a list of the log groups that were analyzed during a single CloudWatch Logs Insights query. This can be useful for queries that use log group name prefixes or the <code>filterIndex</code> command, because the log groups are dynamically selected in these cases.</p> <p>For more information about field indexes, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CloudWatchLogs-Field-Indexing.html">Create field indexes to improve query performance and reduce costs</a>.</p>

    Args:
        query_id: <p>The ID of the query to use. This query ID is from the response to your <a href="https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_StartQuery.html">StartQuery</a> operation.</p>
        max_results: <p>Limits the number of returned log groups to the specified number.</p>

    Raises:
        capo_cloudwatch_logs.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient permissions to perform this action.</p>
        capo_cloudwatch_logs.errors.invalid_parameter_exception.InvalidParameterException: <p>A parameter is specified incorrectly.</p>
        capo_cloudwatch_logs.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
        capo_cloudwatch_logs.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service cannot complete the request.</p>
        capo_cloudwatch_logs.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_cloudwatch_logs.types.list_log_groups_for_query_request.ListLogGroupsForQueryRequest]",
    ) -> OperationResponse[
        "capo_cloudwatch_logs.types.list_log_groups_for_query_response.ListLogGroupsForQueryResponse"
    ]:
        import capo_cloudwatch_logs._operations.logs_20140328.list_log_groups_for_query

        output, http_response = (
            capo_cloudwatch_logs._operations.logs_20140328.list_log_groups_for_query.list_log_groups_for_query(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListLogGroupsForQuery")
    )
    input_: capo_cloudwatch_logs.types.list_log_groups_for_query_request.ListLogGroupsForQueryRequest = {
        "query_id": query_id
    }
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output