Log weekly Segment data volume to Sheets with Slack alerts
Every Monday, last week's data volume lands in a spreadsheet and your ops channel gets the totals, the biggest sources, and a warning on anything spiking.
Every Monday at 8am, log my Segment ingestion volume to a Google Sheet and post a summary to Slack, so I can see cost trends long before the invoice lands. Build this as a deterministic code workflow: fetch, format, append, post. Every step runs over structured numbers and no step requires judgement.
Start with the Segment operation Get Daily Per-Source API Calls Usage to pull daily API call counts per Source for the previous seven full days, meaning the Monday through Sunday window that ended yesterday. Do not include today, because the current day is still partial and would understate the count. Note that the Segment Public API is only available on Team and Business tier workspaces, so surface a clear error if the credential comes back unauthorized.
Append one row per source per day to a tracking tab in a Google Sheet I will specify, using Append Values. Each row has exactly three columns: the date in YYYY-MM-DD format, the source name, and the API call count. Use the Source name from the usage response and fall back to the Source ID when no name is present. If the tracking tab is empty, write a header row of Date, Source, API Calls first. Order the rows by date ascending and then by source name so the sheet reads chronologically.
Before appending, read the existing rows with Get Values and skip any date and source combination that is already present, so a re-run never double counts. This sheet is the permanent history that Segment's own usage screen does not retain, so never overwrite, clear, or reorder existing rows. Only ever append.
Then compute the comparison from the rows already in the sheet, not from a second Segment call. Read the tracking tab and total the seven day window immediately before the one just written. Calculate the total API calls for the new week, the total for the prior week, and the percentage change between them, and do the same per source.
Post a message to my operations channel in Slack using Send a Message. Include the weekly total with its percentage change against the prior week, then a per source breakdown ranked from highest to lowest volume where each line shows the source name, its call count, and its own percentage change. Finish with a flagged list of any single source whose volume grew more than 25 percent week over week, called out explicitly as a likely runaway client side event firing in a loop, since that is usually the cause. The 25 percent flag is a fixed arithmetic comparison, not a reasoning step.
Handle the edge cases deterministically. On the first run there is no prior week in the sheet, so report the totals and state that there is no baseline yet instead of printing percentages. A source with volume this week but none in the prior week is labelled new rather than infinite percent growth. A source that reported last week but is at zero this week is listed at zero and flagged as stopped, because silent ingestion loss matters as much as a spike. Round every percentage to one decimal place and format call counts with thousands separators.
Example output
What does this prompt do?
- Every Monday, pulls last week's daily data volume for each of your Segment sources and files it in a spreadsheet, one row per source per day.
- Builds a permanent history of your usage, so you can chart months of trends even though Segment only shows the current billing period.
- Posts a weekly recap to your operations channel with the total, a ranked breakdown by source, and how each one changed against the week before.
- Flags any source that grew more than 25 percent in a week, the usual sign of a runaway tracking event firing in a loop.
What do I need to use this?
- A Segment workspace on a Team or Business plan, since usage reporting is not available on the free plan.
- A Google account and a spreadsheet with a tab set aside for the running history.
- A Slack workspace and the channel your operations team actually watches.
How can I customize it?
- Change the timing. Monday at 8am is just a default, and a monthly run works fine if you only care at invoice time.
- Move the alert threshold. 25 percent growth is the default flag, so tighten it for high volume sources or loosen it if your traffic is naturally spiky.
- Pick a different destination. Send the recap to a private channel, a direct message, or your finance channel instead of general operations.
FAQs
Will this work on a free Segment plan?
Why keep the data in a spreadsheet at all?
What happens the first time it runs?
Will it duplicate rows if it runs twice?
Why flag growth at 25 percent?
Related templates
When your flight moves, your calendar times get corrected automatically and you get a Slack note naming the meetings you're about to miss.
Every 15 minutes, forwarded phishing reports get traced back to the server that really sent them, with a verdict in Slack and the worst senders reported.
Every Monday, check every S3 bucket for public exposure, missing encryption and weak backup settings, then get the risks ranked in Slack.
Every weekday at 7am, sign in to the tender portals you track, filter new notices against your bid criteria, and open a deal for the ones worth chasing.
Every weekday at 4pm, spot the threads that went quiet, stage a ready-to-send nudge in your mailbox, and get a ranked Slack recap.
Every Monday, rank the week's matches by expected demand, put the big ones on your venue calendar, and post a rota-ready summary to Slack.
Know what your customer data costs before the invoice lands.
Keep a running history of your data volume and hear about the spikes the week they happen, not when the bill shows up.