Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to filter Compass GraphQL qury

Keith Framnes
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 27, 2026

I have a GraphQL query that pulls back all components and associated with a specific metric of interest and creates to lists:

  1. a list of components with value >0 sorted in desc order
  2. a list of components with no value for the metric ever

What I would love to do is add filters into the query itself to reduce the payload and need to post-process the results.  My current query is:

query HallOfShame($after: String) {
compass {
metricDefinition(cloudId: "<CLOUD ID>", metricDefinitionId: "<METRIC ID>") {
... on CompassMetricDefinition {
name
metricSources(query:{first:50, after: $after}) {
... on CompassMetricSourcesConnection {
nodes {
values(query: {first:1}) {
... on CompassMetricSourceValuesConnection {
nodes {
value
timestamp
}
}
}
component {
name
state
typeId
url
links {
url
}
customFields {
... on CompassCustomBooleanField {
definition {
id
name
}
booleanValue
}
}
}
}
pageInfo { hasNextPage endCursor }
totalCount
}
}
}
}
}
}

Now this works, but it pulls back a great deal of data I end up filtering out.  For instance, I'm only interested in components with `typeId` of `SERVICE` and `status` of `ACTIVE`.  Also I filter out any component with a customField named `excludeFromHOS` with a value of `true`.

Any insight into how I might add some of this to the query itself, or refactor the query to enable such filtering / sorting?  I'm afraid as our usage of Compass grows this is going to become an issue with timeouts (already seeing them on occasion).

1 answer

0 votes
Tomislav Tobijas
Community Champion
March 27, 2026

Love the query name @Keith Framnes 😄

I know that "metricSources" connection primarily supports pagination arguments (which you've already used). But I couldn't find anything related to other properties like typeId, state, or other values. 

I believe it would help if you had JQL metrics where you could incorporate filters such as ACTIVE services directly into the JQL query, but that's far from ideal. 🫤

Would be great to hear if anyone has worked with something similar and if they've found a solution. 👀

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events