GithubHelp home page GithubHelp logo

jessflan / cfn-datadog Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nordcloud/cfn-datadog

0.0 2.0 0.0 16 KB

🐕⚙️Cloudformation custom resources that integrate with datadog

License: Apache License 2.0

Python 98.79% Shell 1.21%

cfn-datadog's Introduction

README

What is this repository for?

  • To setup datadog monitoring via cloudformation

What does it do?

It setups a lambda function that communicate with the monitors and timeboard resource on the datadog api

https://docs.datadoghq.com/api/#monitors https://docs.datadoghq.com/api/#timeboards

The lambda is invoked via cloudformation custom resource. This repo supplies custom resource classes for all the 4 Monitor types. Custom resources have the same exact data structure as the DD api

It uses https://github.com/nordcloud/cfn-encrypt to securely store datadog api credentials

This repository makes use of Troposphere

How do I get set up?

  • clone this repo
git clone [email protected]:nordcloud/cfn-datadog.git
  • Build the lambda package
chmod +x create_zip.sh && ./create_zip.sh
  • upload datadog_lambda.zip to an s3 bucket
  • get your api and application keys from Datadog
  • generate the lambda template
python lambda-template.py > /tmp/lambda.template

How do i use it to monitor resources created in other stacks?

Install the cfn_datadog library

pip install cfn-encrypt

Import the custom resource classes you want to use

from cfn_datadog import (
    MetricAlert, MetricAlertOptions, Composite, CompositeOptions,
    EventAlert, EvenAlertOptions, ServiceCheck, ServiceCheckOptions,
    Timeboard
)

Add a parameter so that you can reference your lambda stack

datadog_lambda_stackname = t.add_parameter(Parameter(
    "DatadogLambdaStackname",
    Type="String",
    Description="Datadog lambda stackname",
))

Add the custom resource to the template: For documentation see datadog api

Example MetricAlert
t.add_resource(MetricAlert(
    'Alert2',
    query=Join("",["avg(last_1h):avg:system.net.bytes_rcvd{host:",Ref(my_instance),"} < 40"]),
    ServiceToken=ImportValue(
    Sub("${DatadogLambdaStackname}-LambdaArn")),
    name="Bytes received on mytesthost",
    message="Some Message @MyDDHandle",
    tags=["tag1", "tag2"],
    options=MetricAlertOptions(
        notify_no_data= True,
        no_data_timeframe=50
    )
))
Example Timeboard
t.add_resource(Timeboard(
    'ExampleTimeBoard',
    ServiceToken=ImportValue(Sub("${DatadogLambdaStackname}-TimeboardLambdaArn")),
    TimeboardTitle="testboard",
    description="Sample testboard",
    graphs=[Graph(
        definition=Definition(
            events=[],
            requests=[Request(
                q="avg:system.mem.free{*}"
            )],
            viz="timeseries"
        ),
        title="Average Memory Free"
    )],
    template_variables=[TemplateVariable(
        name="host1",
        prefix="host",
        default="host:my-host"
    )],
    read_only=True
))

cfn-datadog's People

Contributors

martinkaberg avatar kisst avatar scholtenmartijn avatar

Watchers

James Cloos 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.