Cette page n'est pas encore disponible en français, sa traduction est en cours. Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.
App Builder is not supported for your selected Datadog site ().
Queries populate your app with data from Datadog APIs or supported integrations. They take inputs from other queries or from UI components and return outputs for use in other queries or in UI components.
The Action Catalog within the Datadog App provides actions that can be performed as queries against your infrastructure and integrations using App Builder. You can orchestrate and automate your end-to-end processes by linking together actions that perform tasks in your cloud providers, SaaS tools, and Datadog accounts.
To add a query, click the plus (+) icon in the Queries section and search for an action to add to your app. After you’ve added the query action, it appears in the query list above the query editor. Click and drag queries to reorder them. Select a query to configure it.
Run Settings determine when a query is executed. There are two options:
Auto: The query runs when the app loads and whenever any query arguments change.
Manual: The query runs when another portion of the app triggers it. For example, use a manual trigger if you want a query to execute only when a user clicks a UI button component. For more information on event triggers, see Events.
Debounce
Configuring debounce ensures that your query is only triggered once per user input. By default, debounce is set to 0 milliseconds (ms). To prevent a query from being called too frequently, increase the debounce. Configure debounce in the Advanced section of a query.
Conditional queries
You can set a condition that must be met before a query can run. To set the condition for a query, enter an expression in the Condition field in the Advanced section of the query. This condition must evaluate to true before the query can run. For example, if you want a given query to run only if a UI component named select0 exists and is not empty, use the following expression:
${select0.value&&select0.value.length>0}
Post-query transformation
Perform a post-query transformation to simplify or transform the output of a query. Add a post-query transformation in the Advanced section of a query.
For example, the Slack List Channels action returns an array of dictionaries containing the ID and name for each channel. To discard the IDs and return only an array of names, add the following query transformation:
// Use `outputs` to reference the query's unformatted output.
// TODO: Apply transformations to the raw query output
arr=[]object=outputs.channelsfor(variteminobject){arr.push(object[item].name);}returnarr
Post-query hooks
Similar to UI component events, you can configure a reaction to trigger after a query executes. A post-query hook can set a UI component state, open or close a modal, trigger another query, or even run custom JavaScript. For example, the ECS Task Manager blueprint’s scaleService query uses a post-query hook to rerun the describeService query after it executes.
Error notifications
To display a toast (a brief notification message) to the user when the system returns an error, toggle Show Toast on Errors in the Advanced section of a query.
Confirmation prompts
To prompt a user for confirmation before the query runs, toggle the Requires Confirmation option in the Advanced section of a query.
Example app
Return workflow results to an app
App Builder queries can trigger Workflow Automation workflows. Apps can then use the results of those workflows.
This app provides a button to trigger a workflow. The workflow sends a poll to a Slack channel asking the user to pick from one of two options. Based on the option the user chooses, the workflow issues one of two different HTTP GET requests, which then returns data that is displayed in the app.
Build the app
Create workflow
In a new workflow canvas, under Datadog Triggers, click App.
Under the App trigger step, click the plus (+) icon, then search for “Make a decision” and select the Make a decision Slack action.
Select your workspace and choose a channel to poll.
Fill in the prompt text “Cat fact or dog fact?” and change the button choices to “Cat fact” and “Dog fact”.
Under the Make a decision step in the canvas, click the plus (+) icon above Cat fact and add the Make request HTTP action.
Name the step “Get cat fact”. Under Inputs, for the URL, keep GET selected and enter the URL https://catfact.ninja/fact.
Under the Make a decision step in the canvas, click the plus (+) icon above Dog fact. Follow the same steps to add the Make request HTTP action, but this time name the step “Get dog fact” and use the following parameters:
URL: https://dogapi.dog/api/v2/facts.
Request Headers: Content-Type of application/json
Click the plus (+) icon under the cat fact step. Search for “Function” and choose the Function data transformation step.
Connect the plus (+) icon under the dog fact step to this JS Function step by clicking and dragging from the plus to the dot that appears above the JS Function step.
In the JS Function, under Configure, for Script, use the following code snippet: