-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
175 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
content/en/serverless/step_functions/link-with-lambda-traces.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
--- | ||
title: Link Step Functions and Lambda Traces | ||
further_reading: | ||
- link: '/serverless/step_functions/installation' | ||
tag: 'Documentation' | ||
text: 'Install Serverless Monitoring for AWS Step Functions' | ||
--- | ||
|
||
This page describes how to link your AWS Step Function traces with related AWS Lambda traces. | ||
|
||
### Requirements | ||
- Node.js (layer v112+) or Python (layer v95+) runtimes | ||
- You have [instrumented your AWS Lambda functions][1] to send traces to Datadog | ||
- You have [instrumented your AWS Step Functions][2] to send traces to Datadog | ||
|
||
## Setup | ||
|
||
{{< tabs >}} | ||
{{% tab "Serverless Framework" %}} | ||
|
||
In your `serverless.yaml` file, set `mergeStepFunctionAndLambdaTraces` to `true`: | ||
|
||
{{< highlight yaml "hl_lines=8" >}} | ||
custom: | ||
datadog: | ||
site: <DATADOG_SITE> | ||
apiKeySecretArn: <DATADOG_API_KEY_SECRET_ARN> | ||
forwarderArn: <FORWARDER_ARN> | ||
enableStepFunctionsTracing: true | ||
propagateUpstreamTrace: true | ||
mergeStepFunctionAndLambdaTraces: true | ||
{{< /highlight >}} | ||
|
||
{{% /tab %}} | ||
{{% tab "Datadog CLI" %}} | ||
|
||
Run the following `datadog-ci` command: | ||
|
||
```shell | ||
datadog-ci stepfunctions instrument \ | ||
--step-function <STEP_FUNCTION_ARN> \ | ||
--forwarder <FORWARDER_ARN> \ | ||
--env <ENVIRONMENT> \ | ||
--propagate-upstream-trace \ | ||
--merge-step-function-and-lambda-traces | ||
``` | ||
|
||
{{% /tab %}} | ||
{{% tab "Custom" %}} | ||
|
||
On the Lambda Task, set the `Parameters` key with the following: | ||
|
||
```json | ||
"Parameters": { | ||
"Payload.$": "States.JsonMerge($$, $, false)", | ||
... | ||
} | ||
``` | ||
|
||
The `JsonMerge` [intrinsic function][1] merges the [Step Functions context object][2] (`$$`) with the original Lambda's input payload (`$`). Fields of the original payload overwrite the Step Functions context object if their keys are the same. | ||
|
||
**Example**: | ||
|
||
{{< highlight json "hl_lines=5-5" >}} | ||
"Lambda Read From DynamoDB": { | ||
"Type": "Task", | ||
"Resource": "arn:aws:states:::lambda:invoke", | ||
"Parameters": { | ||
"Payload.$": "States.JsonMerge($$, $, false)", | ||
"FunctionName": "${lambdaArn}" | ||
}, | ||
"End": true | ||
} | ||
{{< /highlight >}} | ||
|
||
Alternatively, if you have business logic defined in the payload, you can also use the following: | ||
|
||
{{< highlight json "hl_lines=7-9" >}} | ||
"Lambda Read From DynamoDB": { | ||
"Type": "Task", | ||
"Resource": "arn:aws:states:::lambda:invoke", | ||
"Parameters": { | ||
"Payload": { | ||
... | ||
"Execution.$": "$$.Execution", | ||
"State.$": "$$.State", | ||
"StateMachine.$": "$$.StateMachine" | ||
}, | ||
"FunctionName": "${lambdaArn}" | ||
}, | ||
"End": true | ||
} | ||
{{< /highlight >}} | ||
|
||
[1]: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html#asl-intrsc-func-json-manipulate | ||
[2]: https://docs.aws.amazon.com/step-functions/latest/dg/input-output-contextobject.html | ||
|
||
{{% /tab %}} | ||
{{< /tabs >}} | ||
|
||
[1]: /serverless/installation/#installation-instructions | ||
[2]: /serverless/step_functions/installation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
title: Retry or redrive AWS Step Function executions | ||
further_reading: | ||
- link: 'https://docs.aws.amazon.com/step-functions/latest/dg/redrive-executions.html' | ||
tag: 'AWS Developer Guide' | ||
text: 'Restarting state machine executions with redrive in Step Functions' | ||
- link: "/service_management/app_builder/" | ||
tag: "Documentation" | ||
text: "Datadog App Builder" | ||
--- | ||
|
||
You can retry any execution that is being monitored or [redrive][1] executions to continue failed AWS Step Functions from the point of failure, without needing a complete state machine restart. You can do this directly within Datadog. | ||
|
||
{{< img src="serverless/step_functions/redrive.png" alt="A visualization of a failed Step Function execution." style="width:100%;" >}} | ||
|
||
## Enable redrive within Datadog | ||
To enable using redrive within Datadog, configure an [AWS Connection][3] with [Datadog App Builder][4]. Ensure that your IAM roles include policies that have permissions to allow executing a Step Function for the retry action (`StartExecution`) or redriving a Step Function for the redrive action (`RedriveExecution`). | ||
|
||
## Usage | ||
To take action on a Step Function in Datadog: | ||
1. Go to the [Step Functions][2] page. | ||
2. Find the Step Function you wish to redrive. | ||
3. Open this Step Function's side panel or State Machine Map. | ||
4. Click on the **Failed** pill to open a redrive modal. | ||
|
||
## Further Reading | ||
|
||
{{< partial name="whats-next/whats-next.html" >}} | ||
|
||
[1]: https://docs.aws.amazon.com/step-functions/latest/dg/redrive-executions.html | ||
[2]: https://app.datadoghq.com/functions?cloud=aws&entity_view=step_functions | ||
[3]: https://docs.aws.amazon.com/dtconsole/latest/userguide/welcome-connections.html | ||
[4]: /service_management/app_builder/ |