Skip to content

Commit

Permalink
Add cloudwatch-logs StartQuery and GetQueryResults
Browse files Browse the repository at this point in the history
  • Loading branch information
filmaj authored and ryanblock committed May 22, 2024
1 parent d94c7eb commit 77b39c9
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 5 deletions.
32 changes: 30 additions & 2 deletions plugins/cloudwatch-logs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,36 @@ Properties:
- Enable automatic result pagination; use this instead of making your own individual pagination requests


### `GetQueryResults`

[Canonical AWS API doc](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_GetQueryResults.html)

Properties:
- **`queryId` (string)**
- The ID of the query


### `StartQuery`

[Canonical AWS API doc](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_StartQuery.html)

Properties:
- **`endTime` (number)**
- End of the time range in epoch seconds
- **`limit` (number)**
- Maximum number of items to evaluate and return
- **`logGroupIdentifiers` (array)**
- List of log groups to query. `StartQuery` requires exactly one of `logGroupName`, `logGroupNames` or `logGroupIdentifiers`.
- **`logGroupName` (string)**
- Name of the log group
- **`logGroupNames` (array)**
- List of log groups to query. `StartQuery` requires exactly one of `logGroupName`, `logGroupNames` or `logGroupIdentifiers`.
- **`query` (string)**
- The query string to use
- **`startTime` (number)**
- Start of the time range in epoch seconds


### Methods yet to be implemented

> Please help out by [opening a PR](https://github.com/architect/aws-lite#authoring-aws-lite-plugins)!
Expand Down Expand Up @@ -161,7 +191,6 @@ Properties:
- [`GetLogAnomalyDetector`](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_GetLogAnomalyDetector.html)
- [`GetLogGroupFields`](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_GetLogGroupFields.html)
- [`GetLogRecord`](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_GetLogRecord.html)
- [`GetQueryResults`](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_GetQueryResults.html)
- [`ListAnomalies`](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_ListAnomalies.html)
- [`ListLogAnomalyDetectors`](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_ListLogAnomalyDetectors.html)
- [`ListTagsForResource`](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_ListTagsForResource.html)
Expand All @@ -180,7 +209,6 @@ Properties:
- [`PutRetentionPolicy`](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutRetentionPolicy.html)
- [`PutSubscriptionFilter`](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutSubscriptionFilter.html)
- [`StartLiveTail`](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_StartLiveTail.html)
- [`StartQuery`](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_StartQuery.html)
- [`StopQuery`](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_StopQuery.html)
- [`TagLogGroup`](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_TagLogGroup.html)
- [`TagResource`](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_TagResource.html)
Expand Down
2 changes: 0 additions & 2 deletions plugins/cloudwatch-logs/src/incomplete.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export default {
GetLogAnomalyDetector: { disabled, awsDoc: docRoot + 'API_GetLogAnomalyDetector.html' },
GetLogGroupFields: { disabled, awsDoc: docRoot + 'API_GetLogGroupFields.html' },
GetLogRecord: { disabled, awsDoc: docRoot + 'API_GetLogRecord.html' },
GetQueryResults: { disabled, awsDoc: docRoot + 'API_GetQueryResults.html' },
ListAnomalies: { disabled, awsDoc: docRoot + 'API_ListAnomalies.html' },
ListLogAnomalyDetectors: { disabled, awsDoc: docRoot + 'API_ListLogAnomalyDetectors.html' },
ListTagsForResource: { disabled, awsDoc: docRoot + 'API_ListTagsForResource.html' },
Expand All @@ -62,7 +61,6 @@ export default {
PutRetentionPolicy: { disabled, awsDoc: docRoot + 'API_PutRetentionPolicy.html' },
PutSubscriptionFilter: { disabled, awsDoc: docRoot + 'API_PutSubscriptionFilter.html' },
StartLiveTail: { disabled, awsDoc: docRoot + 'API_StartLiveTail.html' },
StartQuery: { disabled, awsDoc: docRoot + 'API_StartQuery.html' },
StopQuery: { disabled, awsDoc: docRoot + 'API_StopQuery.html' },
TagLogGroup: { disabled, awsDoc: docRoot + 'API_TagLogGroup.html' },
TagResource: { disabled, awsDoc: docRoot + 'API_TagResource.html' },
Expand Down
38 changes: 37 additions & 1 deletion plugins/cloudwatch-logs/src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,45 @@ const GetLogEvents = {
response: defaultResponse,
}

const GetQueryResults = {
awsDoc: docRoot + 'API_GetQueryResults.html',
validate: {
queryId: { ...str, comment: 'The ID of the query' },
},
request: (params) => {
return {
awsjson: false,
headers: headers('GetQueryResults'),
payload: params,
}
},
response: defaultResponse,
}

const StartQuery = {
awsDoc: docRoot + 'API_StartQuery.html',
validate: {
endTime: { ...num, comment: 'End of the time range in epoch seconds' },
limit,
logGroupIdentifiers: { ...arr, comment: 'List of log groups to query. `StartQuery` requires exactly one of `logGroupName`, `logGroupNames` or `logGroupIdentifiers`.' },
logGroupName,
logGroupNames: { ...arr, comment: 'List of log groups to query. `StartQuery` requires exactly one of `logGroupName`, `logGroupNames` or `logGroupIdentifiers`.' },
query: { ...str, comment: 'The query string to use' },
startTime: { ...num, comment: 'Start of the time range in epoch seconds' },
},
request: (params) => {
return {
awsjson: false,
headers: headers('StartQuery'),
payload: params,
}
},
response: defaultResponse,
}

export default {
name: '@aws-lite/cloudwatch-logs',
service,
property,
methods: { DeleteLogGroup, DescribeLogGroups, DescribeLogStreams, GetLogEvents, ...incomplete },
methods: { DeleteLogGroup, DescribeLogGroups, DescribeLogStreams, GetLogEvents, GetQueryResults, StartQuery, ...incomplete },
}
16 changes: 16 additions & 0 deletions plugins/cloudwatch-logs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
DescribeLogGroupsCommandOutput as DescribeLogGroupsResponse,
DescribeLogStreamsCommandOutput as DescribeLogStreamsResponse,
GetLogEventsCommandOutput as GetLogEventsResponse,
GetQueryResultsCommandOutput as GetQueryResultsResponse,
StartQueryCommandOutput as StartQueryResponse,
// $IMPORTS_END
} from "@aws-sdk/client-cloudwatch-logs";

Expand Down Expand Up @@ -35,6 +37,18 @@ declare interface AwsLiteCloudWatchLogs {
* - aws-lite docs: {@link https://github.com/architect/aws-lite/blob/main/plugins/cloudwatch-logs/readme.md#GetLogEvents CloudWatch Logs: GetLogEvents}
*/
GetLogEvents: (input: { endTime?: number, limit?: number, logGroupIdentifier?: string, logGroupName?: string, logStreamName: string, nextToken?: string, startFromHead?: boolean, startTime?: number, unmask?: boolean, paginate?: boolean }) => Promise<GetLogEventsResponse>
/**
* @description
* - AWS docs: {@link https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_GetQueryResults.html CloudWatch Logs: GetQueryResults}
* - aws-lite docs: {@link https://github.com/architect/aws-lite/blob/main/plugins/cloudwatch-logs/readme.md#GetQueryResults CloudWatch Logs: GetQueryResults}
*/
GetQueryResults: (input: { queryId?: string }) => Promise<GetQueryResultsResponse>
/**
* @description
* - AWS docs: {@link https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_StartQuery.html CloudWatch Logs: StartQuery}
* - aws-lite docs: {@link https://github.com/architect/aws-lite/blob/main/plugins/cloudwatch-logs/readme.md#StartQuery CloudWatch Logs: StartQuery}
*/
StartQuery: (input: { endTime?: number, limit?: number, logGroupIdentifiers?: any[], logGroupName?: string, logGroupNames?: any[], query?: string, startTime?: number }) => Promise<StartQueryResponse>
// $METHODS_END
}

Expand All @@ -52,5 +66,7 @@ export type {
DescribeLogGroupsResponse,
DescribeLogStreamsResponse,
GetLogEventsResponse,
GetQueryResultsResponse,
StartQueryResponse,
// $EXPORT_END
}

0 comments on commit 77b39c9

Please sign in to comment.