Stream Stripe charges to Datadog as business metrics
Every Stripe charge becomes a Datadog metric and a dashboard annotation, so revenue dips show up next to deploys and infra alerts on the same graph.
Build me a deterministic, code-based workflow that pumps Stripe charges into Datadog as live business metrics and dashboard events. No reasoning is needed once the field map is set.
Trigger: a Stripe webhook on the charge.succeeded and charge.failed events.
For each incoming event, parse the Stripe charge payload and extract: charge id, customer id, amount (in the smallest currency unit), currency, payment_method, payment_method_details.type, status (succeeded or failed), and failure_code plus failure_message when present.
Then do these two things in parallel:
1) Call Datadog Submit Metrics (V2) to send two time-series for this charge. First, a counter metric named stripe.charges.count with value 1, tagged with currency, payment_method, and outcome (succeeded or failed). Second, a gauge metric named stripe.charges.amount with value equal to the Stripe amount in the smallest currency unit, tagged with the same currency, payment_method, and outcome. Use the current event timestamp as the metric timestamp.
2) Call Datadog Post an Event with a one-line title describing the charge (for example, "Stripe charge succeeded: 4200 usd" or "Stripe charge failed: card_declined"), a body containing the charge id and customer id (and the failure_code and failure_message if the charge failed), alert_type set to info for succeeded charges and warning for failed charges, and the same currency, payment_method, and outcome tags. This makes each charge appear as an annotation on Datadog dashboards.
The point of the workflow is to let engineering correlate revenue regressions with infra issues on a single Datadog dashboard. Strict field map, no judgment calls in the workflow itself.
Integrations: Stripe (webhook trigger) and Datadog (Submit Metrics V2 and Post an Event).
Additional information
What does this prompt do?
- Listens for every successful and failed Stripe charge in real time.
- Records the charge count and charge amount as live Datadog metrics, broken down by currency, payment method, and outcome.
- Posts each charge to your Datadog event stream, so it appears as an annotation across infra dashboards.
- Lets on-call engineers see at a glance whether a revenue drop lines up with a deploy, outage, or latency spike.
What do I need to use this?
- A Stripe account with permission to send webhooks.
- A Datadog account, plus an API key and an application key.
- A Datadog dashboard where you want the revenue graph and event annotations to appear (optional, but where the value shows up).
How can I customize it?
- Add extra tags by mapping more Stripe fields, like plan name, country, or product id.
- Expand the trigger to cover refunds, disputes, or invoice payments alongside charges.
- Set succeeded charges to post as info events and failed charges as warnings, or raise failures to a higher alert level.
Frequently asked questions
Will this slow down checkout or affect my customers?
Do I have to install the Datadog agent for this to work?
Can I see successful and failed charges on the same chart?
Does this work with non-US Datadog regions?
What happens if a charge event arrives while Datadog is down?
Put revenue on the same dashboard as your infra.
Connect Stripe and Datadog once, and every charge flows in as a live metric and a dashboard annotation.