I have a GraphQL query that pulls back all components and associated with a specific metric of interest and creates to lists:
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).
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. 👀
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.