Stream Stripe charges to Datadog as business metrics

By General Input

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.

Integrations

  • Stripe
  • Datadog

Type

Deterministic Code

Categories

  • Engineering
  • Operations

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).

Related prompts

Explore more prompts
Let support send one-off Loops emails without an engineerCustomer lifecycle inspector for Loops, Stripe and PostHogMonth-end Stripe finance pack, stored and shared in SlackRank your Intercom queue by what each customer pays youCatch the trials quietly dying before the card gets chargedWork every open Stripe dispute from one chargeback war roomLook up any customer's support, billing and CRM in one pageInvestor update studio that builds your board deck monthlySell and invoice Ghost newsletter sponsor slots in one boardSupport console that pairs Gladly chats with orders and refunds