Skip to main content

query_definitions

Creates, updates, deletes or gets a query_definition resource or lists query_definitions in a region

Overview

Namequery_definitions
TypeResource
DescriptionThe resource schema for AWSLogs QueryDefinition
Idaws.logs.query_definitions

Fields

NameDatatypeDescription
namestringA name for the saved query definition
query_stringstringThe query string to use for this definition
log_group_namesarrayOptionally define specific log groups as part of your query definition
query_definition_idstringUnique identifier of a query definition
regionstringAWS region.

Methods

NameAccessible byRequired Params
create_resourceINSERTName, QueryString, region
delete_resourceDELETEdata__Identifier, region
update_resourceUPDATEdata__Identifier, data__PatchDocument, region
list_resourcesSELECTregion
get_resourceSELECTdata__Identifier, region

SELECT examples

Gets all query_definitions in a region.

SELECT
region,
name,
query_string,
log_group_names,
query_definition_id
FROM aws.logs.query_definitions
WHERE region = 'us-east-1';

Gets all properties from an individual query_definition.

SELECT
region,
name,
query_string,
log_group_names,
query_definition_id
FROM aws.logs.query_definitions
WHERE region = 'us-east-1' AND data__Identifier = '<QueryDefinitionId>';

INSERT example

Use the following StackQL query and manifest file to create a new query_definition resource, using stack-deploy.

/*+ create */
INSERT INTO aws.logs.query_definitions (
Name,
QueryString,
region
)
SELECT
'{{ Name }}',
'{{ QueryString }}',
'{{ region }}';

DELETE example

/*+ delete */
DELETE FROM aws.logs.query_definitions
WHERE data__Identifier = '<QueryDefinitionId>'
AND region = 'us-east-1';

Permissions

To operate on the query_definitions resource, the following permissions are required:

Create

logs:PutQueryDefinition

Read

logs:DescribeQueryDefinitions

Update

logs:PutQueryDefinition

Delete

logs:DeleteQueryDefinition

List

logs:DescribeQueryDefinitions