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).

3 answers

2 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. 👀

0 votes
Anwesha Pan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
June 26, 2026

Hi @Keith Framnes 

Now that I see, you have been suggested with multiple solutions, is it still an issue for you? Would you be able to accept one of the answers you have been suggested?

Thanks,
Anwesha

0 votes
Martin Runge
Community Champion
June 18, 2026

Hi @Keith Framnes

Welcome to the Atlassian Community!

Are you using the GraphiQL explorer? https://developer.atlassian.com/cloud/compass/graphql/explorer/

I would fetch the list of services using the standard metricSources query. Then, I would filter the resulting array in your application code based on the specific fields you need, such as typeId or state. This is currently the most reliable way to handle these properties since the API does not expose native input arguments for these specific metadata fields in the primary connection query.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events