Skip to main content

Check out Port for yourselfย 

Report a Jira bug from a New Relic alert

Overviewโ€‹

This guide will help you implement a self-service action in Port that allows you to report bugs in Jira based on New Relic alert in one click, ensuring prompt issue resolution and improving overall platform reliability.

You can implement this action in two ways:

  1. Synced webhooks: A simpler approach that directly interacts with Jira's API through Port, ideal for quick implementation and minimal setup.
  2. GitHub workflow: A more flexible approach that allows for complex workflows and custom logic, suitable for teams that want to maintain their automation in Git.

Prerequisitesโ€‹

Set up data modelโ€‹

If you have installed Port's Jira integration and New Relic integration, the relevant blueprints will be automatically created in your portal.

If you chose not to install the integrations, you will need to create the blueprints manually:

Create the jira issue blueprint

  1. Go to your Builder page.

  2. Click on + Blueprint.

  3. Click on the {...} button in the top right corner, and choose "Edit JSON".

  4. Add this JSON schema:

    Jira Issue Blueprint (Click to expand)
    {
    "identifier": "jiraIssue",
    "title": "Jira Issue",
    "icon": "Jira",
    "schema": {
    "properties": {
    "url": {
    "title": "Issue URL",
    "type": "string",
    "format": "url",
    "description": "URL to the issue in Jira"
    },
    "status": {
    "title": "Status",
    "type": "string",
    "description": "The status of the issue"
    },
    "issueType": {
    "title": "Type",
    "type": "string",
    "description": "The type of the issue"
    },
    "components": {
    "title": "Components",
    "type": "array",
    "description": "The components related to this issue"
    },
    "assignee": {
    "title": "Assignee",
    "type": "string",
    "format": "user",
    "description": "The user assigned to the issue"
    },
    "reporter": {
    "title": "Reporter",
    "type": "string",
    "description": "The user that reported to the issue",
    "format": "user"
    },
    "priority": {
    "title": "Priority",
    "type": "string",
    "description": "The priority of the issue"
    },
    "created": {
    "title": "Created At",
    "type": "string",
    "description": "The created datetime of the issue",
    "format": "date-time"
    },
    "updated": {
    "title": "Updated At",
    "type": "string",
    "description": "The updated datetime of the issue",
    "format": "date-time"
    }
    }
    },
    "calculationProperties": {},
    "relations": {}
    }

  5. Click "Save" to create the blueprint.

Create the New Relic Alert blueprint

  1. Go to your Builder page.

  2. Click on + Blueprint.

  3. Click on the {...} button in the top right corner, and choose "Edit JSON".

  4. Add this JSON schema:

    New Relic Alert Blueprint (Click to expand)
    {
    "identifier": "newRelicAlert",
    "description": "This blueprint represents a New Relic alert in our software catalog",
    "title": "New Relic Alert",
    "icon": "NewRelic",
    "ownership": {
    "type": "Inherited",
    "title": "Owning Teams",
    "path": "alert_to_workload.service"
    },
    "schema": {
    "properties": {
    "priority": {
    "type": "string",
    "title": "Priority",
    "enum": [
    "CRITICAL",
    "HIGH",
    "MEDIUM",
    "LOW"
    ],
    "enumColors": {
    "CRITICAL": "red",
    "HIGH": "red",
    "MEDIUM": "yellow",
    "LOW": "green"
    }
    },
    "state": {
    "type": "string",
    "title": "State",
    "enum": [
    "ACTIVATED",
    "CLOSED",
    "CREATED"
    ],
    "enumColors": {
    "ACTIVATED": "yellow",
    "CLOSED": "green",
    "CREATED": "lightGray"
    }
    },
    "sources": {
    "type": "array",
    "items": {
    "type": "string"
    },
    "title": "Sources"
    },
    "alertPolicyNames": {
    "type": "array",
    "items": {
    "type": "string"
    },
    "title": "Alert Policy Names"
    },
    "conditionName": {
    "type": "array",
    "items": {
    "type": "string"
    },
    "title": "Condition Name"
    },
    "link": {
    "type": "string",
    "title": "Link",
    "format": "url"
    },
    "description": {
    "type": "string",
    "title": "Description"
    },
    "activatedAt": {
    "type": "string",
    "title": "Activated at",
    "format": "date-time"
    }
    },
    "required": []
    },
    "mirrorProperties": {
    "cloud_resource_name": {
    "title": "Cloud Resource",
    "path": "cloud_resource.$title"
    },
    "port_service": {
    "title": "Service",
    "path": "alert_to_workload.service.$title"
    },
    "team": {
    "title": "Team",
    "path": "alert_to_workload.service.$team"
    },
    "workload_name": {
    "title": "Workload name",
    "path": "alert_to_workload.$title"
    },
    "pager_duty_service": {
    "title": "Pager duty service",
    "path": "alert_to_workload.service.pager_duty_service.$identifier"
    }
    },
    "calculationProperties": {},
    "aggregationProperties": {},
    "relations": {
    "alert_to_workload": {
    "title": "Workload",
    "target": "workload",
    "required": false,
    "many": false
    },
    "cloud_resource": {
    "title": "Cloud resource",
    "target": "newRelicCloudResource",
    "required": false,
    "many": false
    }
    }
    }

  5. Click "Save" to create the blueprint.

Implementationโ€‹

You can create Jira bugs by leveraging Port's synced webhooks and secrets to directly interact with the Jira's API. This method simplifies the setup by handling everything within Port.

Add Port secrets

Existing secrets

If you have already installed Port's Jira integration, these secrets should already exist in your portal.
To view your existing secrets:

  1. Click on the ... button in the top right corner of your Port application.
  2. Choose Credentials, then click on the Secrets tab.

To add these secrets to your portal:

  1. Click on the ... button in the top right corner of your Port application.

  2. Click on Credentials.

  3. Click on the Secrets tab.

  4. Click on + Secret and add the following secrets:

    • JIRA_API_TOKEN - Your Jira API token

    • JIRA_USER_EMAIL - The email of the Jira user that owns the API token

    • JIRA_AUTH - Base64 encoded string of your Jira credentials. Generate this by running:

      echo -n "your-email@domain.com:your-api-token" | base64

      Replace your-email@domain.com with your Jira email and your-api-token with your Jira API token.

      One time generation

      The base64 encoded string only needs to be generated once and will work for all webhook calls until you change your API token.

Set up self-service action

Follow these steps to create the self-service action:

  1. Head to the self-service page.

  2. Click on the + New Action button.

  3. Click on the {...} Edit JSON button.

  4. Copy and paste the following JSON configuration into the editor.

    Report a bug from New Relic alert action (Webhook) (Click to expand)
    {
    "identifier": "report_a_jira_bug_from_new_relic_alert",
    "title": "Report a bug from New Relic alert (Webhook)",
    "icon": "Jira",
    "description": "Report a Jira bug in Port based on a New Relic alert.",
    "trigger": {
    "type": "self-service",
    "operation": "DAY-2",
    "userInputs": {
    "properties": {
    "project": {
    "title": "Project",
    "description": "The Jira project where the bug will be created",
    "icon": "Jira",
    "type": "string",
    "blueprint": "jiraProject",
    "format": "entity"
    }
    },
    "required": [
    "project"
    ],
    "order": [
    "project"
    ]
    },
    "blueprintIdentifier": "newRelicAlert"
    },
    "invocationMethod": {
    "type": "WEBHOOK",
    "url": "https://<JIRA_ORGANIZATION_URL>.atlassian.net/rest/api/3/issue",
    "agent": false,
    "synchronized": true,
    "method": "POST",
    "headers": {
    "Authorization": "Basic {{.secrets.JIRA_AUTH}}",
    "Content-Type": "application/json"
    },
    "body": {
    "fields": {
    "project": {
    "key": "{{.inputs.project.identifier}}"
    },
    "summary": "Bug | New Relic | {{.entity.title}}",
    "description": {
    "version": 1,
    "type": "doc",
    "content": [
    {
    "type": "paragraph",
    "content": [
    {
    "type": "text",
    "text": "\n New Relic description: {{.entity.description}}\n\n New Relic link: {{.entity.link}}"
    }
    ]
    },
    {
    "type": "paragraph",
    "content": [
    {
    "type": "text",
    "text": "Reported by: {{.trigger.by.user.email}}"
    }
    ]
    }
    ]
    },
    "issuetype": {
    "name": "Bug"
    }
    }
    }
    },
    "requiredApproval": false
    }
  5. Click Save.

Configure your Jira url

Replace <JIRA_ORGANIZATION_URL> in the webhook URL with your Jira organization URL (e.g., example.atlassian.net).

Now you should see the Report a bug from New Relic alert action in the self-service page. ๐ŸŽ‰

Let's test it!โ€‹

  1. Head to the self-service page of your portal

  2. Choose either the GitHub workflow or webhook implementation:

    • For webhook: Click on Report a bug from New Relic alert (Webhook)
    • For GitHub workflow: Click on Report a bug from New Relic alert (GitHub actions)
  3. Fill in the bug details:

    • Select the New Relic alert that will trigger the creation of the Jira bug
    • Select the Jira project where the bug will be created
  4. Click on Execute

  5. Done! wait for the bug to be created in Jira