Skip to main content

query_definitions

Creates, updates, deletes, gets or lists a query_definitions resource.

Overview

Namequery_definitions
TypeResource
Idaws.logs.query_definitions

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
next_tokenstringThe token for the next set of items to return. The token expires after 24 hours.
query_definitionsarrayThe list of query definitions that match your request.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_query_definitionsselectregionThis operation returns a paginated list of your saved CloudWatch Logs Insights query definitions. You can retrieve query definitions from the current account or from a source account that is linked to the current account. You can use the queryDefinitionNamePrefix parameter to limit the results to only the query definitions that have names that start with a certain string.
put_query_definitionreplaceregion, name, queryStringCreates 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.
delete_query_definitiondeleteregionDeletes a saved CloudWatch Logs Insights query definition. A query definition contains details about a saved CloudWatch Logs Insights query. Each DeleteQueryDefinition operation can delete one query definition. You must have the logs:DeleteQueryDefinition permission to be able to perform this operation.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
regionstringAWS region (default: us-east-1)

SELECT examples

This operation returns a paginated list of your saved CloudWatch Logs Insights query definitions. You can retrieve query definitions from the current account or from a source account that is linked to the current account. You can use the queryDefinitionNamePrefix parameter to limit the results to only the query definitions that have names that start with a certain string.

SELECT
next_token,
query_definitions
FROM aws.logs.query_definitions
WHERE region = '{{ region }}' -- required
;

REPLACE examples

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.

REPLACE aws.logs.query_definitions
SET
queryLanguage = '{{ queryLanguage }}',
name = '{{ name }}',
queryDefinitionId = '{{ queryDefinitionId }}',
logGroupNames = '{{ logGroupNames }}',
queryString = '{{ queryString }}',
clientToken = '{{ clientToken }}',
parameters = '{{ parameters }}'
WHERE
region = '{{ region }}' --required
AND name = '{{ name }}' --required
AND queryString = '{{ queryString }}' --required
RETURNING
query_definition_id;

DELETE examples

Deletes a saved CloudWatch Logs Insights query definition. A query definition contains details about a saved CloudWatch Logs Insights query. Each DeleteQueryDefinition operation can delete one query definition. You must have the logs:DeleteQueryDefinition permission to be able to perform this operation.

DELETE FROM aws.logs.query_definitions
WHERE region = '{{ region }}' --required
;