Code Monkey home page Code Monkey logo

datadog-synthetic-scheduler's Introduction

Datadog Synthetic Scheduler

This solution helps you to schedule Datadog Synthetics (API and Browser tests) for a specific time-slot. This can save you money if you don't need the results 24/7.

โ— This solution will create several resources which will be billed by AWS.

Base architecture

An AWS EventBridge rule starts an AWS Lambda function at the time you specified. This function retrieves the credentials from the AWS Secrets Manager. After having the credentials, it calls the Datadog Rest API to start the configured Synthetic. A second AWS EventBridge rule starts a second AWS Lambda function to do nearly the same. But this time, the Synthetic is paused.

Used AWS Services

  • AWS Secrets Manager
  • AWS EventBridge
  • AWS Lambda
  • AWS X-Ray
  • AWS Cloudwatch

Implementation guide

Please follow all the steps below to deploy the solution. Please pay attention that the solution only can be deployed in a region where all mentioned services above are available.

Requirements

  • Python 3 (tested with version 3.8.0)
  • Node.js (tested with version 12.12.0)
  • Serverless (tested with version 1.57.0)

Deploy the solution

  1. Clone this repository
  2. Edit the parameters in the serverless.yml
  • syntheticStart: Cron-expression when to start the Synthetic (see documentation)
  • syntheticStop: Cron-expression when to stop the Synthetic (see documentation)
  • syntheticPublicId: Public ID of the synthetic. You can find the public ID if you switch to the Synthetic in your browser. The url should look like this: https://app.datadoghq.eu/synthetics/details/123-abc-456a The Id can be found at the end of the url: 123-abc-456 is the public id in this case.
  • datadogApiEndpoint: Suitable endpoints can be found here. (EU site: https://api.datadoghq.com/api/ // US site: https://api.datadoghq.com/api/)
  1. Deploy the solution to AWS with sls deploy --region eu-central-1 --stage dev.
  2. Switch to the AWS Console and the Service Secrets Manager. Edit the value for the secret DatadogSyntheticSchedulerSecret and enter your Datadog API and APP key.

โ— If you want to use this solution for multiple Synthetic tests in one AWS account, you need to modify the service name in the serverless.yml (first line).

Undeploy the solution

Just follow the next steps to undeploy the solution:

  1. Open the AWS Console and clean up the s3 bucket
  2. run sls remove to remove the solution

ToDo list

Code

There are surely ways to improve. Just send a pull request. ๐Ÿ˜‰

datadog-synthetic-scheduler's People

Stargazers

 avatar

Watchers

 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.