Forums

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

Pushing metrics to Compass

Michael Akinde May 13, 2025

I'm trying to automate pushing of metrics to Compass using Curl from our CI/CD system as described here, 
https://developer.atlassian.com/cloud/compass/components/push-metric-values-using-a-curl-command/

  • How do I get the metricSourceId for a given component and metric? The text says to grab it from Compass - this makes no sense except for testing. I hope no one is seriously expecting people to manually copy-paste multiple metrics for hundreds of projects into scripts.
  • Is there a way to bundle multiple metrics into a single POST? According to the docs, the POST call is rate-limited to 100 calls/minute. Although that probably works for us (we are not a huge org), if we start posting 10+ metrics per build, I suspect we might hit the limit multiple times a day.

I note that the curl event command is significantly better documented (although I haven't tried that yet, so might have similar questions once I get to that).

2 answers

2 accepted

1 vote
Answer accepted
Erik Budtke
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 13, 2025

@Michael Akinde thanks for the feedback about the documentation! I'll make sure that gets passed along so that we can hopefully make this more clear for future users.

As to your questions:

  • The easiest way to get the metricSourceId is to take it directly from the copied curl command that is mentioned in step 2 of that page. It should just be in your clipboard at that point and doesn't need any further modification. If you're looking for something a bit more programmatic, you can use our GraphQL API to query for metric sources for a given component. Docs here https://developer.atlassian.com/cloud/compass/graphql/#queries_component 
  • We currently don't have a batch API for metric values, but that is great feedback. I will say that the rate limit is 100 calls per user per minute, so hopefully that makes it a little bit less likely that you do run into it. You could segment the calls across users to outright avoid it, but I understand that this is totally just a workaround so I'll get an item added to our backlog to look into something more user friendly.
Michael Akinde May 20, 2025

I replied in the other anser, in order to avoid splitting the discussion.

1 vote
Answer accepted
Enrique Serrano Valle
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 13, 2025

Hi, @Michael Akinde !

To answer your questions:

  • You can use the Compass GraphQL API to retrieve the IDs of the metric sources related to your components programmatically. This answer has more details about that. Remember that you can also use the GraphQL explorer in <your-site>.atlassian.net/gateway/api/graphql as an easier way to test your GraphQL queries.
  • If you find a limitation in the REST API regarding how frequently you can update metrics, I'd suggest using the equivalent insertMetricValue GraphQL operation. The the most recent value for a given metric, per component, per hour is stored, so in practice and with the cadence used to evaluate overall component health, your use case may already be under the supported ranges.

Let me know whether that works for you!

Michael Akinde May 20, 2025

Got GraphQL working for retrieving the sourceIds, though not without some trial and error. This is my main issue with GraphQL - it does the job, but it is just so verbose to use  (and thus error prone) when all I really want is a simple query.

Does the inserMetricValue not have the 100 calls per minute limitation? If so, I guess that is an alternative workaround if we hit the limit.

Michael Akinde May 20, 2025

I'll just reply to @Erik Budtke here as well, rather than split the discussion.

Our use case is that we have test and analysis jobs running on our CI/CD server, which pushes data to SonarQube. Since the SonarQube integration for Atlassian is extremely limited, we need some way to send the metrics to Compass.

We have several hundred projects in our system. Manually copying the sourceId from Compass into a variable somewhere is not an option.

What we do now is grab the SonarID, fetch the metrics from Sonar through it's API, then grab the CompassComponentId (from the compass.yml), retrieve the metricSourceIds from the Compass GraphQL API, and then post the metrics to Compass. All of this is scripted.

Currently we do this on every commit. We considered doing this on a timer, but then you'd have a 100 builds jobs running in parallel, and that would almost certainly cause an issue with the rate limit.

The problem is that we have to post every metric individually. Currently in the version we are testing, we are just posting 2 metrics, but there are easily 10-15 metrics that could be interesting to push to Compass per component. If every iteration of this job results in ~15 calls, then it's not going to take very many simultaneous build jobs to hit the rate limit.

Segmenting the call across multiple users is not an option I'd like to take. The caller is our "bot" user for the CI/CD system; having multiple users for the system would complicate the scripting.

Being able to post the metrics in a single call would solve the problem for our use case.

Michael Akinde May 27, 2025

A follow-up question: Using the GraphQL command, it looks like I am only able to get the built-in compass metrics. Is there a way to get hold of the codes for custom metrics as well?

Michael Akinde May 28, 2025

OK, I think I found the answer to this - I guess that the metric needs to be connected to the component for it to be useful.

The only way seems to be doing it component by component. Though this of course means that this is never happening (again - 200+ components - no one is spending their time doing this manually).

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events