SDK for TypeScript
The SDK for TypeScript provides a TypeScript API for Dynatrace platform services and Dynatrace AppEngine functionality.
It consists of the following:
- TypeScript packages focused on specific use cases to use Dynatrace platform functionality.
- Modular clients for each Dynatrace platform service to reduce overhead on a specific use.
Using the SDK for Dynatrace App development
Generic layer
This layer of the SDK can be used in all TypeScript apps, providing a use case-based approach for Dynatrace App developers, and for writing scripts in Dynatrace Workflows and Dynatrace Notebooks.
Here is an example of how to format a number to a human-readable string in a Dynatrace function:
import { format, units } from '@dynatrace-sdk/units';
export default async function () {
const value = 1200;
const displayValue = format(value, {
input: units.data.byte,
});
return displayValue; // returns "1.17 KiB"
}
Low-level clients
Client packages give you direct access to Dynatrace platform services. These reflect the services API and provide you with granular use of the services. The requests have authentication with the user's permissions on the respective environment.
The following example loads the connected ActiveGates matching network zone lab
:
import { activeGatesClient } from '@dynatrace-sdk/client-classic-environment-v2';
export default async function () {
const activeGates = await activeGatesClient.getAllActiveGates({
networkZone: 'lab',
});
// …
}
Your app needs to declare scopes for the services it uses to improve security. Please find the necessary scope in the reference for each client.
Using the SDK in ad-hoc functions
You can use the SDK for TypeScript in ad-hoc functions in Dynatrace Workflows and Dynatrace Notebooks, and this applies to all convenience packages (except UI-related ones) and low-level clients.
This is an example of how to ingest metrics in a workflow:
import { metricsClient } from '@dynatrace-sdk/client-classic-environment-v2';
export default async function () {
return metricsClient.ingest({ body: 'cpu.temperature,hostname=hostA,cpu=1 55' });
}
Giving feedback
We at Dynatrace dedicate ourselves to providing the best possible experience for our users. To achieve this, we would like your feedback on our SDK. Your feedback will help us improve our product's quality and ensure that we meet your needs. The Dynatrace community is a welcoming place to share your thoughts, make requests and upvote topics related to SDK improvements. Join the discussion.