- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
JavaScript is available in Workflows using inline expressions or through the dedicated JS Function and Expression actions.
You can use JavaScript (JS) expressions directly in workflow steps to perform a wide range of data transformations without needing to include dedicated JS steps.
To use an inline expression in your workflow, enclose the expression in ${}
. For example, to convert a string ID (Trigger.stringId
) to an integer, use ${ parseInt(Trigger.stringId) }
.
The Lodash utility library is available in inline expressions. The Lodash underscore prefix (_
) is optional. For example, both ${ _.toNumber("1") }
and ${ toNumber("1") }
are valid inline expressions.
The following example uses the Lodash now()
function inside a Get hosts total step to get the count of hosts in the last minute.
The action uses the following inline expression in the From field:
${ Math.floor(now() / 1000) - 60 }
The following example increments the desired capacity inside a Set desired capacity step by 1.
The action uses the following inline expression in the Desired capacity field:
${ Steps.Describe_auto_scaling_group.autoScalingGroup.DesiredCapacity + 1 }
The Expression and Function actions perform custom data transformations within your workflows using JavaScript. Use the values of any context variables available within your workflow as inputs for your JavaScript expressions and functions with the syntax $.Steps.<step_name>.<variable>
.
The data returned by these actions can then be referenced in subsequent steps of the workflow.
You can use an underscore (_
) to make use of Lodash in your expression and function steps. For example, to reference the HTTP request status variable (status
) from the HTTP request step (Make_request
), you’d use the following context variable:
$.Steps.Make_request.status
And to determine if an array returned by Array_function
includes the name Bits
, apply the _.includes
Lodash function with the following syntax:
_.includes($.Steps.Array_function.data, "Bits")
The function action allows for variable assignments and complex data transformations requiring multiple expressions.
To add a function action:
function
. Select the Function action to add it to your workflow.function
. Select the Function action to add it to your workflow.You can use Bits AI to help you write the JavaScript for a Function step. To use this feature, perform the following steps:
In most cases, use an inline expression instead of a dedicated expression step. Expression actions accept a single line of code. For example, [1, 2, 3].filter(x => x < 3)
. Variable assignments are not available in expressions.
To add an expression action:
expression
. Select the Expression action to add it to your workflow.expression
. Select the Expression action to add it to your workflow.In an expression step, execution uses copies of all available variables. Mutating a variable within a step has no effect on the variable’s value outside of the step. To assign the result of an expression to a variable, see Set variables.
See the test and debug page to learn how to test a workflow step.
추가 유용한 문서, 링크 및 기사:
Do you have questions or feedback? Join the #workflows channel on the Datadog Community Slack.