GithubHelp home page GithubHelp logo

isabella232 / datadog-2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zendesk/datadog

0.0 0.0 0.0 816 KB

Send Datadog metrics and events from GitHub workflows

License: MIT License

TypeScript 97.42% JavaScript 2.58%

datadog-2's Introduction

Datadog Action

build-test

This Action lets you send events and metrics to Datadog from a GitHub workflow.

Usage

The action can send metrics and events to any Datadog site by setting the api-url param. When omitted, it defaults to the US endpoint: https://api.datadoghq.com.

Please note how metrics is defined as a string containing YAML code - this allows to send more than one metric at once if needed. To send one metric, configure a job step like the following:

- name: Build count
  uses: masci/datadog@v1
  with:
    api-key: ${{ secrets.DATADOG_API_KEY }}
    metrics: |
      - type: "count"
        name: "test.runs.count"
        value: 1.0
        host: ${{ github.repository_owner }}
        tags:
          - "project:${{ github.repository }}"
          - "branch:${{ github.head_ref }}"

You can also send Datadog events from workflows, same as metric please note how events is indeed a string containing YAML code. For example, an use case might be sending an event when a job has failed:

steps:
  - name: checkout
    uses: actions/checkout@v2
  - name: build
    run: this-will-fail
  - name: Datadog
    if: failure()
    uses: masci/datadog@v1
    with:
      api-key: ${{ secrets.DATADOG_API_KEY }}
      events: |
        - title: "Failed building Foo"
          text: "Branch ${{ github.head_ref }} failed to build"
          alert_type: "error"
          host: ${{ github.repository_owner }}
          tags:
            - "project:${{ github.repository }}"

You can also send Datadog service checks from workflows, same as others please note how service-checks is indeed a string containing YAML code. For example, an use case might be sending when a job has failed:

steps:
  - name: checkout
    uses: actions/checkout@v2
  - name: build
    run: this-will-fail
  - name: Datadog
    if: failure()
    uses: masci/datadog@v1
    with:
      api-key: ${{ secrets.DATADOG_API_KEY }}
      service-checks: |
        - check: "app.ok"
          message: "Branch ${{ github.head_ref }} failed to build"
          status: 0
          host_name: ${{ github.repository_owner }}
          tags:
            - "project:${{ github.repository }}"

You can also send Datadog logs from workflows, same as others please note how logs is indeed a string containing YAML code. For example, an use case might be sending when a job has failed:

steps:
  - name: checkout
    uses: actions/checkout@v2
  - name: build
    run: this-will-fail
  - name: Datadog
    if: failure()
    uses: masci/datadog@v1
    with:
      api-key: ${{ secrets.DATADOG_API_KEY }}
      logs: |
        - ddsource: "nginx"
          ddtags: "env:staging,version:5.1"
          hostname: "i-012345678"
          message: "{\"message\":\"2019-11-19T14:37:58,995 ERROR [process.name][20081] Hello World\", \"level\":\"error\"}"
          service: "payment"

Development

Install the dependencies

$ npm install

Lint, test and build the typescript and package it for distribution

$ npm run all

Run the tests ✔️

$ npm test

> [email protected] test /datadog
> jest

 PASS  __tests__/main.test.ts
  unit-tests
    ✓ api-key input param must be set (3 ms)
    ✓ default api endpoint URL (1 ms)
    ✓ custom api endpoint URL
    ✓ run calls the sending functions (1 ms)
  end-to-end tests
    ✓ actually sends data to the backend when DD_API_KEY env var is set
...
Ran all test suites.

When the DD_API_KEY env var is set with a valid API Key, the tests will also perform an actual call sending some metrics, events and service checks.

datadog-2's People

Contributors

dependabot[bot] avatar masci avatar trfv 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.