Skip to content

get_bucket_metric_data async

get_bucket_metric_data(
    bucket_name: BucketName,
    metric_name: BucketMetricName,
    start_time: IsoDate,
    end_time: IsoDate,
    period: MetricPeriod,
    statistics: MetricStatisticList,
    unit: MetricUnit,
    *,
    config_overrides: Optional[AsyncLightsailClientConfig] = None,
) -> GetBucketMetricDataResult

Returns the data points of a specific metric for an Amazon Lightsail bucket.

Metrics report the utilization of a bucket. View and collect metric data regularly to monitor the number of objects stored in a bucket (including object versions) and the storage space used by those objects.

Parameters:

  • bucket_name (BucketName) –

    The name of the bucket for which to get metric data.

  • metric_name (BucketMetricName) –

    The metric for which you want to return information.

    Valid bucket metric names are listed below, along with the most useful statistics to include in your request, and the published unit value.

    These bucket metrics are reported once per day.

    • BucketSizeBytes - The amount of data in bytes stored in a bucket. This value is calculated by summing the size of all objects in the bucket (including object versions), including the size of all parts for all incomplete multipart uploads to the bucket.

      Statistics: The most useful statistic is Maximum.

      Unit: The published unit is Bytes.

    • NumberOfObjects - The total number of objects stored in a bucket. This value is calculated by counting all objects in the bucket (including object versions) and the total number of parts for all incomplete multipart uploads to the bucket.

      Statistics: The most useful statistic is Average.

      Unit: The published unit is Count.

  • start_time (IsoDate) –

    The timestamp indicating the earliest data to be returned.

  • end_time (IsoDate) –

    The timestamp indicating the latest data to be returned.

  • period (MetricPeriod) –

    The granularity, in seconds, of the returned data points.

    Bucket storage metrics are reported once per day. Therefore, you should specify a period of 86400 seconds, which is the number of seconds in a day.

  • statistics (MetricStatisticList) –

    The statistic for the metric.

    The following statistics are available:

    • Minimum - The lowest value observed during the specified period. Use this value to determine low volumes of activity for your application.

    • Maximum - The highest value observed during the specified period. Use this value to determine high volumes of activity for your application.

    • Sum - The sum of all values submitted for the matching metric. You can use this statistic to determine the total volume of a metric.

    • Average - The value of Sum / SampleCount during the specified period. By comparing this statistic with the Minimum and Maximum values, you can determine the full scope of a metric and how close the average use is to the Minimum and Maximum values. This comparison helps you to know when to increase or decrease your resources.

    • SampleCount - The count, or number, of data points used for the statistical calculation.

  • unit (MetricUnit) –

    The unit for the metric data request.

    Valid units depend on the metric data being requested. For the valid units with each available metric, see the metricName parameter.

Raises:

  • AccessDeniedException –

    Lightsail throws this exception when the user cannot be authenticated or uses invalid credentials to access a resource.

  • InvalidInputException –

    Lightsail throws this exception when user input does not conform to the validation rules of an input field.

    Domain and distribution APIs are only available in the N. Virginia (us-east-1) Amazon Web Services Region. Please set your Amazon Web Services Region configuration to us-east-1 to create, view, or edit these resources.

  • NotFoundException –

    Lightsail throws this exception when it cannot find a resource.

  • RegionSetupInProgressException –

    Lightsail throws this exception when an operation is performed on resources in an opt-in Region that is currently being set up.

  • ServiceException –

    A general service exception.

  • UnauthenticatedException –

    Lightsail throws this exception when the user has not been authenticated.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_lightsail/_services/async_lightsail.py
async def get_bucket_metric_data(
    self,
    bucket_name: "capo_lightsail.types.bucket_name.BucketName",
    metric_name: "capo_lightsail.types.bucket_metric_name.BucketMetricName",
    start_time: "capo_lightsail.types.iso_date.IsoDate",
    end_time: "capo_lightsail.types.iso_date.IsoDate",
    period: "capo_lightsail.types.metric_period.MetricPeriod",
    statistics: "capo_lightsail.types.metric_statistic_list.MetricStatisticList",
    unit: "capo_lightsail.types.metric_unit.MetricUnit",
    *,
    config_overrides: Optional[AsyncLightsailClientConfig] = None,
) -> "capo_lightsail.types.get_bucket_metric_data_result.GetBucketMetricDataResult":
    """<p>Returns the data points of a specific metric for an Amazon Lightsail bucket.</p> <p>Metrics report the utilization of a bucket. View and collect metric data regularly to monitor the number of objects stored in a bucket (including object versions) and the storage space used by those objects.</p>

    Args:
        bucket_name: <p>The name of the bucket for which to get metric data.</p>
        metric_name: <p>The metric for which you want to return information.</p> <p>Valid bucket metric names are listed below, along with the most useful statistics to include in your request, and the published unit value.</p> <note> <p>These bucket metrics are reported once per day.</p> </note> <ul> <li> <p> <b> <code>BucketSizeBytes</code> </b> - The amount of data in bytes stored in a bucket. This value is calculated by summing the size of all objects in the bucket (including object versions), including the size of all parts for all incomplete multipart uploads to the bucket.</p> <p>Statistics: The most useful statistic is <code>Maximum</code>.</p> <p>Unit: The published unit is <code>Bytes</code>.</p> </li> <li> <p> <b> <code>NumberOfObjects</code> </b> - The total number of objects stored in a bucket. This value is calculated by counting all objects in the bucket (including object versions) and the total number of parts for all incomplete multipart uploads to the bucket.</p> <p>Statistics: The most useful statistic is <code>Average</code>.</p> <p>Unit: The published unit is <code>Count</code>.</p> </li> </ul>
        start_time: <p>The timestamp indicating the earliest data to be returned.</p>
        end_time: <p>The timestamp indicating the latest data to be returned.</p>
        period: <p>The granularity, in seconds, of the returned data points.</p> <note> <p>Bucket storage metrics are reported once per day. Therefore, you should specify a period of 86400 seconds, which is the number of seconds in a day.</p> </note>
        statistics: <p>The statistic for the metric.</p> <p>The following statistics are available:</p> <ul> <li> <p> <code>Minimum</code> - The lowest value observed during the specified period. Use this value to determine low volumes of activity for your application.</p> </li> <li> <p> <code>Maximum</code> - The highest value observed during the specified period. Use this value to determine high volumes of activity for your application.</p> </li> <li> <p> <code>Sum</code> - The sum of all values submitted for the matching metric. You can use this statistic to determine the total volume of a metric.</p> </li> <li> <p> <code>Average</code> - The value of <code>Sum</code> / <code>SampleCount</code> during the specified period. By comparing this statistic with the <code>Minimum</code> and <code>Maximum</code> values, you can determine the full scope of a metric and how close the average use is to the <code>Minimum</code> and <code>Maximum</code> values. This comparison helps you to know when to increase or decrease your resources.</p> </li> <li> <p> <code>SampleCount</code> - The count, or number, of data points used for the statistical calculation.</p> </li> </ul>
        unit: <p>The unit for the metric data request.</p> <p>Valid units depend on the metric data being requested. For the valid units with each available metric, see the <code>metricName</code> parameter.</p>

    Raises:
        capo_lightsail.errors.access_denied_exception.AccessDeniedException: <p>Lightsail throws this exception when the user cannot be authenticated or uses invalid credentials to access a resource.</p>
        capo_lightsail.errors.invalid_input_exception.InvalidInputException: <p>Lightsail throws this exception when user input does not conform to the validation rules of an input field.</p> <note> <p>Domain and distribution APIs are only available in the N. Virginia (<code>us-east-1</code>) Amazon Web Services Region. Please set your Amazon Web Services Region configuration to <code>us-east-1</code> to create, view, or edit these resources.</p> </note>
        capo_lightsail.errors.not_found_exception.NotFoundException: <p>Lightsail throws this exception when it cannot find a resource.</p>
        capo_lightsail.errors.region_setup_in_progress_exception.RegionSetupInProgressException: <p>Lightsail throws this exception when an operation is performed on resources in an opt-in Region that is currently being set up.</p>
        capo_lightsail.errors.service_exception.ServiceException: <p>A general service exception.</p>
        capo_lightsail.errors.unauthenticated_exception.UnauthenticatedException: <p>Lightsail throws this exception when the user has not been authenticated.</p>
        capo_lightsail.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_lightsail.types.get_bucket_metric_data_request.GetBucketMetricDataRequest]",
    ) -> AsyncOperationResponse[
        "capo_lightsail.types.get_bucket_metric_data_result.GetBucketMetricDataResult"
    ]:
        import capo_lightsail._operations.lightsail_20161128.get_bucket_metric_data

        (
            output,
            http_response,
        ) = await capo_lightsail._operations.lightsail_20161128.get_bucket_metric_data.async_get_bucket_metric_data(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetBucketMetricData")
    )
    input_: capo_lightsail.types.get_bucket_metric_data_request.GetBucketMetricDataRequest = {
        "bucket_name": bucket_name,
        "metric_name": metric_name,
        "start_time": start_time,
        "end_time": end_time,
        "period": period,
        "statistics": statistics,
        "unit": unit,
    }

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output