api_op_GetLoadBalancerMetricData.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 information about health metrics for your Lightsail load balancer.
  16  //
  17  // Metrics report the utilization of your resources, and the error counts
  18  // generated by them. Monitor and collect metric data regularly to maintain the
  19  // reliability, availability, and performance of your resources.
  20  func (c *Client) GetLoadBalancerMetricData(ctx context.Context, params *GetLoadBalancerMetricDataInput, optFns ...func(*Options)) (*GetLoadBalancerMetricDataOutput, error) {
  21  	if params == nil {
  22  		params = &GetLoadBalancerMetricDataInput{}
  23  	}
  24  
  25  	result, metadata, err := c.invokeOperation(ctx, "GetLoadBalancerMetricData", params, optFns, c.addOperationGetLoadBalancerMetricDataMiddlewares)
  26  	if err != nil {
  27  		return nil, err
  28  	}
  29  
  30  	out := result.(*GetLoadBalancerMetricDataOutput)
  31  	out.ResultMetadata = metadata
  32  	return out, nil
  33  }
  34  
  35  type GetLoadBalancerMetricDataInput struct {
  36  
  37  	// The end time of the period.
  38  	//
  39  	// This member is required.
  40  	EndTime *time.Time
  41  
  42  	// The name of the load balancer.
  43  	//
  44  	// This member is required.
  45  	LoadBalancerName *string
  46  
  47  	// The metric for which you want to return information.
  48  	//
  49  	// Valid load balancer metric names are listed below, along with the most useful
  50  	// statistics to include in your request, and the published unit value.
  51  	//
  52  	//   - ClientTLSNegotiationErrorCount - The number of TLS connections initiated by
  53  	//   the client that did not establish a session with the load balancer due to a TLS
  54  	//   error generated by the load balancer. Possible causes include a mismatch of
  55  	//   ciphers or protocols.
  56  	//
  57  	// Statistics : The most useful statistic is Sum .
  58  	//
  59  	// Unit : The published unit is Count .
  60  	//
  61  	//   - HealthyHostCount - The number of target instances that are considered
  62  	//   healthy.
  63  	//
  64  	// Statistics : The most useful statistic are Average , Minimum , and Maximum .
  65  	//
  66  	// Unit : The published unit is Count .
  67  	//
  68  	//   - HTTPCode_Instance_2XX_Count - The number of HTTP 2XX response codes
  69  	//   generated by the target instances. This does not include any response codes
  70  	//   generated by the load balancer.
  71  	//
  72  	// Statistics : The most useful statistic is Sum . Note that Minimum , Maximum ,
  73  	//   and Average all return 1 .
  74  	//
  75  	// Unit : The published unit is Count .
  76  	//
  77  	//   - HTTPCode_Instance_3XX_Count - The number of HTTP 3XX response codes
  78  	//   generated by the target instances. This does not include any response codes
  79  	//   generated by the load balancer.
  80  	//
  81  	// Statistics : The most useful statistic is Sum . Note that Minimum , Maximum ,
  82  	//   and Average all return 1 .
  83  	//
  84  	// Unit : The published unit is Count .
  85  	//
  86  	//   - HTTPCode_Instance_4XX_Count - The number of HTTP 4XX response codes
  87  	//   generated by the target instances. This does not include any response codes
  88  	//   generated by the load balancer.
  89  	//
  90  	// Statistics : The most useful statistic is Sum . Note that Minimum , Maximum ,
  91  	//   and Average all return 1 .
  92  	//
  93  	// Unit : The published unit is Count .
  94  	//
  95  	//   - HTTPCode_Instance_5XX_Count - The number of HTTP 5XX response codes
  96  	//   generated by the target instances. This does not include any response codes
  97  	//   generated by the load balancer.
  98  	//
  99  	// Statistics : The most useful statistic is Sum . Note that Minimum , Maximum ,
 100  	//   and Average all return 1 .
 101  	//
 102  	// Unit : The published unit is Count .
 103  	//
 104  	//   - HTTPCode_LB_4XX_Count - The number of HTTP 4XX client error codes that
 105  	//   originated from the load balancer. Client errors are generated when requests are
 106  	//   malformed or incomplete. These requests were not received by the target
 107  	//   instance. This count does not include response codes generated by the target
 108  	//   instances.
 109  	//
 110  	// Statistics : The most useful statistic is Sum . Note that Minimum , Maximum ,
 111  	//   and Average all return 1 .
 112  	//
 113  	// Unit : The published unit is Count .
 114  	//
 115  	//   - HTTPCode_LB_5XX_Count - The number of HTTP 5XX server error codes that
 116  	//   originated from the load balancer. This does not include any response codes
 117  	//   generated by the target instance. This metric is reported if there are no
 118  	//   healthy instances attached to the load balancer, or if the request rate exceeds
 119  	//   the capacity of the instances (spillover) or the load balancer.
 120  	//
 121  	// Statistics : The most useful statistic is Sum . Note that Minimum , Maximum ,
 122  	//   and Average all return 1 .
 123  	//
 124  	// Unit : The published unit is Count .
 125  	//
 126  	//   - InstanceResponseTime - The time elapsed, in seconds, after the request
 127  	//   leaves the load balancer until a response from the target instance is received.
 128  	//
 129  	// Statistics : The most useful statistic is Average .
 130  	//
 131  	// Unit : The published unit is Seconds .
 132  	//
 133  	//   - RejectedConnectionCount - The number of connections that were rejected
 134  	//   because the load balancer had reached its maximum number of connections.
 135  	//
 136  	// Statistics : The most useful statistic is Sum .
 137  	//
 138  	// Unit : The published unit is Count .
 139  	//
 140  	//   - RequestCount - The number of requests processed over IPv4. This count
 141  	//   includes only the requests with a response generated by a target instance of the
 142  	//   load balancer.
 143  	//
 144  	// Statistics : The most useful statistic is Sum . Note that Minimum , Maximum ,
 145  	//   and Average all return 1 .
 146  	//
 147  	// Unit : The published unit is Count .
 148  	//
 149  	//   - UnhealthyHostCount - The number of target instances that are considered
 150  	//   unhealthy.
 151  	//
 152  	// Statistics : The most useful statistic are Average , Minimum , and Maximum .
 153  	//
 154  	// Unit : The published unit is Count .
 155  	//
 156  	// This member is required.
 157  	MetricName types.LoadBalancerMetricName
 158  
 159  	// The granularity, in seconds, of the returned data points.
 160  	//
 161  	// This member is required.
 162  	Period *int32
 163  
 164  	// The start time of the period.
 165  	//
 166  	// This member is required.
 167  	StartTime *time.Time
 168  
 169  	// The statistic for the metric.
 170  	//
 171  	// The following statistics are available:
 172  	//
 173  	//   - Minimum - The lowest value observed during the specified period. Use this
 174  	//   value to determine low volumes of activity for your application.
 175  	//
 176  	//   - Maximum - The highest value observed during the specified period. Use this
 177  	//   value to determine high volumes of activity for your application.
 178  	//
 179  	//   - Sum - All values submitted for the matching metric added together. You can
 180  	//   use this statistic to determine the total volume of a metric.
 181  	//
 182  	//   - Average - The value of Sum / SampleCount during the specified period. By
 183  	//   comparing this statistic with the Minimum and Maximum values, you can determine
 184  	//   the full scope of a metric and how close the average use is to the Minimum and
 185  	//   Maximum values. This comparison helps you to know when to increase or decrease
 186  	//   your resources.
 187  	//
 188  	//   - SampleCount - The count, or number, of data points used for the statistical
 189  	//   calculation.
 190  	//
 191  	// This member is required.
 192  	Statistics []types.MetricStatistic
 193  
 194  	// The unit for the metric data request. Valid units depend on the metric data
 195  	// being requested. For the valid units with each available metric, see the
 196  	// metricName parameter.
 197  	//
 198  	// This member is required.
 199  	Unit types.MetricUnit
 200  
 201  	noSmithyDocumentSerde
 202  }
 203  
 204  type GetLoadBalancerMetricDataOutput struct {
 205  
 206  	// An array of objects that describe the metric data returned.
 207  	MetricData []types.MetricDatapoint
 208  
 209  	// The name of the metric returned.
 210  	MetricName types.LoadBalancerMetricName
 211  
 212  	// Metadata pertaining to the operation's result.
 213  	ResultMetadata middleware.Metadata
 214  
 215  	noSmithyDocumentSerde
 216  }
 217  
 218  func (c *Client) addOperationGetLoadBalancerMetricDataMiddlewares(stack *middleware.Stack, options Options) (err error) {
 219  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
 220  		return err
 221  	}
 222  	err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetLoadBalancerMetricData{}, middleware.After)
 223  	if err != nil {
 224  		return err
 225  	}
 226  	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetLoadBalancerMetricData{}, middleware.After)
 227  	if err != nil {
 228  		return err
 229  	}
 230  	if err := addProtocolFinalizerMiddlewares(stack, options, "GetLoadBalancerMetricData"); err != nil {
 231  		return fmt.Errorf("add protocol finalizers: %v", err)
 232  	}
 233  
 234  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
 235  		return err
 236  	}
 237  	if err = addSetLoggerMiddleware(stack, options); err != nil {
 238  		return err
 239  	}
 240  	if err = addClientRequestID(stack); err != nil {
 241  		return err
 242  	}
 243  	if err = addComputeContentLength(stack); err != nil {
 244  		return err
 245  	}
 246  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
 247  		return err
 248  	}
 249  	if err = addComputePayloadSHA256(stack); err != nil {
 250  		return err
 251  	}
 252  	if err = addRetry(stack, options); err != nil {
 253  		return err
 254  	}
 255  	if err = addRawResponseToMetadata(stack); err != nil {
 256  		return err
 257  	}
 258  	if err = addRecordResponseTiming(stack); err != nil {
 259  		return err
 260  	}
 261  	if err = addSpanRetryLoop(stack, options); err != nil {
 262  		return err
 263  	}
 264  	if err = addClientUserAgent(stack, options); err != nil {
 265  		return err
 266  	}
 267  	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
 268  		return err
 269  	}
 270  	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
 271  		return err
 272  	}
 273  	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 274  		return err
 275  	}
 276  	if err = addTimeOffsetBuild(stack, c); err != nil {
 277  		return err
 278  	}
 279  	if err = addUserAgentRetryMode(stack, options); err != nil {
 280  		return err
 281  	}
 282  	if err = addCredentialSource(stack, options); err != nil {
 283  		return err
 284  	}
 285  	if err = addOpGetLoadBalancerMetricDataValidationMiddleware(stack); err != nil {
 286  		return err
 287  	}
 288  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetLoadBalancerMetricData(options.Region), middleware.Before); err != nil {
 289  		return err
 290  	}
 291  	if err = addRecursionDetection(stack); err != nil {
 292  		return err
 293  	}
 294  	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
 295  		return err
 296  	}
 297  	if err = addResponseErrorMiddleware(stack); err != nil {
 298  		return err
 299  	}
 300  	if err = addRequestResponseLogging(stack, options); err != nil {
 301  		return err
 302  	}
 303  	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
 304  		return err
 305  	}
 306  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 307  		return err
 308  	}
 309  	if err = addInterceptAttempt(stack, options); err != nil {
 310  		return err
 311  	}
 312  	if err = addInterceptors(stack, options); err != nil {
 313  		return err
 314  	}
 315  	return nil
 316  }
 317  
 318  func newServiceMetadataMiddleware_opGetLoadBalancerMetricData(region string) *awsmiddleware.RegisterServiceMetadata {
 319  	return &awsmiddleware.RegisterServiceMetadata{
 320  		Region:        region,
 321  		ServiceID:     ServiceID,
 322  		OperationName: "GetLoadBalancerMetricData",
 323  	}
 324  }
 325