Skip to main content

More detailed usage info via the GraphQL API

Instead of exporting a csv file with usage data we want to retrieve the same information + stack labels with a GraphQL query.
What we are especially interested in is:
TimestampUnix, StateDurationMinutes, RunULID , StackSlug, StackULID, WorkerPoolName, labels

Workaround
Exporting the csv file
Problem
Status: ⬆️ Gathering votes5 comments

Log in to comment and vote

Comments5

  • Ovidiu Moise

    Team•

    Oct 6

    Dear Upvoters, FYI we’ve just launched a new Usage page where you can see, in the UI, your current minutes usage, available burst budget, and you are also now notified in advance about reaching the budget limit, before overages. Please share any feedback, and whether the GraphQL enhancements are still needed.

  • Natalia Gazda

    Team•

    Jun 26, 2025

    Perfect use case! For cost allocation like this, we'd recommend a push-based approach using notification policies rather than extending GraphQL - it'll save you implementation work and give you real-time data.

    We already have this pattern working with our Datadog integration. It uses a notification policy that triggers on run events and pushes structured data via webhook to Datadog's API.

    For your cost allocation system, we could create a similar solution that:

    • Triggers on run completion
    • Sends webhook payload with your required fields: timestamp, duration, stack ULID/slug, worker pool, and most importantly - stack labels for your cost center mapping
    • Pushes directly to your cost collection system's webhook endpoint

    This approach means:

    • No polling logic needed on your side
    • Real-time data as runs complete
    • No missed events or pagination complexity
    • Same reliability as our existing integrations

    What format does your cost collection system expect for webhook payloads? JSON with specific schema, or can you adapt to whatever structure we send?

    • Blue Goose

      •

      Jun 26, 2025

      Thanks for your answer Natalia!
      For the webhook approach I see two issues.
      One we’d have to handle way more data than we do right now when we poll our target systems on a schedule. We’re not treating our system as the primary source for the cost data but only as a collector and don’t have the requirement to be near real-time. We’re more focused on historical data. While me might be able to change that, I don’t think it’d be our preferred way.
      The other is that our system is internal only, at the moment we’d have no public endpoint to push the data from public workers to our system.

      But…! :D
      As we’re using Datadog anyways I will look into the Datadog integration and we might be able to pull our data from there.

      Will report back.


      Thanks!
      Marc

  • Blue Goose

    •

    Jun 26, 2025

    Hi Marcin, missed the mail informing me of your answer.

    We are providing Spacelift as a central platform in our company and need ways to cross charge our teams. The idea is to label the stacks with Cost Center ID and Cost Center responsible.
    The idea is to split the costs then based on usage, probably worker minutes.
    Internally we’re collecting this data from our cloud providers and other SaaS applications in a tool that’s also used for onboarding teams. From there we distribute it to our finance system, send out cost e-mails and provide unified cost dashboards.

  • Black Breeze

    •

    May 10, 2025

    Thanks for the suggestion! Could you share a bit more about the job you’re trying to do with this info? For example, are you trying to break down usage by team, understand cost drivers, automate reports, or something else? Knowing the outcome you’re after would help us shape the right surface for it—whether that’s GraphQL, webhooks, exports, or dashboards.