All Projects → base2Services → aws-lambda-http-check

base2Services / aws-lambda-http-check

Licence: MIT license
Lambda function to check http endpoint wrapped in serverless project

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to aws-lambda-http-check

cloudwatch-dashboards-cloudformation-sample
A sample project to demonstrate using Cloudformation, how to create and configure CloudWatch metric filters, alarms and a dashboard to monitor an AWS Lambda function.
Stars: ✭ 61 (+103.33%)
Mutual labels:  cloudwatch, aws-cloudwatch
fluent-plugin-cloudwatch-ingest
Alternative to ryotarai/fluent-plugin-cloudwatch-logs for ingesting AWS Cloudwatch logs via fluentd
Stars: ✭ 11 (-63.33%)
Mutual labels:  cloudwatch, aws-cloudwatch
gozeit
GoZeit
Stars: ✭ 19 (-36.67%)
Mutual labels:  lambda, cloudwatch
Awesome Aws
A curated list of awesome Amazon Web Services (AWS) libraries, open source repos, guides, blogs, and other resources. Featuring the Fiery Meter of AWSome.
Stars: ✭ 9,895 (+32883.33%)
Mutual labels:  lambda, cloudwatch
aws-lambda-scheduler
aws-lambda-scheduler is EventBridge Rule manager that lets you call any existing AWS Lambda Function you have in a set future time with pre-set parameters. Allows more rule creation than AWS limit.
Stars: ✭ 58 (+93.33%)
Mutual labels:  lambda, cloudwatch
go-localstack
Go Wrapper for using localstack
Stars: ✭ 56 (+86.67%)
Mutual labels:  lambda, cloudwatch
serverless-plugin-epsagon
Epsagon's plugin for Serverless Framework ⚡️
Stars: ✭ 53 (+76.67%)
Mutual labels:  lambda, monitoring-tool
terraform-aws-lambda-auto-package
A terraform module to define a lambda function which source files are automatically built and packaged for lambda deployment.
Stars: ✭ 23 (-23.33%)
Mutual labels:  lambda
guitarteacher
Guitar Teacher skill for the Amazon Alexa platform
Stars: ✭ 16 (-46.67%)
Mutual labels:  lambda
aws-turn-off-my-account
📦 🚀 📦 Lambda stack to turn off and destroy all resources from your personal AWS Account to avoid billing surprises
Stars: ✭ 63 (+110%)
Mutual labels:  lambda
ecs-drain-lambda
Automation of Draining ECS instances with Lambda, based on Autoscaling Group Lifecycle hooks or Spot Instance Interruption Notices
Stars: ✭ 56 (+86.67%)
Mutual labels:  lambda
terraform-aws-lambda
A Terraform module to create AWS Lambda ressources.
Stars: ✭ 40 (+33.33%)
Mutual labels:  lambda
sqs-to-lambda-async
Process SQS messages with Lambda, asynchronously
Stars: ✭ 27 (-10%)
Mutual labels:  lambda
home-energy-monitor
ESP32-based Home Energy Monitor
Stars: ✭ 152 (+406.67%)
Mutual labels:  lambda
iopipe-java
AWS Lambda telemetry for Java
Stars: ✭ 17 (-43.33%)
Mutual labels:  lambda
serverless-media-portal
Ready-to-deploy webapp for sharing home videos: a React frontend with a AWS Lambda backend using FFmpeg to process videos. Created using Serverless Framework.
Stars: ✭ 90 (+200%)
Mutual labels:  lambda
rust-webassembly-serverless
An AWS lambda function written in Rust using WebAssembly
Stars: ✭ 29 (-3.33%)
Mutual labels:  lambda
s3-db
Document DB API for AWS S3
Stars: ✭ 97 (+223.33%)
Mutual labels:  lambda
SecretsManagerwithCloudFormation
Implements a Lambda-backed CloudFormation Custom Resource for AWS Secrets Manager
Stars: ✭ 20 (-33.33%)
Mutual labels:  lambda
serverless-aws-rust-http
⚡🏗️ template for new aws lambda serverless rust http apps
Stars: ✭ 85 (+183.33%)
Mutual labels:  lambda

Lambda http check

Lambda function to check specific http endpoint, and report on it's availability.

Optionally, it can record metrics to CloudWatch.

Inputs

All inputs are either defined as environment variables or as part of event data. Event data will take priority over environment variables

ENDPOINT - url to be checked

METHOD - http method to use, defaults to GET

PAYLOAD - http payload, if POST or PUT used as method

TIMEOUT - timeout to use for http requests, defaults to 120s

HEADERS - list of percentage sign (%) separated headers to send to target server, defaults to empty list.

USER_AGENT - If specified, will be added to the HEADERS. An example is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Base2/Lambda

REPORT_RESPONSE_BODY - set to 1 if you wish to report on response body, 0 otherwise, 0 otherwise, defaults to 0

REPORT_AS_CW_METRICS - set to 1 if you wish to store reported data as CW custom metrics, 0 otherwise, defaults to 1

CW_METRICS_NAMESPACE - if CW custom metrics are being reported, this will determine their namespace, defaults to 'HttpCheck'

BODY_REGEX_MATCH - if CW custom metrics are being reported, this will enable ResponseBodyRegexMatch metric to be published as well, with value determined by success of matching response body against regular expression contained within this option

STATUS_CODE_MATCH - report whether http status code is equal to given status code or not. If this option is not present, it won't be reported upon. Defaults to empty

FAIL_ON_STATUS_CODE_MISMATCH - if checking for status code match treat mismatch as failure, ie report Available: 0

Outputs

By default, following properties will be rendered in output Json

Reason - Reason

Available - 0 or 1

TimeTaken - Time in ms it took to get response from remote server. Default timeout is 2 minutes for http requests.

StatusCode - Http Status Code

ResponseBody - Optional, by default this won't be reported

ResponseBodyRegexMatch - Optional, if BODY_REGEX_MATCH option is provided

StatusCodeMatch - Optional, if STATUS_CODE_MATCH options is provided

Dependencies

Lambda function is having no external dependencies by design, so no additional packaging steps are required for deploying it, such as doing pip install [libname]

CloudWatch Metrics

In order to get some metrics which you can alert on, REPORT_AS_CW_METRICS and CW_METRICS_NAMESPACE environment variables are used. Following metrics will be reported

  • Available - 0 or 1, whether response was received in timely manner, indicating problems with network, DNS lookup or server timeout

  • TimeTaken - Time taken to fetch response, reported in milliseconds

  • StatusCode - HTTP Status code received from server

  • ResponseBodyRegexMatch - optional this will report 1 or 0 if BODY_REGEX_MATCH option is specified. 1 is reported if response body matches regex provided, or 0 otherwise.

  • StatusCodeMatch - *optional& this will report 1 or 0 if STATUS_CODE_MATCH options is specified. 1 is reported if response status code matches code provided, or 0 otherwise

Deployment

You can either deploy Lambda manually, or through AWS SAM CLI. If the SAM CLI is being chosen as method of deployments use command below, while making sure that you have setup access to your AWS account.

build the lambda

sam build

deploy the template

sam deploy --guided

If you are setting up your Lambda function by hand, make sure it has proper IAM permissions to push Cloud Watch metrics data, and to write to CloudWatch logs

Testing

To test function locally with simple Google url (default), run following

sam local invoke Check

Optionally, for complicated example take a look at test/ipify.json file

sam local invoke Check --event test/ipify.json 

Debugging

If you wish to see debug output for http request, set HTTP_DEBUG environment variable to '1'. This can't be controlled through event payload.

Schedule execution

Pull requests are welcome to serverless project to deploy CloudWatch rules in order to schedule execution of Http Checking Lambda function.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].