Coder Social home page Coder Social logo

mikaelvesavuori / serverless-observability-example Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 703 KB

Presents a complete project to demonstrate a 'broken' observable serverless application.

License: MIT License

TypeScript 92.39% JavaScript 4.04% Shell 3.58%
aws demo example honeycomb honeycombio observability serverless datadog

serverless-observability-example's Introduction

Serverless Observability example: AWS + Honeycomb or Datadog

This repo presents a complete project to demonstrate a "broken" observable serverless application.

This project is built using Typescript and runs on API Gateway and Lambda. It is composed of two separate backend services ("internal") and one mock server on Mockachino ("external") that serves a subset of the content.

Additionally, there is a set of AWS CloudWatch alerts included to demonstrate such usage.

Diagram

The below diagram gives an indicative sense of the overall flow.

Serverless Observability example diagram

Prerequisites

It is assumed that:

  • You have a recent Node.js version installed (ideally version 18 or later)
  • You have an AWS account
  • You have sufficient privileges to deploy infrastructure such as Lambda, API Gateway and S3 to AWS
  • You are logged into AWS through your environment

Deployment

Version 2.0 introduced support for Datadog in addition to the existing Honeycomb support. It won't quite be as a rich an experience as using Honeycomb but it will definitely be servicable.

The instructions below relate broadly to either tool. When it comes to getting API keys and such, please refer to Datadog's own instructions.

Make sure to check the respective serverless.yml files for the services and remove anything you don't want to use.

1. Get a free Honeycomb account and API key

Go to Honeycomb and get a free, generous account.

Create an API key for a new environment. Note the environment name and key for later.

For more information, refer to https://docs.honeycomb.io/getting-data-in/api-keys/.

2. Set up GreetingPhrase

Open up code/GreetingPhrase and follow the instructions there on how to put up a new Mockachino endpoint with the JSON contents in the folder.

Save the endpoint URL for the third step.

3. Deploy User service

Go to code/User and update the following values in serverless.yml with those you got from Honeycomb:

  • LIBHONEY_DATASET: Name of your dataset
  • LIBHONEY_API_KEY: The actual API key

Next, run npm install (or yarn install) and deploy with npm run deploy (or yarn run deploy).

Save the endpoint URL for the third step.

4. Deploy Greet service

Go to code/User and update the following values in serverless.yml with those you got from Honeycomb:

  • LIBHONEY_DATASET: Name of your dataset
  • LIBHONEY_API_KEY: The actual API key

Also edit the following fields to the values you've saved from before:

  • GREETING_PHRASES_SERVICE_URL to the Mockachino endpoint URL
  • GET_USER_NAME_SERVICE_URL to the User service endpoint URL on AWS
  • Set custom.aws.awsAccountNumber to your AWS account number
  • Optionally: Set custom.aws.eventBusName to the event bus name you have changed it (default: observabilitydemo)

Install the dependencies with npm install or yarn install, then deploy the service with npm run deploy (or yarn run deploy).

5. Run a bit of test traffic to create logs and traces

You can either do a crude manual call like curl -X POST -d '{"id":1}' https://RANDOM.execute-api.REGION.amazonaws.com/greet or use k6.

To use k6 you will first need to install it. Go to the load folder and run npm run install:k6 which will use homebrew to install k6.

Then, you will need to modify the load testing script (test.js), ensuring the endpoint is updated to your own greet endpoint. Now you should be able to run it with npm test. Feel free to modify the settings as you please.

6. Check and observe!

Honeycomb will get logs streamed continuously from AWS. You should be able to see logs both in AWS CloudWatch as well as in Honeycomb now.

serverless-observability-example's People

Contributors

mikaelvesavuori avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.