Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Lambda timeout & refactor timeout names #65

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions serverless/DEVELOPER_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ When deploying your connector using one-click deployment the following parameter
- LogLevel
- MemorySize
- ReadThrottlingBurstLimit
- TimeoutInMillis
- ApiGatewayTimeoutInMillis
- LambdaTimeoutInSeconds
- WriteThrottlingBurstLimit

The `DefaultDatabase`, `DefaultTable` and `LogLevel` may be altered to fit your needs, all other parameters will not require altering for the standard deployment. The `DefaultDatabase` and `DefaultTable` determine the ingestion destination, and `LogLevel` can be set to `info`, `debug`, `warn`, or `error`.
Expand Down Expand Up @@ -98,7 +99,7 @@ The steps to deploy a template are as follows:
To override default parameter values use the `--parameter-overrides` argument and provide a string with format ParameterKey=ParameterValue. For example:

```shell
sam deploy --parameter-overrides "TimeoutInMillis=60000 DefaultDatabase=<CustomDatabase>"
sam deploy --parameter-overrides "LambdaTimeoutInSeconds=50 ApiGatewayTimeoutInMillis=60000 DefaultDatabase=<CustomDatabase>"
```
You can view the full set of parameters defined for `serverless/template.yml` below, in [AWS Lambda Configuration Options](#aws-lambda-configuration-options).

Expand Down Expand Up @@ -213,7 +214,8 @@ Follow the verification steps in [README.md#verification](../README.md#verificat
| DefaultDatabase | The Prometheus label containing the database name. | PrometheusDatabase |
| DefaultTable | The Prometheus label containing the table name. | PrometheusMetricsTable |
| MemorySize | The memory size of the AWS Lambda function. | 512 |
| TimeoutInMillis | The amount of time in milliseconds to run the connector on AWS Lambda before timing out. | 30000 |
| ApiGatewayTimeoutInMillis | The maximum amount of time in milliseconds an API Gateway event will wait before timing out. | 30000 |
| LambdaTimeoutInSeconds | The amount of time in seconds to run the connector on AWS Lambda before timing out. | 30 |
| ReadThrottlingBurstLimit | The number of burst read requests per second that API Gateway permits. | 1200 |
| WriteThrottlingBurstLimit | The number of burst write requests per second that API Gateway permits. | 1200 |

Expand Down Expand Up @@ -641,13 +643,23 @@ See the list below for parameters whose values that may result in resource confl

### AWS Lambda Timeout or HTTP Status 404 Not Found

If the Lambda `TimeoutInMillis` parameter is too small or a PromQL query exceeds the `TimeoutInMillis` value a
If the Lambda `ApiGatewayTimeoutInMillis` parameter is too small or a PromQL query exceeds the `ApiGatewayTimeoutInMillis` value a

```shell
remote_read: remote server https://api-id.execute-api.region.amazonaws.com/dev/read returned HTTP status 404 Not Found: {"message":"Not Found"}
```

error could be returned. If you encounter this error first try overriding the default value for `TimeoutInMillis` (30 seconds) with a greater value using the [`--parameter-overrides` option for `sam deploy`](#aws-cli-deployment).
error could be returned. If you encounter this error first try overriding the default value for `ApiGatewayTimeoutInMillis` (30 seconds) with a greater value using the [`--parameter-overrides` option for `sam deploy`](#aws-cli-deployment).

### Task Timed Out Error

If the `LambdaTimeoutInSeconds` value is too small then a

```shell
Task timed out after <seconds> seconds
```

error could be logged. If you encounter this error try increasing the value of `LambdaTimeoutInSeconds` (30 seconds) with a greater value using the [`--parameter-overrides` option for `sam deploy`](#aws-cli-deployment).

## Caveats

Expand All @@ -662,4 +674,4 @@ During **production**, enable TLS encryption through Amazon API Gateway, see [Co

## License

This project is licensed under the Apache 2.0 License.
This project is licensed under the Apache 2.0 License.
14 changes: 10 additions & 4 deletions serverless/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ Parameters:
MinValue: 128
MaxValue: 8192
Description: "The memory size of Lambda function."
TimeoutInMillis:
ApiGatewayTimeoutInMillis:
Type: Number
MinValue: 2
Default: 30000
Description: "The amount of time in milliseconds to run the connector on AWS Lambda before timing out."
Description: "The maximum amount of time in milliseconds an API Gateway event will wait before timing out."
LambdaTimeoutInSeconds:
Type: Number
MinValue: 3
Default: 30
Description: "The amount of time in seconds to run the connector on AWS Lambda before timing out."
ReadThrottlingBurstLimit:
Type: Number
Default: 1200
Expand Down Expand Up @@ -88,6 +93,7 @@ Resources:
Description: "Prometheus remote storage connector for Amazon Timestream"
Handler: "bootstrap"
MemorySize: !Ref "MemorySize"
Timeout: !Ref LambdaTimeoutInSeconds
Runtime: "provided.al2023"
Environment:
Variables:
Expand All @@ -102,7 +108,7 @@ Resources:
ApiId: !Ref APIGateway
Method: POST
Path: /write
TimeoutInMillis: !Ref TimeoutInMillis
TimeoutInMillis: !Ref ApiGatewayTimeoutInMillis
RouteSettings:
ThrottlingBurstLimit: !Ref "WriteThrottlingBurstLimit"

Expand All @@ -112,7 +118,7 @@ Resources:
ApiId: !Ref APIGateway
Method: POST
Path: /read
TimeoutInMillis: !Ref TimeoutInMillis
TimeoutInMillis: !Ref ApiGatewayTimeoutInMillis
RouteSettings:
ThrottlingBurstLimit: !Ref "ReadThrottlingBurstLimit"

Expand Down
Loading