api_op_StartQuery.go 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. // Code generated by smithy-go-codegen DO NOT EDIT.
  2. package cloudwatchlogs
  3. import (
  4. "context"
  5. "fmt"
  6. awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
  7. "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
  8. "github.com/aws/smithy-go/middleware"
  9. smithyhttp "github.com/aws/smithy-go/transport/http"
  10. )
  11. // Schedules a query of a log group using CloudWatch Logs Insights. You specify
  12. // the log group and time range to query and the query string to use. For more
  13. // information, see CloudWatch Logs Insights Query Syntax (https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html)
  14. // . After you run a query using StartQuery , the query results are stored by
  15. // CloudWatch Logs. You can use GetQueryResults (https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_GetQueryResults.html)
  16. // to retrieve the results of a query, using the queryId that StartQuery returns.
  17. // If you have associated a KMS key with the query results in this account, then
  18. // StartQuery (https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_StartQuery.html)
  19. // uses that key to encrypt the results when it stores them. If no key is
  20. // associated with query results, the query results are encrypted with the default
  21. // CloudWatch Logs encryption method. Queries time out after 60 minutes of runtime.
  22. // If your queries are timing out, reduce the time range being searched or
  23. // partition your query into a number of queries. If you are using CloudWatch
  24. // cross-account observability, you can use this operation in a monitoring account
  25. // to start a query in a linked source account. For more information, see
  26. // CloudWatch cross-account observability (https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html)
  27. // . For a cross-account StartQuery operation, the query definition must be
  28. // defined in the monitoring account. You can have up to 30 concurrent CloudWatch
  29. // Logs insights queries, including queries that have been added to dashboards.
  30. func (c *Client) StartQuery(ctx context.Context, params *StartQueryInput, optFns ...func(*Options)) (*StartQueryOutput, error) {
  31. if params == nil {
  32. params = &StartQueryInput{}
  33. }
  34. result, metadata, err := c.invokeOperation(ctx, "StartQuery", params, optFns, c.addOperationStartQueryMiddlewares)
  35. if err != nil {
  36. return nil, err
  37. }
  38. out := result.(*StartQueryOutput)
  39. out.ResultMetadata = metadata
  40. return out, nil
  41. }
  42. type StartQueryInput struct {
  43. // The end of the time range to query. The range is inclusive, so the specified
  44. // end time is included in the query. Specified as epoch time, the number of
  45. // seconds since January 1, 1970, 00:00:00 UTC .
  46. //
  47. // This member is required.
  48. EndTime *int64
  49. // The query string to use. For more information, see CloudWatch Logs Insights
  50. // Query Syntax (https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html)
  51. // .
  52. //
  53. // This member is required.
  54. QueryString *string
  55. // The beginning of the time range to query. The range is inclusive, so the
  56. // specified start time is included in the query. Specified as epoch time, the
  57. // number of seconds since January 1, 1970, 00:00:00 UTC .
  58. //
  59. // This member is required.
  60. StartTime *int64
  61. // The maximum number of log events to return in the query. If the query string
  62. // uses the fields command, only the specified fields and their values are
  63. // returned. The default is 1000.
  64. Limit *int32
  65. // The list of log groups to query. You can include up to 50 log groups. You can
  66. // specify them by the log group name or ARN. If a log group that you're querying
  67. // is in a source account and you're using a monitoring account, you must specify
  68. // the ARN of the log group here. The query definition must also be defined in the
  69. // monitoring account. If you specify an ARN, the ARN can't end with an asterisk
  70. // (*). A StartQuery operation must include exactly one of the following
  71. // parameters: logGroupName , logGroupNames , or logGroupIdentifiers .
  72. LogGroupIdentifiers []string
  73. // The log group on which to perform the query. A StartQuery operation must
  74. // include exactly one of the following parameters: logGroupName , logGroupNames ,
  75. // or logGroupIdentifiers .
  76. LogGroupName *string
  77. // The list of log groups to be queried. You can include up to 50 log groups. A
  78. // StartQuery operation must include exactly one of the following parameters:
  79. // logGroupName , logGroupNames , or logGroupIdentifiers .
  80. LogGroupNames []string
  81. noSmithyDocumentSerde
  82. }
  83. type StartQueryOutput struct {
  84. // The unique ID of the query.
  85. QueryId *string
  86. // Metadata pertaining to the operation's result.
  87. ResultMetadata middleware.Metadata
  88. noSmithyDocumentSerde
  89. }
  90. func (c *Client) addOperationStartQueryMiddlewares(stack *middleware.Stack, options Options) (err error) {
  91. if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
  92. return err
  93. }
  94. err = stack.Serialize.Add(&awsAwsjson11_serializeOpStartQuery{}, middleware.After)
  95. if err != nil {
  96. return err
  97. }
  98. err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpStartQuery{}, middleware.After)
  99. if err != nil {
  100. return err
  101. }
  102. if err := addProtocolFinalizerMiddlewares(stack, options, "StartQuery"); err != nil {
  103. return fmt.Errorf("add protocol finalizers: %v", err)
  104. }
  105. if err = addlegacyEndpointContextSetter(stack, options); err != nil {
  106. return err
  107. }
  108. if err = addSetLoggerMiddleware(stack, options); err != nil {
  109. return err
  110. }
  111. if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
  112. return err
  113. }
  114. if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
  115. return err
  116. }
  117. if err = addResolveEndpointMiddleware(stack, options); err != nil {
  118. return err
  119. }
  120. if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
  121. return err
  122. }
  123. if err = addRetryMiddlewares(stack, options); err != nil {
  124. return err
  125. }
  126. if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
  127. return err
  128. }
  129. if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
  130. return err
  131. }
  132. if err = addClientUserAgent(stack, options); err != nil {
  133. return err
  134. }
  135. if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
  136. return err
  137. }
  138. if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
  139. return err
  140. }
  141. if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
  142. return err
  143. }
  144. if err = addOpStartQueryValidationMiddleware(stack); err != nil {
  145. return err
  146. }
  147. if err = stack.Initialize.Add(newServiceMetadataMiddleware_opStartQuery(options.Region), middleware.Before); err != nil {
  148. return err
  149. }
  150. if err = awsmiddleware.AddRecursionDetection(stack); err != nil {
  151. return err
  152. }
  153. if err = addRequestIDRetrieverMiddleware(stack); err != nil {
  154. return err
  155. }
  156. if err = addResponseErrorMiddleware(stack); err != nil {
  157. return err
  158. }
  159. if err = addRequestResponseLogging(stack, options); err != nil {
  160. return err
  161. }
  162. if err = addDisableHTTPSMiddleware(stack, options); err != nil {
  163. return err
  164. }
  165. return nil
  166. }
  167. func newServiceMetadataMiddleware_opStartQuery(region string) *awsmiddleware.RegisterServiceMetadata {
  168. return &awsmiddleware.RegisterServiceMetadata{
  169. Region: region,
  170. ServiceID: ServiceID,
  171. OperationName: "StartQuery",
  172. }
  173. }