Skip to content

Latest commit

 

History

History
167 lines (115 loc) · 8.94 KB

app-engine.md

File metadata and controls

167 lines (115 loc) · 8.94 KB

App Engine

Dynatrace App Engine lets you extend the platform with custom and built-in applications. dtctl provides commands to list, inspect, and delete apps, as well as discover and execute app functions and intents. It also lists the App Engine SDK versions available to apps with dtctl get sdk-versions, and fetches the TypeScript type definitions of an SDK package with dtctl get runtime-type-definitions.

dtctl docs / Resources / App Engine

Supported operations

Operation Resource Command syntax Description Mutating Access
delete app dtctl delete app Delete resources yes delete
describe app dtctl describe app Show details of a specific resource no read
get apps dtctl get apps Display one or many resources no read
describe function dtctl describe function Show details of a specific resource no read
exec function dtctl exec function Execute workflows, functions, analyzers, SLOs, and code-level profiling yes run
get functions dtctl get functions Display one or many resources no read
describe intent dtctl describe intent Show details of a specific resource no read
find intents dtctl find intents Find resources based on criteria no read
get intents dtctl get intents Display one or many resources no read
open intent dtctl open intent Open resources in browser no read
get runtime-type-definitions dtctl get runtime-type-definitions Display one or many resources no read
get sdk-versions dtctl get sdk-versions Display one or many resources no read

Flags

These commands take dtctl's global flags (-o/--output, --context, --jq, -v, and more). Some verbs add their own flags (apply, diff, query, inventory); see the verb in COMMANDS.md. Individual commands may take further flags of their own — run dtctl <verb> <resource> --help for the authoritative list.

Required token scopes

Safety level Scopes
delete app-engine:apps:delete
read app-engine:apps:run, app-engine:functions:run
run app-engine:functions:run
write app-engine:apps:install

Output

get apps/get functions/get intents print compact tables; -o wide on get functions adds detail such as the owning app. describe function includes the function's parameter and result schema so you know what to pass to exec function. describe intent shows the parameters accepted for deep-linking.

Examples

# List all installed apps
dtctl get apps

# Describe a specific app
dtctl describe app app-123

Discover and describe app functions:

# List all available functions across all apps
dtctl get functions

# List functions for a specific app with extra detail
dtctl get functions --app dynatrace.automations -o wide

# View function details including parameters and schema
dtctl describe function dynatrace.automations/execute-dql-query

Get the TypeScript type definitions of an SDK package available in the function runtime (for example to generate correct TypeScript code). Both flags are required; dtctl get sdk-versions shows which packages and versions exist. The default output, -o wide and --plain print the .d.ts text itself (not JSON, unlike other get commands under --plain); -o json|yaml|csv|toon, --fields, --jq and agent mode return the response object with the resolved version and file name. The command needs app-engine:functions:run, which a readonly login does not request: use a readwrite-mine (or higher) context, or a token with that scope.

# Print the .d.ts content
dtctl get runtime-type-definitions --package-name @dynatrace-sdk/client-automation --major-version 8

# Save it to a file
dtctl get runtime-type-definitions --package-name @dynatrace-sdk/client-automation --major-version 8 > client-automation.d.ts

# Resolved package version, file name and the declaration in typeDefinitions
dtctl get runtime-type-definitions --package-name @dynatrace-sdk/client-automation --major-version 8 -o json

dtctl exec function has two modes, selected by the flags you pass: app function (invoke a function exposed by an installed app) is the default, and ad-hoc JavaScript (run code directly, without deploying an app) is selected by passing --code or -f/--file. The command has aliases fn and func.

# GET (default method, no payload)
dtctl exec function dynatrace.automations/execute-dql-query

# POST with an inline JSON payload
dtctl exec function dynatrace.automations/execute-dql-query \
  --method POST \
  --payload '{"query":"fetch logs | limit 5"}'

# Payload from a file, or from stdin with "-"
dtctl exec function dynatrace.automations/execute-dql-query --method POST --data payload.json

# Defer execution (async, for resumable functions) — returns a handle instead of the result
dtctl exec function dynatrace.automations/long-running --method POST --payload '{}' --defer

# Ad-hoc JavaScript (no app deployment; --code or -f selects this mode)
dtctl exec function --code 'export default async function () { return "hi" }'
dtctl exec function -f script.js --payload '{"input":"data"}'

# Pin SDK major versions for ad-hoc code: inline JSON, @file, or @- for stdin
dtctl exec function -f script.js --sdk-major-versions '{"@dynatrace-sdk/adhoc-utils":"1"}'
dtctl exec function -f script.js --sdk-major-versions @sdk-versions.json

--method accepts GET (default), POST, PUT, PATCH, or DELETE. --payload takes an inline JSON string; --data reads the same payload from a file (or - for stdin) — pass at most one of the two. If you're unsure what fields a function expects, try executing it with an empty payload (--payload '{}'); the error response typically lists the required fields.

Discover and use app intents (deep-linking into specific app views with contextual data):

# List all registered intents, or describe one to see its parameters
dtctl get intents
dtctl describe intent dynatrace.distributedtracing/view-trace

# Find intents that accept a given set of data fields
dtctl find intents --data trace_id=abc123

# Generate a deep-link URL and open it in the browser
dtctl open intent dynatrace.distributedtracing/view-trace \
  --data trace_id=abc123 \
  --browser

Delete an app:

dtctl delete app app-123

Notes

Ad-hoc JavaScript use cases

Running a function's worth of JavaScript without publishing an app is useful for quick platform automation and for prototyping app functions before you commit to a full app. You can also pipe a payload in from another command:

# Read the payload from stdin
cat payload.json | dtctl exec function dynatrace.automations/execute-dql-query --method POST --data -

In ad-hoc mode, --payload/--data supply the input passed to the code; the --method and --defer flags do not apply, and dtctl ignores any app-id/function-name argument.

Pinning SDK major versions

--sdk-major-versions sets the function executor's sdkMajorVersions for ad-hoc code: a JSON object mapping SDK package names to major versions, each a string ({"@dynatrace-sdk/adhoc-utils":"1"}). Pass it inline, as @file to read it from a file, or as @- to read it from stdin; a value that does not start with @ is always treated as JSON, never as a path. {} is sent as an empty object. Without the flag the request is unchanged.

dtctl checks only the shape — an object whose values are all strings — and fails before sending anything if it is wrong. Package names and versions are left to the API, whose error is shown as returned; dtctl get sdk-versions lists the versions available. The flag requires --code or -f; --method and --defer are still ignored in ad-hoc mode, as they are without it. It can be given only once, and @- cannot be combined with -f - or --data -, since stdin can feed only one flag.

Common built-in functions

A few functions from the built-in dynatrace.automations app cover common automation needs:

App Function Description
dynatrace.automations execute-dql-query Run a DQL query
dynatrace.automations send-email Send an email notification
dynatrace.automations send-slack-message Post a message to Slack
dynatrace.automations create-jira-issue Create a Jira issue

Common intent use cases

Intents are typically used for deep linking from alert notifications to the relevant trace or dashboard, scripted navigation for runbooks, and building custom integrations that open Dynatrace views with pre-filled context.