Integrate LaunchDarkly with Dynatrace Cloud Automation
Integrating Dynatrace Cloud Automation with LaunchDarkly allows you to automatically enable or disable feature flags to remediate problems when specific operational health thresholds or alerts are triggered, or as part of software delivery lifecycle delivery and testing.
To integrate Dynatrace Cloud Automation with LaunchDarkly, follow the instructions below.
Prerequisites
LaunchDarkly
Dynatrace
LaunchDarkly
-
A LaunchDarkly Enterprise feature account.
-
Enable the Writer role on your LaunchDarkly account.
If you use custom roles to manage your team, your member account must have the
createTriggers
action in order to create flag triggers. -
Create a feature flag for Cloud Automation.
-
Create a trigger and configure it to take action on the Cloud Automation feature flag.
Dynatrace
-
Create a Cloud Automation project with a shipyard file that has a custom task (for example,
setflag
) to trigger the LaunchDarkly webhook subscription. -
Add the LaunchDarkly flag trigger obtained above as a Cloud Automation secret.
Set up the LaunchDarkly webhook subscription
Use case: Set up a passive webhook subscription that toggles a flag to an ON
or OFF
state. The Cloud Automation sequence will not wait for the LaunchDarkly flag trigger to send back a Cloud Automation sequence task finished event.
-
On the Cloud Automation bridge, select your Cloud Automation project.
-
Select Settings, and then select Integrations.
-
Select webhook-service from the list, and then select Add subscription.
-
Enter the following values:
- Task: Select the task associated with your shipyard file (in this case,
setflag
). - Task suffix: Select
triggered
. - Request method: Select
POST
. - URL: Enter your URL endpoint, using the placeholder of the secret created earlier (for example,
https://app.launchdarkly.com/webhook/triggers/{{.secret.launchdarkly.myfeature}}
).
- Task: Select the task associated with your shipyard file (in this case,
-
Select Add custom header and enter the following values:
- Name: Enter
Content-Type
. - Value: Enter
application/json
.
- Name: Enter
-
optional Enter a Custom payload.
LaunchDarkly triggers work without any request body, but you can add different attributes to enhance the flag's audit log. Any combination of properties will return information, and any attribute is optional.
Example:
Be sure to replace the URL in the example below with your Cloud Automation web console URL.
{
"eventName": "{{.type}}",
"value": "{{.data.status}}",
"url": "https://example.cloudautomation.live.dynatrace.com/bridge/project/{{.data.project}}/sequence/{{.shkeptncontext}}/stage/{{.data.stage}}"
}
-
Under Send finished event, select
automatically
. -
Select Create subscription.
Trigger a sequence
Cloud Automation triggers LaunchDarkly whenever the defined task in the sequence is triggered.
To trigger the sequence, you can send the event command in the Keptn CLI.
- Create a file called
triggered-event.json
.
Example:
{
"type": "sh.keptn.event.mystage.mysequence.triggered",
"specversion":"1.0",
"source":"manual-trigger"
"data":{
"project":"demo",
"stage":"production",
"service":"myservice"
}
-
Send the event.
keptn send event --file triggered-event.json
After sending the event, you can
- Monitor the sequence progress on the project’s Cloud Automation sequence page
- Monitor the flag targeting status on the LaunchDarkly flag targeting page
- Monitor the audit log in LaunchDarkly to see the changes made to your flag after the trigger execution