1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package lightsail 4 5import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 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. Metrics report the utilization of your resources, and 17// the error counts generated by them. Monitor and collect metric data regularly to 18// maintain the reliability, availability, and performance of your resources. 19func (c *Client) GetInstanceMetricData(ctx context.Context, params *GetInstanceMetricDataInput, optFns ...func(*Options)) (*GetInstanceMetricDataOutput, error) { 20 if params == nil { 21 params = &GetInstanceMetricDataInput{} 22 } 23 24 result, metadata, err := c.invokeOperation(ctx, "GetInstanceMetricData", params, optFns, addOperationGetInstanceMetricDataMiddlewares) 25 if err != nil { 26 return nil, err 27 } 28 29 out := result.(*GetInstanceMetricDataOutput) 30 out.ResultMetadata = metadata 31 return out, nil 32} 33 34type GetInstanceMetricDataInput struct { 35 36 // The end time of the time period. 37 // 38 // This member is required. 39 EndTime *time.Time 40 41 // The name of the instance for which you want to get metrics data. 42 // 43 // This member is required. 44 InstanceName *string 45 46 // The metric for which you want to return information. Valid instance metric names 47 // are listed below, along with the most useful statistics to include in your 48 // request, and the published unit value. 49 // 50 // * BurstCapacityPercentage - The 51 // percentage of CPU performance available for your instance to burst above its 52 // baseline. Your instance continuously accrues and consumes burst capacity. Burst 53 // capacity stops accruing when your instance's BurstCapacityPercentage reaches 54 // 100%. For more information, see Viewing instance burst capacity in Amazon 55 // Lightsail 56 // (https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-viewing-instance-burst-capacity). 57 // Statistics: The most useful statistics are Maximum and Average. Unit: The 58 // published unit is Percent. 59 // 60 // * BurstCapacityTime - The available amount of time 61 // for your instance to burst at 100% CPU utilization. Your instance continuously 62 // accrues and consumes burst capacity. Burst capacity time stops accruing when 63 // your instance's BurstCapacityPercentage metric reaches 100%. Burst capacity time 64 // is consumed at the full rate only when your instance operates at 100% CPU 65 // utilization. For example, if your instance operates at 50% CPU utilization in 66 // the burstable zone for a 5-minute period, then it consumes CPU burst capacity 67 // minutes at a 50% rate in that period. Your instance consumed 2 minutes and 30 68 // seconds of CPU burst capacity minutes in the 5-minute period. For more 69 // information, see Viewing instance burst capacity in Amazon Lightsail 70 // (https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-viewing-instance-burst-capacity). 71 // Statistics: The most useful statistics are Maximum and Average. Unit: The 72 // published unit is Seconds. 73 // 74 // * CPUUtilization - The percentage of allocated 75 // compute units that are currently in use on the instance. This metric identifies 76 // the processing power to run the applications on the instance. Tools in your 77 // operating system can show a lower percentage than Lightsail when the instance is 78 // not allocated a full processor core. Statistics: The most useful statistics are 79 // Maximum and Average. Unit: The published unit is Percent. 80 // 81 // * NetworkIn - The 82 // number of bytes received on all network interfaces by the instance. This metric 83 // identifies the volume of incoming network traffic to the instance. The number 84 // reported is the number of bytes received during the period. Because this metric 85 // is reported in 5-minute intervals, divide the reported number by 300 to find 86 // Bytes/second. Statistics: The most useful statistic is Sum. Unit: The published 87 // unit is Bytes. 88 // 89 // * NetworkOut - The number of bytes sent out on all network 90 // interfaces by the instance. This metric identifies the volume of outgoing 91 // network traffic from the instance. The number reported is the number of bytes 92 // sent during the period. Because this metric is reported in 5-minute intervals, 93 // divide the reported number by 300 to find Bytes/second. Statistics: The most 94 // useful statistic is Sum. Unit: The published unit is Bytes. 95 // 96 // * StatusCheckFailed 97 // - Reports whether the instance passed or failed both the instance status check 98 // and the system status check. This metric can be either 0 (passed) or 1 (failed). 99 // This metric data is available in 1-minute (60 seconds) granularity. Statistics: 100 // The most useful statistic is Sum. Unit: The published unit is Count. 101 // 102 // * 103 // StatusCheckFailed_Instance - Reports whether the instance passed or failed the 104 // instance status check. This metric can be either 0 (passed) or 1 (failed). This 105 // metric data is available in 1-minute (60 seconds) granularity. Statistics: The 106 // most useful statistic is Sum. Unit: The published unit is Count. 107 // 108 // * 109 // StatusCheckFailed_System - Reports whether the instance passed or failed the 110 // system status check. This metric can be either 0 (passed) or 1 (failed). This 111 // metric data is available in 1-minute (60 seconds) granularity. Statistics: The 112 // most useful statistic is Sum. Unit: The published unit is Count. 113 // 114 // This member is required. 115 MetricName types.InstanceMetricName 116 117 // The granularity, in seconds, of the returned data points. The StatusCheckFailed, 118 // StatusCheckFailed_Instance, and StatusCheckFailed_System instance metric data is 119 // available in 1-minute (60 seconds) granularity. All other instance metric data 120 // is available in 5-minute (300 seconds) granularity. 121 // 122 // This member is required. 123 Period int32 124 125 // The start time of the time period. 126 // 127 // This member is required. 128 StartTime *time.Time 129 130 // The statistic for the metric. The following statistics are available: 131 // 132 // * Minimum 133 // - The lowest value observed during the specified period. Use this value to 134 // determine low volumes of activity for your application. 135 // 136 // * Maximum - The highest 137 // value observed during the specified period. Use this value to determine high 138 // volumes of activity for your application. 139 // 140 // * Sum - All values submitted for the 141 // matching metric added together. You can use this statistic to determine the 142 // total volume of a metric. 143 // 144 // * Average - The value of Sum / SampleCount during the 145 // specified period. By comparing this statistic with the Minimum and Maximum 146 // values, you can determine the full scope of a metric and how close the average 147 // use is to the Minimum and Maximum values. This comparison helps you to know when 148 // to increase or decrease your resources. 149 // 150 // * SampleCount - The count, or number, 151 // of data points used for the statistical calculation. 152 // 153 // This member is required. 154 Statistics []types.MetricStatistic 155 156 // The unit for the metric data request. Valid units depend on the metric data 157 // being requested. For the valid units to specify with each available metric, see 158 // the metricName parameter. 159 // 160 // This member is required. 161 Unit types.MetricUnit 162} 163 164type GetInstanceMetricDataOutput struct { 165 166 // An array of objects that describe the metric data returned. 167 MetricData []types.MetricDatapoint 168 169 // The name of the metric returned. 170 MetricName types.InstanceMetricName 171 172 // Metadata pertaining to the operation's result. 173 ResultMetadata middleware.Metadata 174} 175 176func addOperationGetInstanceMetricDataMiddlewares(stack *middleware.Stack, options Options) (err error) { 177 err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetInstanceMetricData{}, middleware.After) 178 if err != nil { 179 return err 180 } 181 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetInstanceMetricData{}, middleware.After) 182 if err != nil { 183 return err 184 } 185 if err = addSetLoggerMiddleware(stack, options); err != nil { 186 return err 187 } 188 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 189 return err 190 } 191 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 192 return err 193 } 194 if err = addResolveEndpointMiddleware(stack, options); err != nil { 195 return err 196 } 197 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 198 return err 199 } 200 if err = addRetryMiddlewares(stack, options); err != nil { 201 return err 202 } 203 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 204 return err 205 } 206 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 207 return err 208 } 209 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 210 return err 211 } 212 if err = addClientUserAgent(stack); err != nil { 213 return err 214 } 215 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 216 return err 217 } 218 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 219 return err 220 } 221 if err = addOpGetInstanceMetricDataValidationMiddleware(stack); err != nil { 222 return err 223 } 224 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetInstanceMetricData(options.Region), middleware.Before); err != nil { 225 return err 226 } 227 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 228 return err 229 } 230 if err = addResponseErrorMiddleware(stack); err != nil { 231 return err 232 } 233 if err = addRequestResponseLogging(stack, options); err != nil { 234 return err 235 } 236 return nil 237} 238 239func newServiceMetadataMiddleware_opGetInstanceMetricData(region string) *awsmiddleware.RegisterServiceMetadata { 240 return &awsmiddleware.RegisterServiceMetadata{ 241 Region: region, 242 ServiceID: ServiceID, 243 SigningName: "lightsail", 244 OperationName: "GetInstanceMetricData", 245 } 246} 247