Export key findings via API

Pull your Cost & Performance key findings into your own tools with the getCostKeyFindings GraphQL query.

The getCostKeyFindings GraphQL query returns your account's Cost & Performance key findings: the same findings the Key findings tab shows, in the same order. Each finding keeps the same key from one analysis to the next, so your own automation can open, update and close one ticket per finding.

📘

Latest findings only

The query returns the findings the Key findings tab shows now. Earlier lists can't be retrieved through the API. To keep a history, run the query on a schedule and store each result.

Before you begin

  • Credentials. Create an API key or OAuth client. See API Authentication.
  • Permissions. The caller needs the Cost & Performance permission, and AI features must be enabled for the account.

Run the query

The query takes no arguments.

query GetCostKeyFindings {
  getCostKeyFindings {
    asOfTime
    findings {
      stableKey
      keyVersion
      earlierKeys
      fixType
      platform
      platformAccount
      warehouseUuids
      warehouseId
      outputTableMcon
      removeRunsCase
      pattern
      change
      overlapGroup
      targets {
        kind
        id
        sizeBytes
        downstreamCount
      }
      evidence {
        name
        value
        unit
      }
      text {
        title
        headline
        body
      }
      currentSpend {
        ...Figure
      }
      saving {
        ...Figure
      }
    }
    lostAnalyses {
      warehouseUuids
      fixType
      reasonCode
      reasonText
    }
  }
}

fragment Figure on CostFindingFigureOutput {
  __typename
  ... on CostFindingShownFigureOutput {
    status
    usdPerMonth
    creditsPerMonth
    tier
    label
    calculation {
      formula
      formulaVersion
      assumption
      inputs {
        name
        value
        unit
        source
        sourceId
      }
      price {
        amount
        unit
        source
        asOf
        label
      }
      window {
        start
        end
      }
    }
  }
  ... on CostFindingWithheldFigureOutput {
    status
    reasonCode
    reasonText
    label
  }
}

Save the query as query.graphql and send it with your API key:

jq -n --rawfile q query.graphql '{query: $q}' | \
curl --location --request POST 'https://api.getmontecarlo.com/graphql' \
  --header 'x-mcd-id: <KEY_ID>' \
  --header 'x-mcd-token: <SECRET>' \
  --header 'Content-Type: application/json' \
  --data @-

If you use an OAuth client, send Authorization: Bearer <ACCESS_TOKEN> instead of the x-mcd-id and x-mcd-token headers. You can also try the query in the API Explorer.

Example response

This example shows a single finding. Its spend and saving figures are withheld.

{
  "data": {
    "getCostKeyFindings": {
      "asOfTime": "2026-11-26T13:00:00+00:00",
      "findings": [
        {
          "stableKey": "2f64140efc800c648b052d9f25bb353b",
          "keyVersion": 1,
          "earlierKeys": [],
          "fixType": "REMOVE_RUNS",
          "platform": "snowflake",
          "platformAccount": null,
          "warehouseUuids": ["<warehouse_uuid>"],
          "warehouseId": "202",
          "outputTableMcon": "MCON++<account_uuid>++<warehouse_uuid>++table++analytics:prod.example_table",
          "removeRunsCase": "TOO_FREQUENT",
          "pattern": null,
          "change": null,
          "overlapGroup": "2f64140efc800c648b052d9f25bb353b",
          "targets": [
            {
              "kind": "QUERY_GROUP",
              "id": "<query_group_id>",
              "sizeBytes": null,
              "downstreamCount": null
            }
          ],
          "text": {
            "title": "Run the job that writes analytics:prod.example_table less often",
            "headline": "1,607 runs more than reads need in 7 days · analytics:prod.example_table",
            "body": "Over the last 7 days, the job that writes `analytics:prod.example_table` had 1,623 successful runs, while the output table was read 15 times. ..."
          },
          "currentSpend": {
            "__typename": "CostFindingWithheldFigureOutput",
            "status": "WITHHELD",
            "reasonCode": "PER_QUERY_COST",
            "reasonText": "This warehouse bills for running time, not per query, so this job's own cost can't be measured. The warehouse costs $98 a month.",
            "label": "This job's spend"
          },
          "saving": {
            "__typename": "CostFindingWithheldFigureOutput",
            "status": "WITHHELD",
            "reasonCode": "SAVING_NOT_CALCULATED",
            "reasonText": "Savings from changing one job aren't calculated on this warehouse yet: it bills for running time, which other work may keep the same.",
            "label": null
          }
        }
      ],
      "lostAnalyses": []
    }
  }
}

Building automation on the findings

  • One ticket per finding. Store each finding's stableKey on its ticket. A finding keeps the same stableKey in every analysis while keyVersion is unchanged. When keyVersion changes, the finding's earlier keys are listed in earlierKeys, so match tickets on those too.
  • Is the list new? asOfTime changes when a newer analysis replaces the list. If it hasn't changed since your last read, neither have the findings.
  • Closing a ticket. Close a finding's ticket when a newer list (a later asOfTime) no longer has its key, with two exceptions. If lostAnalyses lists the finding's fixType for one of its warehouses, leave the ticket open: that analysis didn't run, so the finding may still be there. And don't close tickets when asOfTime is null (see When the list is empty).
  • What changed. change says how a finding compares with the previous analysis: NEW, UNCHANGED or CHANGED. It is null when the finding wasn't compared.
  • Adding up savings. Findings with the same overlapGroup share a table, warehouse or job, so their savings overlap. Count each group once, at its largest saving. Count a finding whose overlapGroup is null as its own group. Only shown figures have a dollar value (see Spend and savings figures).

What the query returns

When the list is empty

The query returns no findings and a null asOfTime when cost insights aren't on for the account, or when the latest analysis finished more than 30 days ago. An empty list with a null asOfTime says nothing about whether findings were fixed.

Domain-restricted users

A user restricted to domains gets the table and job findings in their domains, and every warehouse finding.

Free tier

On the free tier, the query returns only the finding with the largest saving, and its change is null.

Errors

Error codeMeaning
COST_KEY_FINDINGS_NOT_SUPPORTEDThe account's Key findings don't have stable keys yet.
COST_KEY_FINDINGS_UNAVAILABLEThe Key findings can't be read right now. Try again later.

New values

Fix types and other enum values can grow, so make your client accept values it doesn't know.

Response fields

getCostKeyFindings

FieldTypeDescription
asOfTimeDateTimeThe end of the data the findings were computed from. Changes when a newer analysis replaces the list. Null when there is no analysis to read.
findingsList of findingsThe findings, in the order the Key findings tab shows them.
lostAnalysesList of lost analysesAnalyses that couldn't run for a fix type on some warehouses.

Finding

FieldTypeDescription
stableKeyStringThe same for the same finding in every analysis, while keyVersion is unchanged.
keyVersionIntChanges when the way stableKey is derived changes.
earlierKeysList of stringsThe finding's key under each earlier keyVersion. Empty when the key never changed.
fixTypeEnumWhat the finding asks you to change. See Fix types.
platformStringThe warehouse platform, lowercase, for example snowflake or bigquery.
platformAccountStringThe Snowflake account the warehouses connect to. Null for other platforms, or when no connection names it.
warehouseUuidsList of UUIDsEvery Monte Carlo warehouse that reports what the finding targets.
warehouseIdStringThe platform's ID of the warehouse the job runs on. Set on Snowflake REMOVE_RUNS and MAKE_WORK_CHEAPER findings whose warehouse was measured.
outputTableMconStringThe MCON of the table the job writes. Set on REMOVE_RUNS and MAKE_WORK_CHEAPER findings only. Null on older analyses.
removeRunsCaseEnumWhy the job's runs can go. Set on REMOVE_RUNS findings only. See Remove-runs cases.
patternStringA code naming what makes the job expensive, for example full_rebuild_could_be_incremental. Set on MAKE_WORK_CHEAPER findings only.
changeEnumHow the finding compares with the previous analysis: NEW (not in the previous analysis), UNCHANGED, or CHANGED (different evidence or figures). Null when the finding wasn't compared.
overlapGroupStringThe same for findings that share a table, warehouse or job, directly or through another finding. Null on older analyses.
targetsList of targetsWhat the finding asks you to change. See Target.
evidenceListFacts, computed from your account's data, that the finding rests on. Each has a name, a value (number, string or boolean) and, for numbers, a unit.
textObjectThe finding's words. See Text.
currentSpendFigureWhat the flagged tables, warehouse or job cost today.
savingFigureWhat acting on the finding would save.

Fix types

ValueMeaning
DELETE_UNUSED_TABLESDelete unused tables (storage).
CUT_IDLE_TIMECut a warehouse's idle time (compute).
SHRINK_WAREHOUSEShrink a warehouse (compute).
REMOVE_RUNSRemove runs of a job (compute).
MAKE_WORK_CHEAPERMake a job's work cheaper (compute).

Remove-runs cases

ValueMeaning
UNUSED_OUTPUTThe job's output is unused.
FAILINGThe job's runs fail.
DUPLICATEThe job's runs duplicate each other.
TOO_FREQUENTThe job runs more often than its output is read.

Target

FieldTypeDescription
kindEnumTABLE, WAREHOUSE or QUERY_GROUP.
idStringA table's MCON, the platform's warehouse ID, or a query group ID, depending on kind.
sizeBytesFloatA table's size in bytes. Set on the tables of a DELETE_UNUSED_TABLES finding; null otherwise.
downstreamCountIntHow many tables, views, streams and BI assets sit directly downstream of the table in Monte Carlo's lineage. Set on the tables of a DELETE_UNUSED_TABLES finding; 0 when lineage shows none. Null when unknown and on other targets.

Text

FieldTypeDescription
titleStringThe finding's title.
headlineStringA short title for a card. Can be null.
bodyStringThe full explanation, in Markdown.

Spend and savings figures

currentSpend and saving each return one of two types. Check __typename, or status, to see which one you received.

Shown figure (CostFindingShownFigureOutput, status: SHOWN)

FieldTypeDescription
statusEnumSHOWN
usdPerMonthFloatDollars a month.
creditsPerMonthFloatThe same figure in credits. Set for Snowflake compute figures only.
tierEnumHow the figure was produced. A current spend is always MEASURED. A saving is COMPUTED (fixed formula) or ESTIMATED (assumed share).
labelStringWhat a current spend measures on its fix type, for example Idle spend. Null on savings.
calculationObjectHow the figure was calculated, in enough detail to recompute it. See below.

calculation contains:

FieldTypeDescription
formulaStringThe formula over the inputs, by name.
formulaVersionStringChanges whenever the formula changes.
inputsListEach input's name (its symbol in the formula), value, unit (for example bytes or credits), source (the dataset it was read from) and sourceId (the record: a table MCON, a platform warehouse ID, a query group ID, or a table entry name).
priceObjectThe price the figure was converted to dollars with: amount (dollars per unit), unit (for example USD/credit or USD/TB-month), source (STANDARD list price, CUSTOMER price you entered, or BILLED_AVERAGE from your billing data), asOf (the billing day of a BILLED_AVERAGE price) and label (the price and its source in words).
windowObjectThe dates the inputs cover, start and end, both included.
assumptionStringWhat an estimate assumes. Set on ESTIMATED figures only.

Withheld figure (CostFindingWithheldFigureOutput, status: WITHHELD)

FieldTypeDescription
statusEnumWITHHELD
reasonCodeEnumWhy the figure is withheld. See Reason codes.
reasonTextStringThe reason in plain language.
labelStringWhat a current spend would measure on its fix type. Null on savings.

Lost analysis

FieldTypeDescription
warehouseUuidsList of UUIDsThe warehouses the analysis was lost for.
fixTypeEnumThe fix type whose analysis didn't run.
reasonCodeEnumWhy. See Reason codes.
reasonTextStringThe reason in plain language.

Reason codes

reasonCode on a withheld figure or a lost analysis is one of: DATA_UNAVAILABLE, DATA_LATE, COLLECTING_DATA, NOT_ENROLLED, USAGE_UNAVAILABLE, NO_PRICE, NOT_SUPPORTED, NOT_VERIFIABLE, OUTSIDE_TOP_WAREHOUSES, SAVING_NOT_CALCULATED, PER_QUERY_COST, RESERVED_CAPACITY. Use reasonText to show the reason to people.

Related


Did this page help you?