So I'm trying to figure out the best way to store or get the
I'm running datacenter and everything needs to be done manually, so just trying to think about the best way to implement, since there is little support for datacenter and compass integration
If I could choose, please make it an API call so I can get a current list of all metrics configured
example api request:
curl --request GET \ --url https://acme.atlassian.net/gateway/api/compass/v1/metrics/${component_id} \ --user "$USER_EMAIL:$USER_API_KEY" \ --header "Accept: application/json" \ --header "Content-Type: application/json"
example config-as-code:
name: my-apiid: 'ari:cloud:compass:12j3hg123jhg123hj:component/34io5u34oi5u3oi4u534/324klj34kjl4jl3k4j'metrics: - name: build time metricId: 'ari:cloud:compass:12j3hg123jhg123hjg123:metric-source/34io5u34oi5u3oi4u534/kwpoerkekmfemcpeck23\'
Hi @Phill Pafford ,
Thanks for reaching out!
There is currently a GraphQL API where you can provide a component ID and request all the metricSources for that component.
The full API reference can be found here but here's an example GraphQL request body also:
query getComponentDetails($id: ID!) { compass { component(id: $id) { ... on CompassComponent { metricSources { ...on CompassComponentMetricSourcesConnection { nodes { id } } } } } }}
And providing the input variables:
{ "id": "yourComponentId"}
In this query I'm only returning the metricSource IDs but you can add extra fields to the query such as the metricDefinition and name also.
Would this work for your use case?
while that works, my script is not for some reason
any ideas?
#!/usr/bin/env bashset -e# ConfigurationATLASSIAN_URL="https://acme.atlassian.net/gateway/api"ATLASSIAN_TOKEN="lkasjdlkajsdlkjaslkdjalksjdlkajsdlkajsdlkajsdlkajskldjalkdjlaksjdlkasjdkjasdlkajsdlkasjdklajdlksajdkalsjd"CONTENT_TYPE="application/json"GRAPHQL_QUERY=$(cat <<EOFquery getComponentDetails(\$id: ID!) { compass { component(id: \$id) { ... on CompassComponent { metricSources { ... on CompassComponentMetricSourcesConnection { nodes { id } } } } } }}EOF)# Parameters for the queryCOMPASS_COMPONENT_ID="ari:cloud:compass:sdlkfjslkdjflksjdlkfjsdlkfjslkdjflksdjf-sdlfslkdfjlsdkjflksdjflksdjflsdjfsd-d234234234"# Construct the variables JSONVARIABLES_JSON=$(cat <<EOF{ "id": "$COMPASS_COMPONENT_ID"}EOF)REQUEST_JSON=$(cat <<EOF{ "query": "$GRAPHQL_QUERY", "variables": $VARIABLES_JSON}EOF)## format as JSONREQUEST_JSON=$(echo $REQUEST_JSON | jq -c)# Make the GraphQL request using curlresponse=$(curl -v -X -L POST \-H "Authorization: Bearer $ATLASSIAN_TOKEN" \-H "Content-Type: $CONTENT_TYPE" \-d "$REQUEST_JSON" \"$ATLASSIAN_URL")echo "$response"exit 0
There's a couple of possible fixes to try:
1. update the ATLASSIAN_URL to include "/graphql" at the end. In full, it would be:
https://<your_site>/gateway/api/graphql
2. try a different auth header. Here's some details for generating and using Atlassian API tokens: https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/
If the above doesn't help, can you provide more details regarding any errors you are receiving?
thanks @Emile Raffoul that was one of the things, got it working
example:
ATLASSIAN_BASIC_AUTH=$(echo -n $ATLASSIAN_USER:$ATLASSIAN_TOKEN | base64)response=$(curl -v -X POST \-H "Authorization: Basic $ATLASSIAN_BASIC_AUTH" \-H "Content-Type: $CONTENT_TYPE" \-d "$REQUEST_JSON" \"$ATLASSIAN_URL")
It looks like you're new here. Sign in or register to get started.