Skip to main content
Sumo Logic

Collect Logs for Bitbucket App

This page provides instructions for collecting logs for the Sumo App for Bitbucket.

This page provides instructions for configuring log collection for the Bitbucket App. Click a link to jump to a section:

Collection Overview

Configuring log collection consists of the following tasks:

  1. Configuring a Hosted Collector in Sumo Logic to receive Bitbucket Events
  2. Registering a Webhook in Bitbucket
  3. Configuring the Bitbucket CI/CD pipeline to collect deploy Events
  4. Enable Bitbucket for Event-Key tagging

There are 2 types of events of interest from Bitbucket to Sumo Logic: 

Bitbucket Events sends the event request to the server URL for the Webhook whenever that event occurs.

Deploy Events are triggered whenever code is pushed to test, staging or production environments. These events are in the form of Success deploy events or the Failed deploy events.

Configure Hosted Collector to Receive Bitbucket events

In this step, you create a Hosted Collector to receive Webhook Events from Bitbucket and set up an HTTP source on it.

  1. Configure a Hosted Collector, or select an existing hosted collector for the HTTP source.

  2. Configure an HTTP source on the hosted collector.

    • For Source Category, specify bitbucket/events.

    • Click +Add Field and provide the following:

      • Field Name. _convertHeadersToFields

      • Value. true

    • Click Save and make note of the HTTP address for the source. You will supply it when you configure a Jira Webhook in the next step.


Adding a Webhook in Bitbucket

  1. From Bitbucket, open the repository where you want to add the Webhook.

  2. Click the Settings link on the left side.

  3. From the links on the Settings page, click the Webhooks link.

  4. Click the Add Webhook button to create a Webhook for the repository. The Add New Webhook page appears.


  1. Enter a Title with a short description.

  2. Enter Sumo Logic Http source URL, you configured this in Configure Hosted Collector to Receive Bitbucket events.

  3. Click on Status to make it Active.

  4. Triggers - Click on Choose from a full list of triggers, and choose all triggers under Repository, Issue and Pull Request

  5. Click Save

A Bitbucket pipe needs to be configured to send code deploy status to Sumo Logic. Add the following pipe code to the step section of your deployment part of the bitbucket-pipelines.yml file. Replace SUMOLOGIC_HTTP_URL with HTTP Source URL configured in Step 1.

          - pipe: docker://appdevsumologic/sumologic-send-event:1.15

For reference - This is how bitbucket-pipelines.yml looks like after adding deploy pipe code to our sample Bitbucket CI/CD pipeline.

Enable Bitbucket Event-Key tagging at Sumo Logic

Sumo Logic needs to understand the event type for incoming events (for example, repo:push events). To enable this, the X-Event-Key event type needs to be enabled. To enable this,  perform the following steps in the Sumo Logic console:

  1. From Sumo Logic, go to Manage Date - > Logs - > Fields
  2. Add Field ‎X-Event-Key


Sample Log Messages

This section provides an example of Bitbucket Events and Deploy Events log messages.

Bitbucket Events

Deploy Events

  "buildNumber": "160",
  "deploymentEnvironment": "production",
  "gitHttpOrigin": "",
  "commit": "67be2cdb4db18556df9b49872d7d3945ada3cb09",
  "branch": "master",
  "tag": "",
  "prDestinationBranch": "",
  "projectKey": "",
  "repoFullName": "app-dev-sumo/backendservice",
  "repoOwner": "app-dev-sumo",
  "pr_id": "",
  "pipe_result_link": "!/results/160",
  "deploy_status": "0",
  "commit_link": "",
  "event_date": "2020-03-23 08:07:34"

Query Example

This section provides a sample from the Failed Deployments panel on the Bitbucket Deployment dashboard.


  • Event_Date:*
  • Build_Number:*
  • Deploy_Status:*
  • Deployment_Environment:*
  • Files_Committed:*
  • Repo_Full_Name:*
  • Repo_Owner:*
  • Source_Branch:*
  • Deploy_Result:*

Query String

_sourceCategory="bitbucket" production  deploymentEnvironment pipe_result_link deploy_status commit_link 
| json field=_raw "buildNumber", "deploymentEnvironment", "branch", "repoFullName", "pipe_result_link", "deploy_status", "pr_id", "commit", "tag", "projectKey", "repoOwner", "commit_link" , "event_date" 
| repoFullName as repo_name
| where   repoFullName matches "*"  AND buildNumber matches "*"
| branch as source_branch
| if (deploy_status matches "0", "Success", "Failed") as deploy_status
| where deploymentEnvironment="production" and deploy_status="Failed"
| tourl (commit_link, concat("Commit # ",commit)) as files_commited
| tourl (pipe_result_link, buildNumber) as deploy_result
| count by event_date, buildNumber, deploy_status, deploymentEnvironment, files_commited, repoFullName, repoOwner, source_branch, deploy_result
| fields - _count