Monitoring Technologies
Counting Technologies
Use the following URL, replacing <saagie_host>
with your Saagie URL and <platform_id>
with the platform identifier of the platform you want to retrieve information from.
https://<saagie_host>/api/v1/projects/platform/<platform_id>/graphql
For more information on GraphQL, refer to the GraphQL documentation. |
Using cURL Commands
-
Retrieve a Bearer connection token via cURL by running the following command line:
TOKEN_SAAGIE_API=$( \ curl \ -s \ -X POST \ -H "Content-Type:application/json" \ -H 'Saagie-Realm: '<realm> \ (1) --data '{"login":"<user>", "password":"<pwd>"}' \ (2) (3) https://<saagie_host>/authentication/api/open/authenticate \ (4) )
Where:
1 <realm>
is the prefix that was determined during Saagie installation.2 <user>
is your Saagie username.3 <pwd>
is your Saagie password.4 <saagie_host>
is your Saagie URL. -
Retrieve the count of jobs and apps per project by running the following command line:
curl \ -H 'Accept: application/json' \ -H "Authorization: Bearer <token_saagie_api>" \ (1) --request POST \ --header "Content-Type:application/json" \ --data '{"query":"{\n projects {\n jobsCount\n }\n}\n","variables":null}' \ (4) https://<saagie_host>/api/v1/projects/platform/<platform_id>/graphql (2) (3)
Where:
1 <token_saagie_api>
is your Saagie realm.2 <saagie_host>
is your Saagie URL.3 <platform_id>
is the platform identifier of the platform you want to retrieve information.4 The sum of the field jobsCount
reveals the total count per platform.{ "data": { "projects": [ { "id": "cea7be12-462f-4000-b8bb-666c1eb63d95", "name": "test port", "jobsCount": 6 }, { "id": "17236c69-88f9-4124-bf2f-6e90aef48640", "name": "test-reporter", "jobsCount": 0 }, { "id": "f3062b55-4802-40d1-a957-d3ae8331ad2b", "name": "test ux", "jobsCount": 1 }, { "id": "154008e6-2f68-4046-80e8-949edf8157f0", "name": "test b", "jobsCount": 2 } ] } }
-
Using the data from the previous GraphQL response, retrieve the total count of jobs and apps on a platform with the following
jq
command line:Do not forget to replace the variables with your values. #!/bin/bash PLATFORM_SAAGIE=1 SAAGIE_HOST=saagie1-beta.a42.saagie.cloud REALM=saagie1 user=user pwd=password TOKEN_SAAGIE_API=$( \ curl \ -s \ -X POST \ -H "Content-Type:application/json" \ -H 'Saagie-Realm: '$REALM \ --data '{"login":"'$user'", "password":"'$pwd'"}' \ https://$SAAGIE_HOST/authentication/api/open/authenticate \ ) responseGraphql=$( \ curl \ -s \ -H 'Accept: application/json' \ -H "Authorization: Bearer $TOKEN_SAAGIE_API" \ -H "Content-Type:application/json" \ -X POST \ --data '{"query":"{\n projects {\n jobsCount\n }\n}\n","variables":null}' \ https://$SAAGIE_HOST/api/v1/projects/platform/$PLATFORM_SAAGIE/graphql \ ) echo $responseGraphql | jq -n '[inputs | .data.projects[].jobsCount] | reduce .[] as $num (0; .+$num)'