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
6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 | |