Skip to content

get_findings_statistics

get_findings_statistics(
    detector_id: DetectorId,
    *,
    config_overrides: Optional[GuardDutyClientConfig] = None,
    finding_statistic_types: Optional[FindingStatisticTypes] = None,
    finding_criteria: Optional[FindingCriteria] = None,
    group_by: Optional[GroupByType] = None,
    order_by: Optional[OrderBy] = None,
    max_results: Optional[MaxResults100] = None,
) -> GetFindingsStatisticsResponse

Lists GuardDuty findings statistics for the specified detector ID.

You must provide either findingStatisticTypes or groupBy parameter, and not both. You can use the maxResults and orderBy parameters only when using groupBy.

There might be regional differences because some flags might not be available in all the Regions where GuardDuty is currently supported. For more information, see Regions and endpoints.

Parameters:

  • detector_id (DetectorId) –

    The ID of the detector whose findings statistics you want to retrieve.

    To find the detectorId in the current Region, see the Settings page in the GuardDuty console, or run the ListDetectors API.

  • finding_statistic_types (Optional[FindingStatisticTypes], default: None ) –

    The types of finding statistics to retrieve.

  • finding_criteria (Optional[FindingCriteria], default: None ) –

    Represents the criteria that is used for querying findings.

  • group_by (Optional[GroupByType], default: None ) –

    Displays the findings statistics grouped by one of the listed valid values.

  • order_by (Optional[OrderBy], default: None ) –

    Displays the sorted findings in the requested order. The default value of orderBy is DESC.

    You can use this parameter only with the groupBy parameter.

  • max_results (Optional[MaxResults100], default: None ) –

    The maximum number of results to be returned in the response. The default value is 25.

    You can use this parameter only with the groupBy parameter.

Raises:

Source code in docs_src/capo_guardduty/_services/guard_duty.py
def get_findings_statistics(
    self,
    detector_id: "capo_guardduty.types.detector_id.DetectorId",
    *,
    config_overrides: Optional[GuardDutyClientConfig] = None,
    finding_statistic_types: Optional[
        "capo_guardduty.types.finding_statistic_types.FindingStatisticTypes"
    ] = None,
    finding_criteria: Optional[
        "capo_guardduty.types.finding_criteria.FindingCriteria"
    ] = None,
    group_by: Optional["capo_guardduty.types.group_by_type.GroupByType"] = None,
    order_by: Optional["capo_guardduty.types.order_by.OrderBy"] = None,
    max_results: Optional[
        "capo_guardduty.types.max_results100.MaxResults100"
    ] = None,
) -> "capo_guardduty.types.get_findings_statistics_response.GetFindingsStatisticsResponse":
    """<p>Lists GuardDuty findings statistics for the specified detector ID.</p> <p>You must provide either <code>findingStatisticTypes</code> or <code>groupBy</code> parameter, and not both. You can use the <code>maxResults</code> and <code>orderBy</code> parameters only when using <code>groupBy</code>.</p> <p>There might be regional differences because some flags might not be available in all the Regions where GuardDuty is currently supported. For more information, see <a href="https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_regions.html">Regions and endpoints</a>.</p>

    Args:
        detector_id: <p>The ID of the detector whose findings statistics you want to retrieve.</p> <p>To find the <code>detectorId</code> in the current Region, see the Settings page in the GuardDuty console, or run the <a href="https://docs.aws.amazon.com/guardduty/latest/APIReference/API_ListDetectors.html">ListDetectors</a> API.</p>
        finding_statistic_types: <p>The types of finding statistics to retrieve.</p>
        finding_criteria: <p>Represents the criteria that is used for querying findings.</p>
        group_by: <p>Displays the findings statistics grouped by one of the listed valid values.</p>
        order_by: <p>Displays the sorted findings in the requested order. The default value of <code>orderBy</code> is <code>DESC</code>.</p> <p>You can use this parameter only with the <code>groupBy</code> parameter.</p>
        max_results: <p>The maximum number of results to be returned in the response. The default value is 25.</p> <p>You can use this parameter only with the <code>groupBy</code> parameter.</p>

    Raises:
        capo_guardduty.errors.bad_request_exception.BadRequestException: <p>A bad request exception object.</p>
        capo_guardduty.errors.internal_server_error_exception.InternalServerErrorException: <p>An internal server error exception object.</p>
        capo_guardduty.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_guardduty.types.get_findings_statistics_request.GetFindingsStatisticsRequest]",
    ) -> OperationResponse[
        "capo_guardduty.types.get_findings_statistics_response.GetFindingsStatisticsResponse"
    ]:
        import capo_guardduty._operations.guard_duty_api_service.get_findings_statistics

        output, http_response = (
            capo_guardduty._operations.guard_duty_api_service.get_findings_statistics.get_findings_statistics(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetFindingsStatistics")
    )
    input_: capo_guardduty.types.get_findings_statistics_request.GetFindingsStatisticsRequest = {
        "detector_id": detector_id
    }
    if finding_statistic_types is not None:
        input_["finding_statistic_types"] = finding_statistic_types
    if finding_criteria is not None:
        input_["finding_criteria"] = finding_criteria
    if group_by is not None:
        input_["group_by"] = group_by
    if order_by is not None:
        input_["order_by"] = order_by
    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