Jump to Content

Class StartQueryCommandProtected

Schedules a query of a log group using CloudWatch Logs Insights. You specify the log group and time range to query and the query string to use.

For more information, see CloudWatch Logs Insights Query Syntax.

Queries time out after 15 minutes of runtime. If your queries are timing out, reduce the time range being searched or partition your query into a number of queries.

If you are using CloudWatch cross-account observability, you can use this operation in a monitoring account to start a query in a linked source account. For more information, see CloudWatch cross-account observability. For a cross-account StartQuery operation, the query definition must be defined in the monitoring account.

You can have up to 20 concurrent CloudWatch Logs insights queries, including queries that have been added to dashboards.

Example

Use a bare-bones client and the command you need to make an API call.

import { CloudWatchLogsClient, StartQueryCommand } from "@aws-sdk/client-cloudwatch-logs"; // ES Modules import
// const { CloudWatchLogsClient, StartQueryCommand } = require("@aws-sdk/client-cloudwatch-logs"); // CommonJS import
const client = new CloudWatchLogsClient(config);
const input = {
logGroupName: "STRING_VALUE",
logGroupNames: [
"STRING_VALUE",
],
logGroupIdentifiers: [
"STRING_VALUE",
],
startTime: Number("long"), // required
endTime: Number("long"), // required
queryString: "STRING_VALUE", // required
limit: Number("int"),
};
const command = new StartQueryCommand(input);
const response = await client.send(command);

Param

StartQueryCommandInput

Returns

StartQueryCommandOutput

See

Throws

InvalidParameterException (client fault)

A parameter is specified incorrectly.

Throws

LimitExceededException (client fault)

You have reached the maximum number of resources that can be created.

Throws

MalformedQueryException (client fault)

The query string is not valid. Details about this error are displayed in a QueryCompileError object. For more information, see QueryCompileError.

For more information about valid query syntax, see CloudWatch Logs Insights Query Syntax.

Throws

ResourceNotFoundException (client fault)

The specified resource does not exist.

Throws

ServiceUnavailableException (server fault)

The service cannot complete the request.

Hierarchy

Constructors

Properties

middlewareStack: MiddlewareStack<StartQueryCommandInput, StartQueryCommandOutput>

Methods