put_query_definition
¶
put_query_definition(
name: QueryDefinitionName,
query_string: QueryDefinitionString,
*,
config_overrides: Optional[CloudWatchLogsClientConfig] = 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/cloud_watch_logs.py
6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 | |