Skip to content

Commit

Permalink
integrations: Update New Relic integration.
Browse files Browse the repository at this point in the history
Add new features to the integration, updated media files
such as logo and bot avatar, updated doc, updated test
fixtures and deleted legacy codes.

Fixes zulip#29729

Co-authored-by: Giovanni Silva <no-reply@gsilva.pro>
  • Loading branch information
Giovanni Silva authored and PieterCK committed Apr 23, 2024
1 parent b45c5a3 commit 92c05bf
Show file tree
Hide file tree
Showing 48 changed files with 886 additions and 490 deletions.
Binary file modified static/images/integrations/bot_avatars/newrelic.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion static/images/integrations/logos/newrelic.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/integrations/newrelic/001.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/integrations/newrelic/002.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed static/images/integrations/newrelic/003.png
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed static/images/integrations/newrelic/newrelic.png
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions zerver/lib/integrations.py
Expand Up @@ -784,9 +784,11 @@ def __init__(self, name: str, *args: Any, **kwargs: Any) -> None:
"nagios": [BaseScreenshotConfig("service_notify.json")],
"netlify": [ScreenshotConfig("deploy_building.json")],
"newrelic": [
ScreenshotConfig("incident_active_new.json", "001.png"),
ScreenshotConfig("incident_acknowledged_new.json", "002.png"),
ScreenshotConfig("incident_closed_new.json", "003.png"),
ScreenshotConfig("incident_activated_new_default_payload.json", "001.png"),
ScreenshotConfig("incident_activated_new_provided_base_payload.json", "002.png"),
ScreenshotConfig(
"incident_provided_base_with_zulip_custom_fields.json", "custom_payload_notif.png"
),
],
"opbeat": [ScreenshotConfig("error_reopen.json")],
"opencollective": [ScreenshotConfig("one_time_donation.json")],
Expand Down
31 changes: 31 additions & 0 deletions zerver/webhooks/newrelic/__init__.py
@@ -0,0 +1,31 @@
from enum import Enum
from typing import List, Literal

# Expected variables from payloads & constant variables


class ConstantVariable(Enum):
@classmethod
def as_list(cls, target: Literal["value", "name"] = "value") -> List[str]:
return [item.value for item in cls] if target == "value" else [item.name for item in cls]


class IncidentStates(ConstantVariable):
CREATED = "Created"
ACTIVATED = "Activated"
CLOSED = "Closed"


class IncidentPrioritiesItems(ConstantVariable):
CRITICAL = ":red_circle:"
HIGH = ":orange_circle:"
MEDIUM = ":yellow:"
LOW = ":blue_circle:"


class IncidentTimeStamps(ConstantVariable):
CREATED = "createdAt"
ACTIVATED = "activatedAt"
UPDATED = "updatedAt"
CLOSED = "closedAt"
ACKNOWLEDGED = "acknowledgedAt"
65 changes: 54 additions & 11 deletions zerver/webhooks/newrelic/doc.md
@@ -1,27 +1,70 @@
New Relic can send messages to a Zulip stream for incidents.
# New Relic ClickUp integration

Get Zulip notifications for your New Relic incidents!

{start_tabs}

1. {!create-stream.md!}

1. {!create-an-incoming-webhook.md!}

1. {!generate-integration-url.md!}
1. {!generate-webhook-url-basic.md!}

1. On [New Relic](https://one.newrelic.com),
select **Alerts & AI**.
1. Go to the [**Destinations**](https://one.newrelic.com/alerts-ai/notify/destinations) menu and select **Webhook** in the **Add a destination** section. ([*Official Guide*](https://docs.newrelic.com/docs/alerts-applied-intelligence/notifications/notification-integrations/#set-webhook-destination))

1. Navigate to **Notification channels**.
1. Set **Endpoint URL** to the URL you generated.

1. Create a new notification channel. Select channel type of **Webhook**, choose a name (e.g. "Zulip"), enter the webhook url created earlier as **Base Url**.
1. Go to the [**Workflows**](https://one.newrelic.com/alerts-ai/workflows) menu and click on **+ Add a Workflow** button. After filtering the trigger condition, select on the **Webhook** option in the **Add Channel** section. ([*Workflow doc*](https://docs.newrelic.com/docs/alerts-applied-intelligence/applied-intelligence/incident-workflows/incident-workflows/))

1. It should look like:
![](/static/images/integrations/newrelic/newrelic.png)
1. Once you're in the **Edit notification message** menu, select the destination for Zulip you've just created earlier.

1. The webhook works with the default payload, click **Create channel**.
1. If you want to include additional information to the notification, refer to this [section](#displaying-custom-fields-in-payload). There's also an optional [base payload template](#recommended-base-payload-template) we recommend you to use.

1. After creating the channel send a test notification to make sure it works.
1. Select **Save message** and the **Activate Workflow** to finish.
{end_tabs}

{!congrats.md!}

![](/static/images/integrations/newrelic/001.png)

![](/static/images/integrations/newrelic/002.png)
![](/static/images/integrations/newrelic/003.png)

### Displaying Custom Fields

The New Relic integration supports the [custom payload feature](https://docs.newrelic.com/docs/alerts-applied-intelligence/notifications/message-templates/) offered by New Relic.
To include your custom fields in your Zulip New Relic notification, follow these rules:

* Put all your custom key-value pairs in a new dictionary called `zulipCustomFields`.

* The Key must be in Camel Case format. Keep in mind that it will be reformatted and
displayed in the notification message, so use descriptive words.

* The supported data-type for the custom payload are: `string`, `list`, `int` and `bool`.
Custom payload containing `dict` are not supported

*example custom payload inside `zulipCustomFields`:*
![](/static/images/integrations/newrelic/custom_payload_example.png)

*the Zulip notification from the payload above:*
![](/static/images/integrations/newrelic/custom_payload_notif.png)

Only custom fields inside the `zulipCustomFields` dictionary will be displayed

### Recommended Base Payload Template

Although the out of the box payload template is already sufficient
to get the integration working, the additional fields provided from
this template will enable the integration to notify you of any
**acknowledged** incidents:

(THIS IMAGE IS TEMPORARYY, placeholder,)
![](/static/images/integrations/newrelic/temporary_payload_example.png)

[1]: ./zapier

[2]: https://raw.githubusercontent.com/zulip/python-zulip-api/main/zulip/integrations/clickup/zulip_clickup.py


### Related documentation

{!webhooks-url-specification.md!}
@@ -0,0 +1,11 @@
{
"issueUrl": "https://radar-api.service.newrelic.com/accounts/1/issues/0ea2df1c-adab-45d2-aae0-042b609d2322?notifier=SLACK",
"title": "PIETER-UBUNTU query result is > 2.0 for 1 minutes on 'High CPU'",
"priority": "CRITICAL",
"totalIncidents": 1,
"state": "CREATED",
"createdAt": 1713592289021,
"updatedAt": 1713592289021,
"alertPolicyNames": ["Golden Signals"],
"alertConditionNames": ["High CPU"]
}
@@ -0,0 +1,25 @@
{
"id": "13bbcdca-f0b6-470d-b0be-b34583c58869",
"issueUrl": "https://radar-api.service.newrelic.com/accounts/4420147/issues/13bbcdca-f0b6-470d-b0be-b34583c58869?notifier=WEBHOOK",
"title": "PIETER-UBUNTU query result is > 1.0 for 5 minutes on 'Storage on Host Exceeded Threshold'",
"priority": "HIGH",
"impactedEntities": [
"PIETER-UBUNTU"
],
"totalIncidents": "1",
"state": "ACTIVATED",
"trigger": "USER_ACTION",
"isCorrelated": "false",
"createdAt": 1713769949493,
"updatedAt": 1713770077412,
"sources": [
"newrelic"
],
"alertPolicyNames": [
"Golden Signals"
],
"alertConditionNames": [
"Storage on Host Exceeded Threshold"
],
"workflowName": "issue workflow"
}
11 changes: 0 additions & 11 deletions zerver/webhooks/newrelic/fixtures/incident_acknowledged_new.json

This file was deleted.

11 changes: 0 additions & 11 deletions zerver/webhooks/newrelic/fixtures/incident_acknowledged_old.json

This file was deleted.

@@ -0,0 +1,31 @@
{
"id": "13bbcdca-f0b6-470d-b0be-b34583c58869",
"issueUrl": "https://radar-api.service.newrelic.com/accounts/4420147/issues/13bbcdca-f0b6-470d-b0be-b34583c58869?notifier=WEBHOOK",
"title": "PIETER-UBUNTU query result is > 1.0 for 5 minutes on 'Storage on Host Exceeded Threshold'",
"priority": "HIGH",
"impactedEntities": [
"PIETER-UBUNTU"
],
"totalIncidents": "1",
"state": "ACTIVATED",
"trigger": "USER_ACTION",
"isCorrelated": "false",
"createdAt": 1713769949493,
"closedAt": "N/A",
"updatedAt": 1713770077412,
"sources": [
"newrelic"
],
"alertPolicyNames": [
"Golden Signals"
],
"alertConditionNames": [
"Storage on Host Exceeded Threshold"
],
"workflowName": "issue workflow",
"acknowledgedAt": 1713770077412,
"acknowedgedBy": "1005906594",
"owner": "Pieter Cardillo Kwok",
"zulipCustomFields": {
}
}
@@ -0,0 +1,25 @@
{
"id": "c5faa7e6-7b54-402d-af79-f99601e0278c",
"issueUrl": "https://radar-api.service.newrelic.com/accounts/4420147/issues/c5faa7e6-7b54-402d-af79-f99601e0278c?notifier=WEBHOOK",
"title": "zulip_app query result is > 1.0 for 1 minutes on 'Zulip Server Low Storage'",
"priority": "CRITICAL",
"impactedEntities": [
"zulip_app"
],
"totalIncidents": 1,
"state": "ACTIVATED",
"trigger": "STATE_CHANGE",
"isCorrelated": false,
"createdAt": 1713755131352,
"updatedAt": 1713769708699,
"sources": [
"newrelic"
],
"alertPolicyNames": [
"Golden Signals"
],
"alertConditionNames": [
"Zulip Server Low Storage"
],
"workflowName": "testWorkflow"
}
@@ -0,0 +1,32 @@
{
"id": "13bbcdca-f0b6-470d-b0be-b34583c58869",
"issueUrl": "https://radar-api.service.newrelic.com/accounts/4420147/issues/13bbcdca-f0b6-470d-b0be-b34583c58869?notifier=WEBHOOK",
"title": "PIETER-UBUNTU query result is > 1.0 for 5 minutes on 'Storage on Host Exceeded Threshold'",
"priority": "HIGH",
"impactedEntities": [
"PIETER-UBUNTU"
],
"totalIncidents": "1",
"state": "ACTIVATED",
"trigger": "STATE_CHANGE",
"isCorrelated": "false",
"createdAt": 1713769949493,
"closedAt": "N/A",
"updatedAt": 1713769949494,
"sources": [
"newrelic"
],
"alertPolicyNames": [
"Golden Signals"
],
"alertConditionNames": [
"Storage on Host Exceeded Threshold"
],
"workflowName": "issue workflow",
"acknowledgedAt": "N/A",
"acknowedgedBy": "N/A",
"owner": "N/A",
"zulipCustomFields": {
"yourCustomPayload": "somedata123"
}
}
11 changes: 0 additions & 11 deletions zerver/webhooks/newrelic/fixtures/incident_active_new.json

This file was deleted.

@@ -0,0 +1,17 @@
{
"id": "95a9344a-2590-48ce-8d83-07e28b6d22c6",
"issueUrl": "https://radar-api.service.newrelic.com/accounts/1/issues/0ea2df1c-adab-45d2-aae0-042b609d2322?notifier=SLACK",
"title": "main_app-UBUNTU query result is > 2.0 for 1 minutes on 'High CPU'",
"priority": "CRITICAL",
"impactedEntities": ["main_app-UBUNTU"],
"totalIncidents": 1,
"state": "CLOSED",
"trigger": "INCIDENT_CLOSED",
"isCorrelated": false,
"createdAt": 1713766590228,
"updatedAt": 1713766657383,
"sources": ["newrelic"],
"alertPolicyNames": ["Golden Signals"],
"alertConditionNames": ["High CPU"],
"workflowName": "DBA Team workflow"
}
11 changes: 0 additions & 11 deletions zerver/webhooks/newrelic/fixtures/incident_closed_new.json

This file was deleted.

11 changes: 0 additions & 11 deletions zerver/webhooks/newrelic/fixtures/incident_closed_old.json

This file was deleted.

@@ -0,0 +1,32 @@
{
"id": "13bbcdca-f0b6-470d-b0be-b34583c58869",
"issueUrl": "https://radar-api.service.newrelic.com/accounts/4420147/issues/13bbcdca-f0b6-470d-b0be-b34583c58869?notifier=WEBHOOK",
"title": "PIETER-UBUNTU query result is > 1.0 for 5 minutes on 'Storage on Host Exceeded Threshold'",
"priority": "HIGH",
"impactedEntities": [
"PIETER-UBUNTU"
],
"totalIncidents": "1",
"state": "CLOSED",
"trigger": "USER_ACTION",
"isCorrelated": "false",
"createdAt": 1713769949493,
"closedAt": 1713770135419,
"updatedAt": 1713770135419,
"sources": [
"newrelic"
],
"alertPolicyNames": [
"Golden Signals"
],
"alertConditionNames": [
"Storage on Host Exceeded Threshold"
],
"workflowName": "issue workflow",
"acknowledgedAt": 1713770077412,
"acknowedgedBy": "1005906594",
"owner": "Pieter Cardillo Kwok",
"zulipCustomFields": {
"yourCustomPayload": "somedata123"
}
}
@@ -0,0 +1,25 @@
{
"id": "208c5e92-f250-40be-b7c2-50508c268c15",
"issueUrl": "https://radar-api.service.newrelic.com/accounts/1/issues/0ea2df1c-adab-45d2-aae0-042b609d2322?notifier=SLACK",
"title": "MAIN-APP-UBUNTU query result is > 2.0 for 1 minutes on 'High CPU'",
"priority": "CRITICAL",
"impactedEntities": [
"MAIN-APP-UBUNTU"
],
"totalIncidents": 1,
"state": "CREATED",
"trigger": "INCIDENT_ADDED",
"isCorrelated": false,
"createdAt": 1713767789495,
"updatedAt": 1713767789495,
"sources": [
"newrelic"
],
"alertPolicyNames": [
"Golden Signals"
],
"alertConditionNames": [
"High CPU"
],
"workflowName": "DBA Team workflow"
}

0 comments on commit 92c05bf

Please sign in to comment.