api_op_GetRelationalDatabaseMetricData.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 of the specified metric for a database in Amazon
  16  // Lightsail.
  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) GetRelationalDatabaseMetricData(ctx context.Context, params *GetRelationalDatabaseMetricDataInput, optFns ...func(*Options)) (*GetRelationalDatabaseMetricDataOutput, error) {
  22  	if params == nil {
  23  		params = &GetRelationalDatabaseMetricDataInput{}
  24  	}
  25  
  26  	result, metadata, err := c.invokeOperation(ctx, "GetRelationalDatabaseMetricData", params, optFns, c.addOperationGetRelationalDatabaseMetricDataMiddlewares)
  27  	if err != nil {
  28  		return nil, err
  29  	}
  30  
  31  	out := result.(*GetRelationalDatabaseMetricDataOutput)
  32  	out.ResultMetadata = metadata
  33  	return out, nil
  34  }
  35  
  36  type GetRelationalDatabaseMetricDataInput struct {
  37  
  38  	// The end of the time interval from which to get metric data.
  39  	//
  40  	// Constraints:
  41  	//
  42  	//   - Specified in Coordinated Universal Time (UTC).
  43  	//
  44  	//   - Specified in the Unix time format.
  45  	//
  46  	// For example, if you wish to use an end time of October 1, 2018, at 8 PM UTC,
  47  	//   then you input 1538424000 as the end time.
  48  	//
  49  	// This member is required.
  50  	EndTime *time.Time
  51  
  52  	// The metric for which you want to return information.
  53  	//
  54  	// Valid relational database metric names are listed below, along with the most
  55  	// useful statistics to include in your request, and the published unit value. All
  56  	// relational database metric data is available in 1-minute (60 seconds)
  57  	// granularity.
  58  	//
  59  	//   - CPUUtilization - The percentage of CPU utilization currently in use on the
  60  	//   database.
  61  	//
  62  	// Statistics : The most useful statistics are Maximum and Average .
  63  	//
  64  	// Unit : The published unit is Percent .
  65  	//
  66  	//   - DatabaseConnections - The number of database connections in use.
  67  	//
  68  	// Statistics : The most useful statistics are Maximum and Sum .
  69  	//
  70  	// Unit : The published unit is Count .
  71  	//
  72  	//   - DiskQueueDepth - The number of outstanding IOs (read/write requests) that
  73  	//   are waiting to access the disk.
  74  	//
  75  	// Statistics : The most useful statistic is Sum .
  76  	//
  77  	// Unit : The published unit is Count .
  78  	//
  79  	//   - FreeStorageSpace - The amount of available storage space.
  80  	//
  81  	// Statistics : The most useful statistic is Sum .
  82  	//
  83  	// Unit : The published unit is Bytes .
  84  	//
  85  	//   - NetworkReceiveThroughput - The incoming (Receive) network traffic on the
  86  	//   database, including both customer database traffic and AWS traffic used for
  87  	//   monitoring and replication.
  88  	//
  89  	// Statistics : The most useful statistic is Average .
  90  	//
  91  	// Unit : The published unit is Bytes/Second .
  92  	//
  93  	//   - NetworkTransmitThroughput - The outgoing (Transmit) network traffic on the
  94  	//   database, including both customer database traffic and AWS traffic used for
  95  	//   monitoring and replication.
  96  	//
  97  	// Statistics : The most useful statistic is Average .
  98  	//
  99  	// Unit : The published unit is Bytes/Second .
 100  	//
 101  	// This member is required.
 102  	MetricName types.RelationalDatabaseMetricName
 103  
 104  	// The granularity, in seconds, of the returned data points.
 105  	//
 106  	// All relational database metric data is available in 1-minute (60 seconds)
 107  	// granularity.
 108  	//
 109  	// This member is required.
 110  	Period *int32
 111  
 112  	// The name of your database from which to get metric data.
 113  	//
 114  	// This member is required.
 115  	RelationalDatabaseName *string
 116  
 117  	// The start of the time interval from which to get metric data.
 118  	//
 119  	// Constraints:
 120  	//
 121  	//   - Specified in Coordinated Universal Time (UTC).
 122  	//
 123  	//   - Specified in the Unix time format.
 124  	//
 125  	// For example, if you wish to use a start time of October 1, 2018, at 8 PM UTC,
 126  	//   then you input 1538424000 as the start time.
 127  	//
 128  	// This member is required.
 129  	StartTime *time.Time
 130  
 131  	// The statistic for the metric.
 132  	//
 133  	// The following statistics are available:
 134  	//
 135  	//   - Minimum - The lowest value observed during the specified period. Use this
 136  	//   value to determine low volumes of activity for your application.
 137  	//
 138  	//   - Maximum - The highest value observed during the specified period. Use this
 139  	//   value to determine high volumes of activity for your application.
 140  	//
 141  	//   - Sum - All values submitted for the matching metric added together. You can
 142  	//   use this statistic to determine the total volume of a metric.
 143  	//
 144  	//   - Average - The value of Sum / SampleCount during the specified period. By
 145  	//   comparing this statistic with the Minimum and Maximum values, you can determine
 146  	//   the full scope of a metric and how close the average use is to the Minimum and
 147  	//   Maximum values. This comparison helps you to know when to increase or decrease
 148  	//   your resources.
 149  	//
 150  	//   - SampleCount - The count, or number, of data points used for the statistical
 151  	//   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 with each available metric, see the
 158  	// metricName parameter.
 159  	//
 160  	// This member is required.
 161  	Unit types.MetricUnit
 162  
 163  	noSmithyDocumentSerde
 164  }
 165  
 166  type GetRelationalDatabaseMetricDataOutput struct {
 167  
 168  	// An array of objects that describe the metric data returned.
 169  	MetricData []types.MetricDatapoint
 170  
 171  	// The name of the metric returned.
 172  	MetricName types.RelationalDatabaseMetricName
 173  
 174  	// Metadata pertaining to the operation's result.
 175  	ResultMetadata middleware.Metadata
 176  
 177  	noSmithyDocumentSerde
 178  }
 179  
 180  func (c *Client) addOperationGetRelationalDatabaseMetricDataMiddlewares(stack *middleware.Stack, options Options) (err error) {
 181  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
 182  		return err
 183  	}
 184  	err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetRelationalDatabaseMetricData{}, middleware.After)
 185  	if err != nil {
 186  		return err
 187  	}
 188  	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetRelationalDatabaseMetricData{}, middleware.After)
 189  	if err != nil {
 190  		return err
 191  	}
 192  	if err := addProtocolFinalizerMiddlewares(stack, options, "GetRelationalDatabaseMetricData"); err != nil {
 193  		return fmt.Errorf("add protocol finalizers: %v", err)
 194  	}
 195  
 196  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
 197  		return err
 198  	}
 199  	if err = addSetLoggerMiddleware(stack, options); err != nil {
 200  		return err
 201  	}
 202  	if err = addClientRequestID(stack); err != nil {
 203  		return err
 204  	}
 205  	if err = addComputeContentLength(stack); err != nil {
 206  		return err
 207  	}
 208  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
 209  		return err
 210  	}
 211  	if err = addComputePayloadSHA256(stack); err != nil {
 212  		return err
 213  	}
 214  	if err = addRetry(stack, options); err != nil {
 215  		return err
 216  	}
 217  	if err = addRawResponseToMetadata(stack); err != nil {
 218  		return err
 219  	}
 220  	if err = addRecordResponseTiming(stack); err != nil {
 221  		return err
 222  	}
 223  	if err = addSpanRetryLoop(stack, options); err != nil {
 224  		return err
 225  	}
 226  	if err = addClientUserAgent(stack, options); err != nil {
 227  		return err
 228  	}
 229  	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
 230  		return err
 231  	}
 232  	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
 233  		return err
 234  	}
 235  	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 236  		return err
 237  	}
 238  	if err = addTimeOffsetBuild(stack, c); err != nil {
 239  		return err
 240  	}
 241  	if err = addUserAgentRetryMode(stack, options); err != nil {
 242  		return err
 243  	}
 244  	if err = addCredentialSource(stack, options); err != nil {
 245  		return err
 246  	}
 247  	if err = addOpGetRelationalDatabaseMetricDataValidationMiddleware(stack); err != nil {
 248  		return err
 249  	}
 250  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetRelationalDatabaseMetricData(options.Region), middleware.Before); err != nil {
 251  		return err
 252  	}
 253  	if err = addRecursionDetection(stack); err != nil {
 254  		return err
 255  	}
 256  	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
 257  		return err
 258  	}
 259  	if err = addResponseErrorMiddleware(stack); err != nil {
 260  		return err
 261  	}
 262  	if err = addRequestResponseLogging(stack, options); err != nil {
 263  		return err
 264  	}
 265  	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
 266  		return err
 267  	}
 268  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 269  		return err
 270  	}
 271  	if err = addInterceptAttempt(stack, options); err != nil {
 272  		return err
 273  	}
 274  	if err = addInterceptors(stack, options); err != nil {
 275  		return err
 276  	}
 277  	return nil
 278  }
 279  
 280  func newServiceMetadataMiddleware_opGetRelationalDatabaseMetricData(region string) *awsmiddleware.RegisterServiceMetadata {
 281  	return &awsmiddleware.RegisterServiceMetadata{
 282  		Region:        region,
 283  		ServiceID:     ServiceID,
 284  		OperationName: "GetRelationalDatabaseMetricData",
 285  	}
 286  }
 287