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 onlyThe 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
stableKeyon its ticket. A finding keeps the samestableKeyin every analysis whilekeyVersionis unchanged. WhenkeyVersionchanges, the finding's earlier keys are listed inearlierKeys, so match tickets on those too. - Is the list new?
asOfTimechanges 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. IflostAnalyseslists the finding'sfixTypefor 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 whenasOfTimeis null (see When the list is empty). - What changed.
changesays how a finding compares with the previous analysis:NEW,UNCHANGEDorCHANGED. It is null when the finding wasn't compared. - Adding up savings. Findings with the same
overlapGroupshare a table, warehouse or job, so their savings overlap. Count each group once, at its largest saving. Count a finding whoseoverlapGroupis 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 code | Meaning |
|---|---|
COST_KEY_FINDINGS_NOT_SUPPORTED | The account's Key findings don't have stable keys yet. |
COST_KEY_FINDINGS_UNAVAILABLE | The 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
getCostKeyFindings| Field | Type | Description |
|---|---|---|
asOfTime | DateTime | The 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. |
findings | List of findings | The findings, in the order the Key findings tab shows them. |
lostAnalyses | List of lost analyses | Analyses that couldn't run for a fix type on some warehouses. |
Finding
| Field | Type | Description |
|---|---|---|
stableKey | String | The same for the same finding in every analysis, while keyVersion is unchanged. |
keyVersion | Int | Changes when the way stableKey is derived changes. |
earlierKeys | List of strings | The finding's key under each earlier keyVersion. Empty when the key never changed. |
fixType | Enum | What the finding asks you to change. See Fix types. |
platform | String | The warehouse platform, lowercase, for example snowflake or bigquery. |
platformAccount | String | The Snowflake account the warehouses connect to. Null for other platforms, or when no connection names it. |
warehouseUuids | List of UUIDs | Every Monte Carlo warehouse that reports what the finding targets. |
warehouseId | String | The platform's ID of the warehouse the job runs on. Set on Snowflake REMOVE_RUNS and MAKE_WORK_CHEAPER findings whose warehouse was measured. |
outputTableMcon | String | The MCON of the table the job writes. Set on REMOVE_RUNS and MAKE_WORK_CHEAPER findings only. Null on older analyses. |
removeRunsCase | Enum | Why the job's runs can go. Set on REMOVE_RUNS findings only. See Remove-runs cases. |
pattern | String | A code naming what makes the job expensive, for example full_rebuild_could_be_incremental. Set on MAKE_WORK_CHEAPER findings only. |
change | Enum | How 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. |
overlapGroup | String | The same for findings that share a table, warehouse or job, directly or through another finding. Null on older analyses. |
targets | List of targets | What the finding asks you to change. See Target. |
evidence | List | Facts, 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. |
text | Object | The finding's words. See Text. |
currentSpend | Figure | What the flagged tables, warehouse or job cost today. |
saving | Figure | What acting on the finding would save. |
Fix types
| Value | Meaning |
|---|---|
DELETE_UNUSED_TABLES | Delete unused tables (storage). |
CUT_IDLE_TIME | Cut a warehouse's idle time (compute). |
SHRINK_WAREHOUSE | Shrink a warehouse (compute). |
REMOVE_RUNS | Remove runs of a job (compute). |
MAKE_WORK_CHEAPER | Make a job's work cheaper (compute). |
Remove-runs cases
| Value | Meaning |
|---|---|
UNUSED_OUTPUT | The job's output is unused. |
FAILING | The job's runs fail. |
DUPLICATE | The job's runs duplicate each other. |
TOO_FREQUENT | The job runs more often than its output is read. |
Target
| Field | Type | Description |
|---|---|---|
kind | Enum | TABLE, WAREHOUSE or QUERY_GROUP. |
id | String | A table's MCON, the platform's warehouse ID, or a query group ID, depending on kind. |
sizeBytes | Float | A table's size in bytes. Set on the tables of a DELETE_UNUSED_TABLES finding; null otherwise. |
downstreamCount | Int | How 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
| Field | Type | Description |
|---|---|---|
title | String | The finding's title. |
headline | String | A short title for a card. Can be null. |
body | String | The 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)
| Field | Type | Description |
|---|---|---|
status | Enum | SHOWN |
usdPerMonth | Float | Dollars a month. |
creditsPerMonth | Float | The same figure in credits. Set for Snowflake compute figures only. |
tier | Enum | How the figure was produced. A current spend is always MEASURED. A saving is COMPUTED (fixed formula) or ESTIMATED (assumed share). |
label | String | What a current spend measures on its fix type, for example Idle spend. Null on savings. |
calculation | Object | How the figure was calculated, in enough detail to recompute it. See below. |
calculation contains:
| Field | Type | Description |
|---|---|---|
formula | String | The formula over the inputs, by name. |
formulaVersion | String | Changes whenever the formula changes. |
inputs | List | Each 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). |
price | Object | The 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). |
window | Object | The dates the inputs cover, start and end, both included. |
assumption | String | What an estimate assumes. Set on ESTIMATED figures only. |
Withheld figure (CostFindingWithheldFigureOutput, status: WITHHELD)
| Field | Type | Description |
|---|---|---|
status | Enum | WITHHELD |
reasonCode | Enum | Why the figure is withheld. See Reason codes. |
reasonText | String | The reason in plain language. |
label | String | What a current spend would measure on its fix type. Null on savings. |
Lost analysis
| Field | Type | Description |
|---|---|---|
warehouseUuids | List of UUIDs | The warehouses the analysis was lost for. |
fixType | Enum | The fix type whose analysis didn't run. |
reasonCode | Enum | Why. See Reason codes. |
reasonText | String | The 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
Updated about 6 hours ago
