query_definitions
Creates, updates, deletes, gets or lists a query_definitions resource.
Overview
| Name | query_definitions |
| Type | Resource |
| Id | aws.logs.query_definitions |
Fields
The following fields are returned by SELECT queries:
- describe_query_definitions
| Name | Datatype | Description |
|---|---|---|
next_token | string | The token for the next set of items to return. The token expires after 24 hours. |
query_definitions | array | The list of query definitions that match your request. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
describe_query_definitions | select | region | 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. | |
put_query_definition | replace | region, name, queryString | 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. | |
delete_query_definition | delete | region | 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. |
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.
| Name | Datatype | Description |
|---|---|---|
region | string | AWS region (default: us-east-1) |
SELECT examples
- describe_query_definitions
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
- put_query_definition
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
- delete_query_definition
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
;