api_op_GetInstanceMetricData.go raw

   1  // Code generated by smithy-go-codegen DO NOT EDIT.
   2  
   3  package lightsail
   4  
   5  import (
   6  	"context"
   7  	"fmt"
   8  	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
   9  	"github.com/aws/aws-sdk-go-v2/service/lightsail/types"
  10  	"github.com/aws/smithy-go/middleware"
  11  	smithyhttp "github.com/aws/smithy-go/transport/http"
  12  	"time"
  13  )
  14  
  15  // Returns the data points for the specified Amazon Lightsail instance metric,
  16  // given an instance name.
  17  //
  18  // Metrics report the utilization of your resources, and the error counts
  19  // generated by them. Monitor and collect metric data regularly to maintain the
  20  // reliability, availability, and performance of your resources.
  21  func (c *Client) GetInstanceMetricData(ctx context.Context, params *GetInstanceMetricDataInput, optFns ...func(*Options)) (*GetInstanceMetricDataOutput, error) {
  22  	if params == nil {
  23  		params = &GetInstanceMetricDataInput{}
  24  	}
  25  
  26  	result, metadata, err := c.invokeOperation(ctx, "GetInstanceMetricData", params, optFns, c.addOperationGetInstanceMetricDataMiddlewares)
  27  	if err != nil {
  28  		return nil, err
  29  	}
  30  
  31  	out := result.(*GetInstanceMetricDataOutput)
  32  	out.ResultMetadata = metadata
  33  	return out, nil
  34  }
  35  
  36  type GetInstanceMetricDataInput struct {
  37  
  38  	// The end time of the time period.
  39  	//
  40  	// This member is required.
  41  	EndTime *time.Time
  42  
  43  	// The name of the instance for which you want to get metrics data.
  44  	//
  45  	// This member is required.
  46  	InstanceName *string
  47  
  48  	// The metric for which you want to return information.
  49  	//
  50  	// Valid instance metric names are listed below, along with the most useful
  51  	// statistics to include in your request, and the published unit value.
  52  	//
  53  	//   - BurstCapacityPercentage - The percentage of CPU performance available for
  54  	//   your instance to burst above its baseline. Your instance continuously accrues
  55  	//   and consumes burst capacity. Burst capacity stops accruing when your instance's
  56  	//   BurstCapacityPercentage reaches 100%. For more information, see [Viewing instance burst capacity in Amazon Lightsail].
  57  	//
  58  	// Statistics : The most useful statistics are Maximum and Average .
  59  	//
  60  	// Unit : The published unit is Percent .
  61  	//
  62  	//   - BurstCapacityTime - The available amount of time for your instance to burst
  63  	//   at 100% CPU utilization. Your instance continuously accrues and consumes burst
  64  	//   capacity. Burst capacity time stops accruing when your instance's
  65  	//   BurstCapacityPercentage metric reaches 100%.
  66  	//
  67  	// Burst capacity time is consumed at the full rate only when your instance
  68  	//   operates at 100% CPU utilization. For example, if your instance operates at 50%
  69  	//   CPU utilization in the burstable zone for a 5-minute period, then it consumes
  70  	//   CPU burst capacity minutes at a 50% rate in that period. Your instance consumed
  71  	//   2 minutes and 30 seconds of CPU burst capacity minutes in the 5-minute period.
  72  	//   For more information, see [Viewing instance burst capacity in Amazon Lightsail].
  73  	//
  74  	// Statistics : The most useful statistics are Maximum and Average .
  75  	//
  76  	// Unit : The published unit is Seconds .
  77  	//
  78  	//   - CPUUtilization - The percentage of allocated compute units that are
  79  	//   currently in use on the instance. This metric identifies the processing power to
  80  	//   run the applications on the instance. Tools in your operating system can show a
  81  	//   lower percentage than Lightsail when the instance is not allocated a full
  82  	//   processor core.
  83  	//
  84  	// Statistics : The most useful statistics are Maximum and Average .
  85  	//
  86  	// Unit : The published unit is Percent .
  87  	//
  88  	//   - NetworkIn - The number of bytes received on all network interfaces by the
  89  	//   instance. This metric identifies the volume of incoming network traffic to the
  90  	//   instance. The number reported is the number of bytes received during the period.
  91  	//   Because this metric is reported in 5-minute intervals, divide the reported
  92  	//   number by 300 to find Bytes/second.
  93  	//
  94  	// Statistics : The most useful statistic is Sum .
  95  	//
  96  	// Unit : The published unit is Bytes .
  97  	//
  98  	//   - NetworkOut - The number of bytes sent out on all network interfaces by the
  99  	//   instance. This metric identifies the volume of outgoing network traffic from the
 100  	//   instance. The number reported is the number of bytes sent during the period.
 101  	//   Because this metric is reported in 5-minute intervals, divide the reported
 102  	//   number by 300 to find Bytes/second.
 103  	//
 104  	// Statistics : The most useful statistic is Sum .
 105  	//
 106  	// Unit : The published unit is Bytes .
 107  	//
 108  	//   - StatusCheckFailed - Reports whether the instance passed or failed both the
 109  	//   instance status check and the system status check. This metric can be either 0
 110  	//   (passed) or 1 (failed). This metric data is available in 1-minute (60 seconds)
 111  	//   granularity.
 112  	//
 113  	// Statistics : The most useful statistic is Sum .
 114  	//
 115  	// Unit : The published unit is Count .
 116  	//
 117  	//   - StatusCheckFailed_Instance - Reports whether the instance passed or failed
 118  	//   the instance status check. This metric can be either 0 (passed) or 1 (failed).
 119  	//   This metric data is available in 1-minute (60 seconds) granularity.
 120  	//
 121  	// Statistics : The most useful statistic is Sum .
 122  	//
 123  	// Unit : The published unit is Count .
 124  	//
 125  	//   - StatusCheckFailed_System - Reports whether the instance passed or failed the
 126  	//   system status check. This metric can be either 0 (passed) or 1 (failed). This
 127  	//   metric data is available in 1-minute (60 seconds) granularity.
 128  	//
 129  	// Statistics : The most useful statistic is Sum .
 130  	//
 131  	// Unit : The published unit is Count .
 132  	//
 133  	//   - MetadataNoToken - Reports the number of times that the instance metadata
 134  	//   service was successfully accessed without a token. This metric determines if
 135  	//   there are any processes accessing instance metadata by using Instance Metadata
 136  	//   Service Version 1, which doesn't use a token. If all requests use token-backed
 137  	//   sessions, such as Instance Metadata Service Version 2, then the value is 0.
 138  	//
 139  	// Statistics : The most useful statistic is Sum .
 140  	//
 141  	// Unit : The published unit is Count .
 142  	//
 143  	// [Viewing instance burst capacity in Amazon Lightsail]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-viewing-instance-burst-capacity
 144  	//
 145  	// This member is required.
 146  	MetricName types.InstanceMetricName
 147  
 148  	// The granularity, in seconds, of the returned data points.
 149  	//
 150  	// The StatusCheckFailed , StatusCheckFailed_Instance , and
 151  	// StatusCheckFailed_System instance metric data is available in 1-minute (60
 152  	// seconds) granularity. All other instance metric data is available in 5-minute
 153  	// (300 seconds) granularity.
 154  	//
 155  	// This member is required.
 156  	Period *int32
 157  
 158  	// The start time of the time period.
 159  	//
 160  	// This member is required.
 161  	StartTime *time.Time
 162  
 163  	// The statistic for the metric.
 164  	//
 165  	// The following statistics are available:
 166  	//
 167  	//   - Minimum - The lowest value observed during the specified period. Use this
 168  	//   value to determine low volumes of activity for your application.
 169  	//
 170  	//   - Maximum - The highest value observed during the specified period. Use this
 171  	//   value to determine high volumes of activity for your application.
 172  	//
 173  	//   - Sum - All values submitted for the matching metric added together. You can
 174  	//   use this statistic to determine the total volume of a metric.
 175  	//
 176  	//   - Average - The value of Sum / SampleCount during the specified period. By
 177  	//   comparing this statistic with the Minimum and Maximum values, you can determine
 178  	//   the full scope of a metric and how close the average use is to the Minimum and
 179  	//   Maximum values. This comparison helps you to know when to increase or decrease
 180  	//   your resources.
 181  	//
 182  	//   - SampleCount - The count, or number, of data points used for the statistical
 183  	//   calculation.
 184  	//
 185  	// This member is required.
 186  	Statistics []types.MetricStatistic
 187  
 188  	// The unit for the metric data request. Valid units depend on the metric data
 189  	// being requested. For the valid units to specify with each available metric, see
 190  	// the metricName parameter.
 191  	//
 192  	// This member is required.
 193  	Unit types.MetricUnit
 194  
 195  	noSmithyDocumentSerde
 196  }
 197  
 198  type GetInstanceMetricDataOutput struct {
 199  
 200  	// An array of objects that describe the metric data returned.
 201  	MetricData []types.MetricDatapoint
 202  
 203  	// The name of the metric returned.
 204  	MetricName types.InstanceMetricName
 205  
 206  	// Metadata pertaining to the operation's result.
 207  	ResultMetadata middleware.Metadata
 208  
 209  	noSmithyDocumentSerde
 210  }
 211  
 212  func (c *Client) addOperationGetInstanceMetricDataMiddlewares(stack *middleware.Stack, options Options) (err error) {
 213  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
 214  		return err
 215  	}
 216  	err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetInstanceMetricData{}, middleware.After)
 217  	if err != nil {
 218  		return err
 219  	}
 220  	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetInstanceMetricData{}, middleware.After)
 221  	if err != nil {
 222  		return err
 223  	}
 224  	if err := addProtocolFinalizerMiddlewares(stack, options, "GetInstanceMetricData"); err != nil {
 225  		return fmt.Errorf("add protocol finalizers: %v", err)
 226  	}
 227  
 228  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
 229  		return err
 230  	}
 231  	if err = addSetLoggerMiddleware(stack, options); err != nil {
 232  		return err
 233  	}
 234  	if err = addClientRequestID(stack); err != nil {
 235  		return err
 236  	}
 237  	if err = addComputeContentLength(stack); err != nil {
 238  		return err
 239  	}
 240  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
 241  		return err
 242  	}
 243  	if err = addComputePayloadSHA256(stack); err != nil {
 244  		return err
 245  	}
 246  	if err = addRetry(stack, options); err != nil {
 247  		return err
 248  	}
 249  	if err = addRawResponseToMetadata(stack); err != nil {
 250  		return err
 251  	}
 252  	if err = addRecordResponseTiming(stack); err != nil {
 253  		return err
 254  	}
 255  	if err = addSpanRetryLoop(stack, options); err != nil {
 256  		return err
 257  	}
 258  	if err = addClientUserAgent(stack, options); err != nil {
 259  		return err
 260  	}
 261  	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
 262  		return err
 263  	}
 264  	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
 265  		return err
 266  	}
 267  	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 268  		return err
 269  	}
 270  	if err = addTimeOffsetBuild(stack, c); err != nil {
 271  		return err
 272  	}
 273  	if err = addUserAgentRetryMode(stack, options); err != nil {
 274  		return err
 275  	}
 276  	if err = addCredentialSource(stack, options); err != nil {
 277  		return err
 278  	}
 279  	if err = addOpGetInstanceMetricDataValidationMiddleware(stack); err != nil {
 280  		return err
 281  	}
 282  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetInstanceMetricData(options.Region), middleware.Before); err != nil {
 283  		return err
 284  	}
 285  	if err = addRecursionDetection(stack); err != nil {
 286  		return err
 287  	}
 288  	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
 289  		return err
 290  	}
 291  	if err = addResponseErrorMiddleware(stack); err != nil {
 292  		return err
 293  	}
 294  	if err = addRequestResponseLogging(stack, options); err != nil {
 295  		return err
 296  	}
 297  	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
 298  		return err
 299  	}
 300  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 301  		return err
 302  	}
 303  	if err = addInterceptAttempt(stack, options); err != nil {
 304  		return err
 305  	}
 306  	if err = addInterceptors(stack, options); err != nil {
 307  		return err
 308  	}
 309  	return nil
 310  }
 311  
 312  func newServiceMetadataMiddleware_opGetInstanceMetricData(region string) *awsmiddleware.RegisterServiceMetadata {
 313  	return &awsmiddleware.RegisterServiceMetadata{
 314  		Region:        region,
 315  		ServiceID:     ServiceID,
 316  		OperationName: "GetInstanceMetricData",
 317  	}
 318  }
 319