This is a simple Flask app that provides an endpoint to receive events from Segment via the webhooks destination. The flask app will forward the received events to Datadog as a counter.
- Heroku account to deploy this app.
- Segment account with your source events.
- Datadog account where your events will be forwarded.
- Heroku Python Buildpack (for Heroku deployment).
- Heroku Datadog Buildpack to run Datadog Agent within Heroku.
- Datadog Python SDK.
- Flask to implement the API.
- Deploy this app in Heroku:
- Set the corresponding keys (you can access your Datadog keys here):
- DD_API_KEY: Your Datadog API key.
- DD_APP_KEY: Your Datadog app key.
- DD_HOSTNAME: Name of your Heroku app.
- SEGMENT_SHARED_SECRET: Your Segment Webhooks destination Shared Secret.
- Add Webhooks destination in your Segment project.
- Configure your Webhooks destination by setting the webhook URL to your Heroku app, eg: https://<APP_NAME>.herokuapp.com/api/<SOURCE>, where APP_NAME is your Heroku app name and SOURCE should be the name of the Segment source you are retrieving events from.
- Activate the webhook destination.
- You should start receiving events in your Datadog dashboard, named segment.event. Datadog tags are included like source, type and event (segment source, type of event (track) and event name, respectively). You can customize app.py file to add your own tags or also monitor other type of events, eg: page events.