A lightweight TypeScript library for sending events to Datadog's Events API. Can be used both as an npm package in your code and as a GitHub Action in your workflows.
gh-datadog-event makes it easy to send custom events to your Datadog dashboard from any Node.js application or GitHub workflow. Use it to track deployments, mark significant application events, or create custom alerts.
npm install gh-datadog-event
import { CreateEvent } from 'gh-datadog-event';
// Set your Datadog API and APP keys as environment variables
// process.env.DATADOG_API_KEY = 'your-api-key';
// process.env.DATADOG_APP_KEY = 'your-app-key';
async function sendDeploymentEvent() {
const results = await CreateEvent({
requests: [
{
title: 'Deployment Completed',
text: 'Service successfully deployed to production',
alertType: 'info',
priority: 'normal',
tags: ['environment:production', 'service:api', 'team:backend']
}
]
});
console.log(`Event created: ${results[0].eventUrl}`);
}
sendDeploymentEvent();
You can also use this package as a GitHub Action in your workflows to send events to Datadog.
name: Deploy and Notify
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# Your deployment steps here...
- name: Notify Datadog of deployment
uses: sds9-org/datadog-event@v2
with:
title: 'Deployment to Production'
text: 'New version deployed to production environment'
alertType: 'info'
priority: 'normal'
tags: 'environment:production,service:api'
includeGitHubContext: 'true'
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DATADOG_APP_KEY: ${{ secrets.DATADOG_APP_KEY }}
| Input | Description | Required | Default |
|---|---|---|---|
title |
Title of the event | Yes | |
text |
Text description of the event | Yes | |
alertType |
Type of alert (e.g., "error", "warning", "info") | No | info |
priority |
Priority of the event (e.g., "normal", "low") | No | normal |
host |
Host associated with the event | No | |
tags |
Comma-separated list of tags | No | |
aggregationKey |
Key to group events together | No | |
sourceTypeName |
Source type name for the event | No | |
includeGitHubContext |
Whether to include GitHub context in tags | No | true |
| Output | Description |
|---|---|
eventUrl |
URL of the created event in Datadog |
eventId |
ID of the created event |
CreateEventMain function for creating events in Datadog.
See the API documentation for detailed information about the function parameters and return types.
To use this library, you need a Datadog API key:
For additional functionality, you may also want an Application key:
For more information about Datadog events, see the official Datadog Events documentation.
Contributions are welcome! Please follow these steps: