Observability configurations can be prone to human error, are time-consuming, and block teams from shipping their code quickly to production. A new trend, Observability from code, brings efficiency to the configuration of your monitoring platforms. Instead of navigating through complex UIs, we use code to create and maintain Observability for our applications.
In this blog, I share insights on how you can use Observability from code to manage New Dynatrace Grail dashboards.
How to Download New Grail Dashboards using the Dynatrace API
Dynatrace offers an alternate way to retrieve the Grail Dashboards using the available Dynatrace API endpoints. This content provides a step-by-step procedure for downloading the Grail Dashboards using the Dynatrace Rest API.
First of all, if you have not created a new Dynatrace Grail Dashboard, please read this https://docs.dynatrace.com/docs/observe-and-explore/dashboards-and-notebooks/dashboards-new
New Dashboards can't be downloaded using standard Dynatrace access tokens. Once you have your new Dashboard, you can prepare the OAuthClient, create a Bearer token, and download the Dashboard.
Step 1 - We create the OAuth2Client
To create OAuth2Client details, please use the Account Management >> Identity & access management >> OAuth clients by supplying the scopes document:documents:read
As a result, you will receive the client details.
Step 2 - We request Bearer token
After you create the OAuth2 client, request the bearer token from the Dynatrace SSO system via an API call.
Provide the following parameters in the request body.
grant_type client_credentials
client_id {your-Client-ID}
client_secret {your-Client-secret}
scope A list of required scopes separated by a whitespace,
Example:- account-uac-read account-uac-write.
resource urn:dtaccount:{your-account-UUID}
Sample code:-
Map<String, Object> mapParameters = new HashMap<String, Object>();
mapParameters.put("grant_type", "client_credentials");
mapParameters.put("client_id", sClientId);
mapParameters.put("client_secret", sClientSecret);
mapParameters.put("scope", sScope);
mapParameters.put("resource", sResource);
HttpResponse<String> responseOAuth2ClientToken =
.header("accept", "application/json; charset=utf-8")
.header("Content-Type", "application/x-www-form-urlencoded")
.header("Authorization", "Api-Token " + sToken)
.fields(mapParameters)
.asString();
The result will be a json similar to the following.
{"scope": "document:documents:read document:documents:write document:documents:delete", "token_type": "Bearer", "expires_in":300, "access_token": "<token code>"}
Use the bearer token from the field "access_token"
Step 3 - We download the New Dashboard
HttpResponse<String> responseDocConfig = Unirest.get("https://"+tenantId+".apps.dynatrace.com/platform/document/v1/documents")
.header("accept", "application/json; charset=utf-8")
.header("Content-Type", "application/json")
.header("Authorization", "Bearer " + token)
.asString();
String sResponseBody = responseDocConfig.getBody();
Once you execute this request, the selected New Dashboard will be downloaded.
Likewise, if you pass the id value taken from the response to the URL,
Unirest.get("https://"+tenantId+".apps.dynatrace.com/platform/document/v1/documents/{id}"), you will receive individual document contents
You can also use the swagger UI from the below link:
https://<yourtenant>.apps.dynatrace.com/platform/swagger-ui/index.html?urls.primaryName=Document%20Service#/
Simplify Dynatrace configuration
We are working on a new platform to manage Dynatrace configurations and provide use cases such as
Backup
Restore
Deploy
Reporting
Check our preview on www.composersaas.com
Keep up the great work! Happy Performance Engineering!
Comments