incubator-devlake icon indicating copy to clipboard operation
incubator-devlake copied to clipboard

[Bug][DORA] Webhook Deployment not appearing in DORA metrics dashboard

Open vincentpatella opened this issue 1 year ago • 4 comments

Search before asking

  • [X] I had searched in the issues and found no similar issues.

What happened

I set up a project with only a webhook as the data input and made an api call on my local machine to generate a deployment. The API call returns a success code, and I see the deployment when I look at the lake.cicd_deployments and lake.cicd_deployments_commits tables, but I don't see a mapping for it in the lake.cicd_scopes table, which I think is the main issue. Because there's no mapping for lake.cicd_scopes (there are mappings for my jenkins and AzureDevOps deployment pipelines), it doesn't show up in the DORA metrics dashboard. I followed the steps here to set it up: https://devlake.apache.org/docs/Configuration/webhook/

What do you expect to happen

I expect the deployment to show up on the DORA metrics dashboard like it does for my Jenkins and Azure DevOps deployments.

How to reproduce

  1. Create a new project named Webhook Test
  2. Create a new webhook and name it Webhook Test
  3. Run Collect Data
  4. Create an API key to authenticate with DevLake
  5. Make the following API call (using your own url):

curl http://localhost:4000/api/rest/plugins/webhook/9/deployments -X 'POST' -H 'Authorization: Bearer {MY_API_KEY}' -d '{ "id": "Test 2", "createdDate":"2024-09-02T11:00:00+00:00", "startedDate":"2024-09-02T12:00:00+00:00", "finishedDate":"2024-09-03T13:00:00+00:00", "environment":"PRODUCTION", "result": "SUCCESS", "displayTitle":"optional-custom-deploy-display-title", "name": "Test Name", "deploymentCommits":[ { "repoUrl":"required-repo-url", "refName": "optional-release-v0.17", "startedDate":"2024-01-01T11:00:00+00:00", "finishedDate":"2024-01-02T11:00:00+00:00", "commitSha":"c1", "commitMsg":"optional-msg-1", "result":"SUCCESS", "name":"Test Commit 1", "displayTitle":"Test Commit 1" }, { "repoUrl":"repo-2", "refName": "optional-release-v0.17", "startedDate":"2024-01-01T11:00:00+00:00", "finishedDate":"2024-01-02T11:00:00+00:00", "commitSha":"c2", "commitMsg":"optional-msg-2", "result":"FAILURE", "name":"Test Commit 2", "displayTitle":"Test Commit 2" } ] }'

  1. Run Collect Data
  2. Check the DORA or DORA Details - Deployment Frequency dashboard

Anything else

I have tried multiple projects and multiple webhooks, but still have this problem with each one.

Version

v1.0.1-beta8@e195107

Are you willing to submit PR?

  • [ ] Yes I am willing to submit a PR!

Code of Conduct

vincentpatella avatar Sep 17 '24 15:09 vincentpatella

Hello @vincentpatella! 👋 I'm here to help you with any bugs, questions, or contributions you have for the project. Let's tackle this together!

I found a similar closed issue: [Bug][DORA] Webhook incidents do not appear, which was resolved by a pull request: fix: add webhook boards in project_mapping table on August 16, 2023 [1].

The deployment created via webhook is not appearing in the DORA metrics dashboard because it is likely not associated with a DevLake project. To resolve this, follow these steps:

  1. Go to the Projects page in DevLake.
  2. Create or select the relevant project.
  3. Add the existing webhook to this project.
  4. Ensure that the data collection is started by clicking Collect All in the blueprint status tab.

This association is necessary for the deployment data to be included in the DORA metrics dashboard. Additionally, ensure that the webhook configuration is correctly set up to push deployment data to DevLake, as described in the documentation. This includes verifying that the webhook payload schema matches the expected format and that the data is being correctly recorded in the cicd_deployments and cicd_deployment_commits tables [2].

For more detailed guidance on setting up and troubleshooting DORA metrics, you can refer to the DORA implementation guide and the DORA troubleshooting documentation. Additionally, you can review the DORA metrics documentation for comprehensive information on implementing and configuring DORA metrics in DevLake [3][4][5].

Furthermore, if you are using webhooks to push deployment data, ensure that the payload schema is correctly formatted. The required fields for deployment data include id, startedDate, finishedDate, and deploymentCommits with their respective repoUrl, commitSha, startedDate, and finishedDate. For more details on the payload schema and sample API calls, refer to the Webhook Plugin documentation [6].

To continue talking to Dosu, mention @dosu.

dosubot[bot] avatar Sep 17 '24 15:09 dosubot[bot]

Hi, I had already looked at that issue and it did not help. The webhook is also already associated with a project and I copied the payload from the Webhook documentation for the fields before editing the data to match what a typical deployment would expect.

vincentpatella avatar Sep 17 '24 16:09 vincentpatella

Hi @vincentpatella , we'll look into this problem.

Startrekzky avatar Sep 18 '24 13:09 Startrekzky

Hi @vincentpatella , I followed the steps you provided with two differences:

The URL’s IP and API key are from my own environment. In the POST request, I updated deploymentCommits[0].startedDate and deploymentCommits[0].finishedDate to more recent dates. Other than that, everything remained the same. After completing the steps, I checked the Deployment Frequency dashboard, and there is data, as shown in the attached screenshot. img_v3_02f1_9602e126-def9-462a-8de4-b29da3f0a69g img_v3_02f1_e15e0d28-e23d-4749-94a1-25968aae4ffg

Could you confirm if the data in the screenshot is what you were expecting?

xiaomingzhang12 avatar Sep 24 '24 08:09 xiaomingzhang12

This issue has been automatically marked as stale because it has been inactive for 60 days. It will be closed in next 7 days if no further activity occurs.

github-actions[bot] avatar Nov 24 '24 00:11 github-actions[bot]

This issue has been closed because it has been inactive for a long time. You can reopen it if you encounter the similar problem in the future.

github-actions[bot] avatar Dec 01 '24 00:12 github-actions[bot]