put_query_definition
async
¶
put_query_definition(
name: QueryDefinitionName,
query_string: QueryDefinitionString,
*,
config_overrides: Optional[AsyncCloudWatchLogsClientConfig] = None,
query_language: Optional[QueryLanguage] = None,
query_definition_id: Optional[QueryId] = None,
log_group_names: Optional[LogGroupNames] = None,
client_token: Optional[ClientToken] = None,
parameters: Optional[QueryParameterList] = None,
) -> PutQueryDefinitionResponse
Creates or updates a query definition for CloudWatch Logs Insights. For more information, see Analyzing Log Data with CloudWatch Logs Insights.
To update a query definition, specify its queryDefinitionId in your request. The values of name, queryString, and logGroupNames are changed to the values that you specify in your update operation. No current values are retained from the current query definition. For example, imagine updating a current query definition that includes log groups. If you don't specify the logGroupNames parameter in your update operation, the query definition changes to contain no log groups.
You must have the logs:PutQueryDefinition permission to be able to perform this operation.
Parameters:
-
query_language(Optional[QueryLanguage], default:None) –Specify the query language to use for this query. The options are Logs Insights QL, OpenSearch PPL, and OpenSearch SQL. For more information about the query languages that CloudWatch Logs supports, see Supported query languages.
-
name(QueryDefinitionName) –A name for the query definition. If you are saving numerous query definitions, we recommend that you name them. This way, you can find the ones you want by using the first part of the name as a filter in the
queryDefinitionNamePrefixparameter of DescribeQueryDefinitions. -
query_definition_id(Optional[QueryId], default:None) –If you are updating a query definition, use this parameter to specify the ID of the query definition that you want to update. You can use DescribeQueryDefinitions to retrieve the IDs of your saved query definitions.
If you are creating a query definition, do not specify this parameter. CloudWatch generates a unique ID for the new query definition and include it in the response to this operation.
-
log_group_names(Optional[LogGroupNames], default:None) –Use this parameter to include specific log groups as part of your query definition. If your query uses the OpenSearch Service query language, you specify the log group names inside the
querystringinstead of here.If you are updating an existing query definition for the Logs Insights QL or OpenSearch Service PPL and you omit this parameter, then the updated definition will contain no log groups.
-
query_string(QueryDefinitionString) –The query string to use for this definition. For more information, see CloudWatch Logs Insights Query Syntax.
-
client_token(Optional[ClientToken], default:None) –Used as an idempotency token, to avoid returning an exception if the service receives the same request twice because of a network error.
-
parameters(Optional[QueryParameterList], default:None) –Use this parameter to include specific query parameters as part of your query definition. Query parameters are supported only for Logs Insights QL queries. Query parameters allow you to use placeholder variables in your query string that are substituted with values at execution time. Use the
{{parameterName}}syntax in your query string to reference a parameter.
Raises:
-
InvalidParameterException–A parameter is specified incorrectly.
-
LimitExceededException–You have reached the maximum number of resources that can be created.
-
ResourceNotFoundException–The specified resource does not exist.
-
ServiceUnavailableException–The service cannot complete the request.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_cloudwatch_logs/_services/async_cloud_watch_logs.py
6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 | |