snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled

This commit is contained in:
upstream-mirror
2026-09-15 15:05:30 +05:00
commit 64898b2c79
8999 changed files with 1757358 additions and 0 deletions

View File

View File

@@ -0,0 +1,82 @@
# Zulip OpenSearch integration
Get OpenSearch alerts in Zulip!
### Create Zulip bot for OpenSearch notifications
{start_tabs}
1. {!create-an-incoming-webhook.md!}
1. {!generate-webhook-url-basic.md!}
{end_tabs}
### Create an OpenSearch notification channel
{start_tabs}
1. From the OpenSearch Menu, select **Notifications** from the
**Management** section, and click **Create channel**.
1. Fill in the name and description. For **Channel type**, select
**Custom webhook**. Set the **Method** to **POST**, and the **Define
endpoints by** to **Webhook URL**. Paste the URL generated above into the
**Webhook URL** field.
1. Click **Send test message**. A test message should appear in Zulip. Click
**Create** to save the notification channel.
{end_tabs}
### Create an OpenSearch alert monitor
{start_tabs}
1. To use the notification channel created above in an alerting action,
create an alert monitor. From the OpenSearch menu, select
**Alerting** from the **OpenSearch Plugins** section, and click
**Create monitor**.
1. [Configure the alert monitor][alert-monitor] by entering the
monitor details, selecting the index to monitor, and adding a
[trigger][trigger]. In the **Actions** section, select the notification
channel created above as the **Notification** action.
1. OpenSearch sends notifications as plain text, so you will want to use a
**Message template** to format your messages in Zulip. To generate the
topic of your Zulip messages via the notification content, you can use
the first line of your template to do so. It must be formatted as
**topic: DYNAMIC_TOPIC_CONTENT**, and all message content should start on
the second line of the template. For example, this template was used to
generate the example screenshot below:
```
{% raw %}
topic: {{ctx.monitor.name}}
Alert of severity **{{ctx.trigger.severity}}** triggered by **{{ctx.trigger.name}}**.
{% endraw %}
```
!!! tip ""
The **Message template** supports Markdown and Mustache template
variables.
1. Click **Send test message** to test the integration, and click **Create**
to save the monitor.
{end_tabs}
{!congrats.md!}
![](/static/images/integrations/opensearch/001.png)
### Related documentation
{!webhooks-url-specification.md!}
* [OpenSearch alert monitor][alert-monitor]
[alert-monitor]: https://opensearch.org/docs/latest/observing-your-data/alerting/index/#creating-an-alert-monitor
[trigger]: https://opensearch.org/docs/latest/observing-your-data/alerting/triggers/

View File

@@ -0,0 +1,5 @@
Monitor Storage size monitor just entered alert status. Please investigate the issue.
- Trigger: Storage size over 1TB
- Severity: 1
- Period start: 2025-02-25T00:58:39.607Z
- Period end: 2025-02-25T00:59:39.607Z

View File

@@ -0,0 +1,2 @@
topic: Resource Monitor
Alert of severity **3** triggered by **Insufficient memory**.

View File

@@ -0,0 +1 @@
Test message content body for config id Uz5bK5UBeE4fYdADfbg0

View File

@@ -0,0 +1,44 @@
from typing_extensions import override
from zerver.lib.test_classes import WebhookTestCase
class OpensearchHookTests(WebhookTestCase):
TOPIC_NAME = "OpenSearch alerts"
@override
def setUp(self) -> None:
super().setUp()
self.url = self.build_webhook_url()
@override
def get_body(self, fixture_name: str) -> str:
body = self.webhook_fixture_data(self.webhook_dir_name, fixture_name, file_type="txt")
return body
def test_test_notification_from_channel(self) -> None:
"""
Tests the message template that OpenSearch uses for
test-notifications when setting up the webhook.
"""
message = "Test message content body for config id Uz5bK5UBeE4fYdADfbg0"
self.check_webhook("test_notification", self.TOPIC_NAME, message, content_type="text/plain")
def test_test_notification_from_monitor_action(self) -> None:
"""Tests the default message template provided by OpenSearch."""
message = (
"Monitor Storage size monitor just entered alert status. Please investigate the issue.\n"
"- Trigger: Storage size over 1TB\n"
"- Severity: 1\n"
"- Period start: 2025-02-25T00:58:39.607Z\n"
"- Period end: 2025-02-25T00:59:39.607Z"
)
self.check_webhook("default_template", self.TOPIC_NAME, message, content_type="text/plain")
def test_example_template_notification(self) -> None:
"""
Tests the copyable example message template we provide in the integration documentation.
"""
message = "Alert of severity **3** triggered by **Insufficient memory**."
expected_topic = "Resource Monitor"
self.check_webhook("example_template", expected_topic, message, content_type="text/plain")

View File

@@ -0,0 +1,33 @@
from typing import Annotated
from django.http import HttpRequest, HttpResponse
from zerver.decorator import webhook_view
from zerver.lib.response import json_success
from zerver.lib.typed_endpoint import ApiParamConfig, typed_endpoint
from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import UserProfile
@webhook_view("OpenSearch")
@typed_endpoint
def api_opensearch_webhook(
request: HttpRequest,
user_profile: UserProfile,
*,
payload: Annotated[str, ApiParamConfig(argument_type_is_body=True)],
) -> HttpResponse:
"""
OpenSearch only sends text/plain payloads, even when the Content-Type is
set to other formats.
Supports passing in the topic as the first line of the payload, with the
topic prefixed by "topic:".
"""
end_of_line = payload.find("\n")
if payload.startswith("topic:") and end_of_line != -1:
topic = payload[6:end_of_line].strip()
message = payload[end_of_line + 1 :]
check_send_webhook_message(request, user_profile, topic, message)
else:
check_send_webhook_message(request, user_profile, "OpenSearch alerts", payload)
return json_success(request)