From f85df2f9910332e1bcb22fc48da3c08ccd9323ce Mon Sep 17 00:00:00 2001 From: Philip <14964470+Flipmonster@users.noreply.github.com> Date: Fri, 30 Oct 2026 14:52:28 +0100 Subject: [PATCH 001/103] chore(smoke-tests): bump ClickHouse 25.12 -> 26.8 (#3498) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `smoke-tests/otel-collector/docker-compose.yaml` is the only compose file still on `clickhouse-server:25.12-alpine`; the root, CI, dev and e2e compose files and the all-in-one Dockerfile are on 26.8 (an LTS line that has received the recent ClickHouse Server security fixes). This aligns it. Not run locally: the otel-collector smoke test should be run in CI. No changeset: test-only change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Drew Davis <6097246+pulpdrew@users.noreply.github.com> --- .github/workflows/main.yml | 7 ++- smoke-tests/otel-collector/README.md | 2 +- .../remove-prometheus-api.xml | 7 --- smoke-tests/otel-collector/compat-schema.bats | 14 ----- .../basic-insert/assert_query.sql | 1 - .../compat-schema/basic-insert/expected.snap | 2 - .../compat-schema/basic-insert/input.json | 51 ------------------- .../index-types/assert_query.sql | 7 --- .../compat-schema/index-types/expected.snap | 2 - .../otel-collector/docker-compose.yaml | 49 ------------------ smoke-tests/otel-collector/setup_suite.bash | 1 - .../test_helpers/assertions.bash | 4 -- 12 files changed, 4 insertions(+), 143 deletions(-) delete mode 100644 smoke-tests/otel-collector/ch-compat-config.d/remove-prometheus-api.xml delete mode 100644 smoke-tests/otel-collector/compat-schema.bats delete mode 100644 smoke-tests/otel-collector/data/compat-schema/basic-insert/assert_query.sql delete mode 100644 smoke-tests/otel-collector/data/compat-schema/basic-insert/expected.snap delete mode 100644 smoke-tests/otel-collector/data/compat-schema/basic-insert/input.json delete mode 100644 smoke-tests/otel-collector/data/compat-schema/index-types/assert_query.sql delete mode 100644 smoke-tests/otel-collector/data/compat-schema/index-types/expected.snap diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5b4c3c94a..bfb5e3064 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -194,10 +194,9 @@ jobs: id: changed-files uses: tj-actions/changed-files@v47.0.6 with: - # The ClickHouse config is mounted into both ch-server (via - # docker-compose.ci.yml) and ch-server-compat, which pins an older - # ClickHouse -- a config feature the old server rejects takes the - # whole suite down, so changes to it run these tests. + # The ClickHouse config is mounted into ch-server (via + # docker-compose.ci.yml) -- a config change the server rejects takes + # the whole suite down, so changes to it run these tests. files: | docker/otel-collector/** smoke-tests/otel-collector/** diff --git a/smoke-tests/otel-collector/README.md b/smoke-tests/otel-collector/README.md index f15974094..b9d2f13f7 100644 --- a/smoke-tests/otel-collector/README.md +++ b/smoke-tests/otel-collector/README.md @@ -45,7 +45,7 @@ The suite exercises all three OTLP signal types against the standalone collector config (`docker/otel-collector/config.standalone.yaml`): - **logs** - severity inference/normalization, JSON auto-parse, JSON-schema - exporter, compat-schema (old ClickHouse), custom-pipeline processor swap, and + exporter, custom-pipeline processor swap, and the `routing/logs` connector that splits rrweb (session replay) logs into `hyperdx_sessions` from ordinary logs in `otel_logs`. - **traces** - the `traces` pipeline into `otel_traces` (`traces.bats`). diff --git a/smoke-tests/otel-collector/ch-compat-config.d/remove-prometheus-api.xml b/smoke-tests/otel-collector/ch-compat-config.d/remove-prometheus-api.xml deleted file mode 100644 index 1213f1ee1..000000000 --- a/smoke-tests/otel-collector/ch-compat-config.d/remove-prometheus-api.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - diff --git a/smoke-tests/otel-collector/compat-schema.bats b/smoke-tests/otel-collector/compat-schema.bats deleted file mode 100644 index 57055aab5..000000000 --- a/smoke-tests/otel-collector/compat-schema.bats +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bats - -load 'test_helpers/utilities.bash' -load 'test_helpers/assertions.bash' - -@test "compat schema should use bloom_filter indexes instead of full text on ClickHouse < 26.2" { - assert_test_data_compat "data/compat-schema/index-types" -} - -@test "compat schema should insert and query log data correctly" { - emit_otel_data "http://localhost:24318" "data/compat-schema/basic-insert" - sleep 3 - assert_test_data_compat "data/compat-schema/basic-insert" -} diff --git a/smoke-tests/otel-collector/data/compat-schema/basic-insert/assert_query.sql b/smoke-tests/otel-collector/data/compat-schema/basic-insert/assert_query.sql deleted file mode 100644 index 051bd0f5e..000000000 --- a/smoke-tests/otel-collector/data/compat-schema/basic-insert/assert_query.sql +++ /dev/null @@ -1 +0,0 @@ -SELECT SeverityText, SeverityNumber, Body FROM otel_logs WHERE ResourceAttributes['suite-id'] = 'compat-schema' AND ResourceAttributes['test-id'] = 'basic-insert' ORDER BY (toStartOfFiveMinutes(Timestamp), Timestamp) FORMAT CSV diff --git a/smoke-tests/otel-collector/data/compat-schema/basic-insert/expected.snap b/smoke-tests/otel-collector/data/compat-schema/basic-insert/expected.snap deleted file mode 100644 index cf778479d..000000000 --- a/smoke-tests/otel-collector/data/compat-schema/basic-insert/expected.snap +++ /dev/null @@ -1,2 +0,0 @@ -"info",9,"compat schema test log entry" -"warn",13,"compat schema warning message" \ No newline at end of file diff --git a/smoke-tests/otel-collector/data/compat-schema/basic-insert/input.json b/smoke-tests/otel-collector/data/compat-schema/basic-insert/input.json deleted file mode 100644 index 1b14b19bf..000000000 --- a/smoke-tests/otel-collector/data/compat-schema/basic-insert/input.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "resourceLogs": [ - { - "resource": { - "attributes": [ - { - "key": "suite-id", - "value": { - "stringValue": "compat-schema" - } - }, - { - "key": "test-id", - "value": { - "stringValue": "basic-insert" - } - }, - { - "key": "service.name", - "value": { - "stringValue": "compat-test-service" - } - } - ] - }, - "scopeLogs": [ - { - "scope": {}, - "logRecords": [ - { - "timeUnixNano": "1901999580000000000", - "severityNumber": 9, - "severityText": "INFO", - "body": { - "stringValue": "compat schema test log entry" - } - }, - { - "timeUnixNano": "1901999580000000001", - "severityNumber": 13, - "severityText": "WARN", - "body": { - "stringValue": "compat schema warning message" - } - } - ] - } - ] - } - ] -} diff --git a/smoke-tests/otel-collector/data/compat-schema/index-types/assert_query.sql b/smoke-tests/otel-collector/data/compat-schema/index-types/assert_query.sql deleted file mode 100644 index 4e7b27b1d..000000000 --- a/smoke-tests/otel-collector/data/compat-schema/index-types/assert_query.sql +++ /dev/null @@ -1,7 +0,0 @@ -SELECT name, type -FROM system.data_skipping_indices -WHERE database = 'default' - AND table = 'otel_logs' - AND name IN ('idx_trace_id', 'idx_lower_body') -ORDER BY name -FORMAT CSV diff --git a/smoke-tests/otel-collector/data/compat-schema/index-types/expected.snap b/smoke-tests/otel-collector/data/compat-schema/index-types/expected.snap deleted file mode 100644 index 99cc5b5ed..000000000 --- a/smoke-tests/otel-collector/data/compat-schema/index-types/expected.snap +++ /dev/null @@ -1,2 +0,0 @@ -"idx_lower_body","tokenbf_v1" -"idx_trace_id","bloom_filter" \ No newline at end of file diff --git a/smoke-tests/otel-collector/docker-compose.yaml b/smoke-tests/otel-collector/docker-compose.yaml index 0c0201d9d..cf015c993 100644 --- a/smoke-tests/otel-collector/docker-compose.yaml +++ b/smoke-tests/otel-collector/docker-compose.yaml @@ -158,55 +158,6 @@ services: networks: - internal - # Older ClickHouse (< 26.2) to test the compatibility schema (bloom filters - # instead of full text indexes) - ch-server-compat: - image: clickhouse/clickhouse-server:25.12-alpine - environment: - CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: 1 - volumes: - - ../../docker/clickhouse/local/config.xml:/etc/clickhouse-server/config.xml - - ../../docker/clickhouse/local/users.xml:/etc/clickhouse-server/users.xml - - ./ch-compat-config.d/remove-prometheus-api.xml:/etc/clickhouse-server/config.d/remove-prometheus-api.xml:ro - ports: - - 29000:9000 - - 28123:8123 - networks: - - internal - healthcheck: - test: - wget -O /dev/null --no-verbose --tries=1 http://127.0.0.1:8123/ping || - exit 1 - interval: 5s - timeout: 3s - retries: 5 - start_period: 10s - otel-collector-compat: - build: - context: ../.. - dockerfile: docker/otel-collector/Dockerfile - target: dev - args: - OTEL_COLLECTOR_VERSION: ${OTEL_COLLECTOR_VERSION:-0.155.0} - OTEL_COLLECTOR_CORE_VERSION: ${OTEL_COLLECTOR_CORE_VERSION:-1.61.0} - environment: - - CLICKHOUSE_ENDPOINT=tcp://ch-server-compat:9000?dial_timeout=10s - - CLICKHOUSE_PROMETHEUS_METRICS_ENDPOINT=ch-server-compat:9363 - - CLICKHOUSE_USER=default - - CLICKHOUSE_PASSWORD= - - HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE=default - - HYPERDX_LOG_LEVEL=info - # See the note on the otel-collector service above for rationale. - - HYPERDX_OTEL_BATCH_TIMEOUT=100ms - # OPAMP_SERVER_URL is intentionally not set to run in standalone mode - ports: - - 24318:4318 # OTLP http receiver - networks: - - internal - depends_on: - ch-server-compat: - condition: service_healthy - # Static bearer-token auth (see docker/otel-collector/config.standalone.auth.yaml). # Verifies both accepted Authorization header forms end-to-end: the bare # token and the `Bearer `-prefixed value. diff --git a/smoke-tests/otel-collector/setup_suite.bash b/smoke-tests/otel-collector/setup_suite.bash index 82bc5cb6b..a76a28450 100644 --- a/smoke-tests/otel-collector/setup_suite.bash +++ b/smoke-tests/otel-collector/setup_suite.bash @@ -13,7 +13,6 @@ setup_suite() { docker compose up --build --detach wait_for_ready "otel-collector" wait_for_ready "otel-collector-json" - wait_for_ready "otel-collector-compat" wait_for_ready "otel-collector-custom" wait_for_ready "otel-collector-oidc" wait_for_ready "otel-collector-bearer-auth" diff --git a/smoke-tests/otel-collector/test_helpers/assertions.bash b/smoke-tests/otel-collector/test_helpers/assertions.bash index a4ed90c0c..3c86aaedb 100644 --- a/smoke-tests/otel-collector/test_helpers/assertions.bash +++ b/smoke-tests/otel-collector/test_helpers/assertions.bash @@ -2,10 +2,6 @@ assert_test_data() { _assert_test_data_on_port "9000" "$@" } -assert_test_data_compat() { - _assert_test_data_on_port "29000" "$@" -} - _assert_test_data_on_port() { local port=$1 local testdir=$2 From 2bfc6307dc0c9b84d0f3ff68e1beeaf0b4fcc877 Mon Sep 17 00:00:00 2001 From: Jordan Simonovski Date: Fri, 30 Oct 2026 15:14:46 +0100 Subject: [PATCH 002/103] chore: add CODEOWNERS for clickstack-app-devs review assignment (#3493) --- .github/CODEOWNERS | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..e4d464149 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# One reviewer is picked round robin by the team's code review settings. +* @hyperdxio/clickstack-app-devs From 2ed617aa4addc25821d826b7dc8c3f37a138e5be Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2026 20:24:28 +0000 Subject: [PATCH 003/103] Update VOUCHED list (#3503) Triggered by [comment](https://github.com/hyperdxio/hyperdx/issues/3467#issuecomment-6532490826) from @wrn14897. Vouch: @andrewdunndev --- .github/VOUCHED.td | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/VOUCHED.td b/.github/VOUCHED.td index 95533ec1a..967a7dd9d 100644 --- a/.github/VOUCHED.td +++ b/.github/VOUCHED.td @@ -29,6 +29,7 @@ adityapimpalkar alex-fedotyev alok87 +andrewdunndev archat-hash arj22 aryainguz From 7a9fe57d373dbb016013435c206be0d91d4e99e6 Mon Sep 17 00:00:00 2001 From: Warren Lee <5959690+wrn14897@users.noreply.github.com> Date: Sat, 31 Oct 2026 07:44:50 -0700 Subject: [PATCH 004/103] [HDX-5860] Disable multipath TCP in the OTel collector (#3505) ## Summary Mitigates [CVE-2026-98432](https://www.cve.org/CVERecord?id=CVE-2026-98432) for the OTel collector by disabling Multipath TCP in the Go runtime. The CVE is a Linux kernel use-after-free in IPv4 TCP connection setup. The published remote-root exploit targets servers with an MPTCP listener. Since Go 1.24, `net.Listen` asks for MPTCP by default, so on a host with MPTCP enabled, every collector listener (4317, 4318, 13133, 8888) is one. The Go Security Team's runtime mitigation is `GODEBUG=multipathtcp=0`. `docker/otel-collector/entrypoint.sh` now adds `multipathtcp=0` to `GODEBUG` before anything else runs. Every Go process the image starts goes through this script, so this one change covers: - the collector in standalone mode (`exec /otelcontribcol`) - the OpAMP supervisor and the collector it spawns (the supervisor's commander leaves `cmd.Env` nil when no `agent.env` is configured, so the child inherits the environment) - the `migrate` tool - the all-in-one images, which run the same script as `/otel-entrypoint.sh` The value is appended rather than set with `ENV` in the Dockerfile, so a deployment that passes its own `GODEBUG` (for example from a Helm chart) keeps its other settings and still gets the mitigation. An explicit `multipathtcp=` value from the operator is left alone. Not changed: `docker/hostmetrics` (stock contrib 0.90.0 built with Go 1.21, where MPTCP is off by default, and not referenced by any compose file or workflow). This only reduces exposure. The Go team calls per-program MPTCP disabling fragile, and the real fix is a patched host kernel. ### How to reproduce **Starting point:** repo root, Docker running. **On `main`:** 1. `docker build -f docker/otel-collector/Dockerfile --target dev -t otel-mptcp .` 2. Start ClickHouse and the collector on a shared network (standalone mode, `HYPERDX_OTEL_EXPORTER_CREATE_LEGACY_SCHEMA=true`, `CLICKHOUSE_ENDPOINT=tcp://:9000`). 3. `docker exec sh -c 'tr "\0" "\n" < /proc/1/environ | grep GODEBUG'` prints nothing. **On this branch:** 1. Same steps. The command prints `GODEBUG=multipathtcp=0`. 2. Passing `-e GODEBUG=http2client=0` gives `GODEBUG=http2client=0,multipathtcp=0`. 3. In supervisor mode (`OPAMP_SERVER_URL` set), PID 1 `opampsupervisor` carries `GODEBUG=multipathtcp=0`. I ran all three cases locally. I could not confirm the change at the socket level: Docker Desktop's VM kernel has no MPTCP support, so listeners are plain TCP either way. It's worth checking `ss -ltnM` on a real node after rollout. Added `smoke-tests/otel-collector/godebug.bats`, which asserts the collector's PID 1 environment. I have not run it locally. `make ci-lint` passes. `make ci-unit` passes apart from `timeZone.test.ts` (`getTimeZoneShortName`), which also fails on `main` on my machine (ICU/locale data) and is unrelated. ### References - Linear Issue: https://linear.app/clickhouse/issue/HDX-5860/disable-multipath-tcp-in-all-otel-collector-deployments - Related PRs: none - [Kernel fix](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e3f33b0a1d89d738e2b913dab519226eaf76e15b) --- .changeset/quiet-paths-close.md | 9 +++++++++ docker/otel-collector/entrypoint.sh | 8 ++++++++ smoke-tests/otel-collector/godebug.bats | 10 ++++++++++ 3 files changed, 27 insertions(+) create mode 100644 .changeset/quiet-paths-close.md create mode 100644 smoke-tests/otel-collector/godebug.bats diff --git a/.changeset/quiet-paths-close.md b/.changeset/quiet-paths-close.md new file mode 100644 index 000000000..d49db0261 --- /dev/null +++ b/.changeset/quiet-paths-close.md @@ -0,0 +1,9 @@ +--- +'@hyperdx/otel-collector': patch +--- + +Disable Multipath TCP in the collector image by setting `GODEBUG=multipathtcp=0` +at startup, mitigating CVE-2026-98432. Go 1.24+ opens MPTCP listeners by +default. Any other `GODEBUG` settings you pass are kept, and an explicit +`multipathtcp=` value is left as is. This also applies to the all-in-one image. +Patching the host kernel is still the actual fix. diff --git a/docker/otel-collector/entrypoint.sh b/docker/otel-collector/entrypoint.sh index 058b94ec4..bed5d965c 100644 --- a/docker/otel-collector/entrypoint.sh +++ b/docker/otel-collector/entrypoint.sh @@ -1,6 +1,14 @@ #!/bin/sh set -e +# Go 1.24+ opens Multipath TCP listeners by default; turn that off for the +# collector, supervisor and migrate to mitigate CVE-2026-98432. Appended so +# other GODEBUG settings survive; an explicit multipathtcp= value wins. +case "$GODEBUG" in + *multipathtcp=*) ;; + *) export GODEBUG="${GODEBUG:+$GODEBUG,}multipathtcp=0" ;; +esac + # DEPRECATED: The clickhouse.json feature gate has been removed upstream. # When OTEL_AGENT_FEATURE_GATE_ARG contains clickhouse.json, strip it and # map it to HYPERDX_OTEL_EXPORTER_CLICKHOUSE_JSON_ENABLE instead. Other feature gates diff --git a/smoke-tests/otel-collector/godebug.bats b/smoke-tests/otel-collector/godebug.bats new file mode 100644 index 000000000..4897fa4ae --- /dev/null +++ b/smoke-tests/otel-collector/godebug.bats @@ -0,0 +1,10 @@ +#!/usr/bin/env bats + +# The entrypoint must disable Go's default Multipath TCP listeners +# (CVE-2026-98432). In standalone mode the collector is exec'd as PID 1. + +@test "GODEBUG: the collector process runs with multipathtcp=0" { + run docker compose exec -T otel-collector sh -c 'tr "\0" "\n" < /proc/1/environ' + [ "$status" -eq 0 ] + echo "$output" | grep -qx 'GODEBUG=multipathtcp=0' +} From 821c2f93357b47d5ff932ea99d2adf93289815a5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 1 Nov 2026 21:08:48 +0000 Subject: [PATCH 005/103] Release HyperDX (#3510) This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @hyperdx/app@2.43.1 ### Patch Changes - @hyperdx/api@2.43.1 ## @hyperdx/otel-collector@2.43.1 ### Patch Changes - 7a9fe57d3: Disable Multipath TCP in the collector image by setting `GODEBUG=multipathtcp=0` at startup, mitigating CVE-2026-98432. Go 1.24+ opens MPTCP listeners by default. Any other `GODEBUG` settings you pass are kept, and an explicit `multipathtcp=` value is left as is. This also applies to the all-in-one image. Patching the host kernel is still the actual fix. ## @hyperdx/api@2.43.1 --- .changeset/quiet-paths-close.md | 9 -------- .env | 4 ++-- CHANGELOG.md | 32 ++++++++++++++++++++++++++++ packages/api/CHANGELOG.md | 2 ++ packages/api/package.json | 2 +- packages/app/CHANGELOG.md | 6 ++++++ packages/app/package.json | 2 +- packages/otel-collector/CHANGELOG.md | 10 +++++++++ packages/otel-collector/package.json | 2 +- 9 files changed, 55 insertions(+), 14 deletions(-) delete mode 100644 .changeset/quiet-paths-close.md diff --git a/.changeset/quiet-paths-close.md b/.changeset/quiet-paths-close.md deleted file mode 100644 index d49db0261..000000000 --- a/.changeset/quiet-paths-close.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -'@hyperdx/otel-collector': patch ---- - -Disable Multipath TCP in the collector image by setting `GODEBUG=multipathtcp=0` -at startup, mitigating CVE-2026-98432. Go 1.24+ opens MPTCP listeners by -default. Any other `GODEBUG` settings you pass are kept, and an explicit -`multipathtcp=` value is left as is. This also applies to the all-in-one image. -Patching the host kernel is still the actual fix. diff --git a/.env b/.env index 32c2952ff..835666b3b 100644 --- a/.env +++ b/.env @@ -8,8 +8,8 @@ NEXT_ALL_IN_ONE_IMAGE_NAME_DOCKERHUB=clickhouse/clickstack-all-in-one ALL_IN_ONE_IMAGE_NAME_DOCKERHUB=hyperdx/hyperdx-all-in-one NEXT_OTEL_COLLECTOR_IMAGE_NAME_DOCKERHUB=clickhouse/clickstack-otel-collector OTEL_COLLECTOR_IMAGE_NAME_DOCKERHUB=hyperdx/hyperdx-otel-collector -CODE_VERSION=2.43.0 -IMAGE_VERSION_SUB_TAG=.43.0 +CODE_VERSION=2.43.1 +IMAGE_VERSION_SUB_TAG=.43.1 IMAGE_VERSION=2 IMAGE_NIGHTLY_TAG=2-nightly IMAGE_LATEST_TAG=latest diff --git a/CHANGELOG.md b/CHANGELOG.md index d5c49e905..0d71cc72f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,38 @@ PR — keep the `hyperdx-release-notes` comment marker intact when editing so yo edits survive regeneration. Per-package detail lives in each `packages/*/CHANGELOG.md`. +## v2.43.1 — 2026-10-31 + + + +**Multipath TCP disabled in the collector image** + +The collector image now sets `GODEBUG=multipathtcp=0` at startup, so it no longer +opens Multipath TCP listeners — Go 1.24 and later turn them on by default — which +mitigates CVE-2026-98432 with no change needed on your side. The all-in-one image +picks up the same setting. Any other `GODEBUG` values you pass through are kept, +and an explicit `multipathtcp=` of your own is left exactly as you set it, so you +can still opt back in to MPTCP. Patching the host kernel remains the actual fix. + +### 📦 Build / Packaging + +- **Multipath TCP listeners no longer opened by the collector**: the collector + image, and the all-in-one image with it, starts with + `GODEBUG=multipathtcp=0`, mitigating CVE-2026-98432 on hosts where Go 1.24+ + would otherwise listen over MPTCP. Your own `GODEBUG` settings are preserved + and an explicit `multipathtcp=` value is honoured as written; patching the host + kernel is still the real fix. + + + +### 📦 Package changelogs + +- `@hyperdx/api` 2.43.0 → 2.43.1 — [changelog](https://github.com/hyperdxio/hyperdx/blob/main/packages/api/CHANGELOG.md#2431) +- `@hyperdx/app` 2.43.0 → 2.43.1 — [changelog](https://github.com/hyperdxio/hyperdx/blob/main/packages/app/CHANGELOG.md#2431) +- `@hyperdx/otel-collector` 2.43.0 → 2.43.1 — [changelog](https://github.com/hyperdxio/hyperdx/blob/main/packages/otel-collector/CHANGELOG.md#2431) + + + ## v2.43.0 — 2026-10-30 diff --git a/packages/api/CHANGELOG.md b/packages/api/CHANGELOG.md index 75d7585d8..141ea376a 100644 --- a/packages/api/CHANGELOG.md +++ b/packages/api/CHANGELOG.md @@ -1,5 +1,7 @@ # @hyperdx/api +## 2.43.1 + ## 2.43.0 ### Minor Changes diff --git a/packages/api/package.json b/packages/api/package.json index 9cd07d3ad..390af6805 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@hyperdx/api", - "version": "2.43.0", + "version": "2.43.1", "license": "MIT", "private": true, "engines": { diff --git a/packages/app/CHANGELOG.md b/packages/app/CHANGELOG.md index 077f92163..e5d45a4fb 100644 --- a/packages/app/CHANGELOG.md +++ b/packages/app/CHANGELOG.md @@ -1,5 +1,11 @@ # @hyperdx/app +## 2.43.1 + +### Patch Changes + +- @hyperdx/api@2.43.1 + ## 2.43.0 ### Minor Changes diff --git a/packages/app/package.json b/packages/app/package.json index 2309d87a1..13345cf94 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -1,6 +1,6 @@ { "name": "@hyperdx/app", - "version": "2.43.0", + "version": "2.43.1", "private": true, "license": "MIT", "engines": { diff --git a/packages/otel-collector/CHANGELOG.md b/packages/otel-collector/CHANGELOG.md index 7ffc80f73..41470c522 100644 --- a/packages/otel-collector/CHANGELOG.md +++ b/packages/otel-collector/CHANGELOG.md @@ -1,5 +1,15 @@ # @hyperdx/otel-collector +## 2.43.1 + +### Patch Changes + +- 7a9fe57d3: Disable Multipath TCP in the collector image by setting `GODEBUG=multipathtcp=0` + at startup, mitigating CVE-2026-98432. Go 1.24+ opens MPTCP listeners by + default. Any other `GODEBUG` settings you pass are kept, and an explicit + `multipathtcp=` value is left as is. This also applies to the all-in-one image. + Patching the host kernel is still the actual fix. + ## 2.43.0 ## 2.42.0 diff --git a/packages/otel-collector/package.json b/packages/otel-collector/package.json index 39e20800f..8636220ca 100644 --- a/packages/otel-collector/package.json +++ b/packages/otel-collector/package.json @@ -1,7 +1,7 @@ { "name": "@hyperdx/otel-collector", "description": "HyperDX OpenTelemetry Collector configuration and Docker image", - "version": "2.43.0", + "version": "2.43.1", "license": "MIT", "private": true } From 442d6dfd9f93961eb28a0efd735c0eb1f15c7557 Mon Sep 17 00:00:00 2001 From: Bilal Atique <74999164+BilalAtique@users.noreply.github.com> Date: Mon, 2 Nov 2026 02:20:30 +0500 Subject: [PATCH 006/103] fix(common-utils): expire cached table columns after 5 minutes (#3481) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary `getMetadata()` shares one module-level `MetadataCache`, and `getOrFetch` kept every entry for the life of the process. After an `ALTER TABLE` adds a column, the API keeps rendering queries with the column list from before the change until it restarts. As #3475 shows, a new MATERIALIZED column is not used for a filter on the Map key it covers, and grouping by it fails with `Unknown expression identifier`. - `MetadataCache.getOrFetch` and `set` take an optional `ttlMs`. `get` drops an entry whose TTL has passed, so the next `getOrFetch` runs the query again. Entries stored without a TTL behave as before. - `getColumns` stores its `DESCRIBE` result with a 5 minute TTL (`COLUMNS_CACHE_TTL_MS`). `getColumn`, `getMaterializedColumnsLookupTable` and the computed metric column lookup from #3191 all read `getColumns`, so they see a new column within 5 minutes. The cost is one `DESCRIBE` per table every 5 minutes per process. Concurrent callers still share one pending query. The browser uses the same cache, so a page reload is no longer needed there either. Things to be aware of: - If the refresh fails (ClickHouse is down), the caller now gets the error instead of the old column list. The query that needs the columns would fail in that case anyway. - Other cached schema data still has no TTL: skip indices, the text index lookups, `system.tables` metadata and TimeSeries table columns. I kept this PR to the column list from the issue. I can extend the TTL to those in a follow-up if you want. - 5 minutes is a guess at "a few minutes" from the issue. Happy to change it. ### Tests In `packages/common-utils/src/__tests__/metadata.test.ts`, with `Date.now` mocked: - `MetadataCache`: a value stored with a TTL is returned from the cache until the TTL passes and fetched again after it. A value stored without a TTL is still cached a year later. - `getMaterializedColumnsLookupTable`: the first `DESCRIBE` has no MATERIALIZED column, and a second one adds `__otel_materialized_k8s.namespace.name`. The lookup stays empty just before the TTL, and has `ResourceAttributes['k8s.namespace.name']` → `__otel_materialized_k8s.namespace.name` once the TTL has passed. `DESCRIBE` runs twice. With this change all 156 tests in the file pass. With `metadata.ts` from `main`, the two TTL tests fail (the cache returns `first` instead of `second`, and the lookup stays empty). With the cache TTL but without the TTL on `getColumns`, the lookup test fails. ESLint, Prettier, `tsc` on the two changed files and `knip` for `common-utils` pass. I did not run the issue's steps against a full `yarn dev` stack. ### How to reproduce **Starting point:** `yarn dev`, with the steps from #3475 (the MCP `clickstack_timeseries` tool on the metrics source). **On `main`:** 1. Call `clickstack_timeseries` on a gauge metric with `where: ResourceAttributes.k8s.namespace.name:foo`. 2. Add the `__otel_materialized_k8s.namespace.name` and `__otel_materialized_k8s.cluster.name` MATERIALIZED columns to `otel_metrics_gauge` (SQL in the issue). 3. Repeat step 1. `system.query_log` shows the filter still reads `ResourceAttributes['k8s.namespace.name']`, and grouping by `` `__otel_materialized_k8s.cluster.name` `` fails with `Unknown expression identifier`. This keeps happening until the API restarts. **On this branch:** 1. Do the same steps, then wait 5 minutes after step 2. 2. Repeat step 1. The filter uses `__otel_materialized_k8s.namespace.name`, and the group-by works without a restart. ### How to test on Vercel preview N/A — non-UI change. ### References - Closes #3475 - Related: #3191 (computed metric columns), #3231 --- .changeset/metadata-columns-cache-ttl.md | 12 +++ .../src/__tests__/metadata.test.ts | 100 ++++++++++++++++++ packages/common-utils/src/core/metadata.ts | 33 ++++-- 3 files changed, 138 insertions(+), 7 deletions(-) create mode 100644 .changeset/metadata-columns-cache-ttl.md diff --git a/.changeset/metadata-columns-cache-ttl.md b/.changeset/metadata-columns-cache-ttl.md new file mode 100644 index 000000000..4a8b98db6 --- /dev/null +++ b/.changeset/metadata-columns-cache-ttl.md @@ -0,0 +1,12 @@ +--- +'@hyperdx/common-utils': patch +'@hyperdx/app': patch +'@hyperdx/api': patch +--- + +fix: refresh cached table columns after 5 minutes + +The shared metadata cache kept each table's `DESCRIBE` result for the life of +the process, so the API did not see columns added with `ALTER TABLE`, such as +new MATERIALIZED columns, until it restarted. Cached columns now expire after 5 +minutes. Other cached metadata is unchanged. diff --git a/packages/common-utils/src/__tests__/metadata.test.ts b/packages/common-utils/src/__tests__/metadata.test.ts index 1489354d2..dab2349b0 100644 --- a/packages/common-utils/src/__tests__/metadata.test.ts +++ b/packages/common-utils/src/__tests__/metadata.test.ts @@ -1,6 +1,7 @@ import { ColumnMeta } from '@/clickhouse'; import { ClickhouseClient } from '@/clickhouse/node'; import { + COLUMNS_CACHE_TTL_MS, GET_ALL_KEY_VALUES_CHUNK_SIZE, Metadata, MetadataCache, @@ -157,6 +158,48 @@ describe('MetadataCache', () => { // And no value should be stored in the cache expect(metadataCache.get(key)).toBeUndefined(); }); + + it('refetches a value stored with a TTL once the TTL has passed', async () => { + const now = jest.spyOn(Date, 'now').mockReturnValue(1_000); + const queryFn = jest + .fn() + .mockResolvedValueOnce('first') + .mockResolvedValueOnce('second'); + + try { + await expect( + metadataCache.getOrFetch('key', queryFn, { ttlMs: 100 }), + ).resolves.toBe('first'); + + now.mockReturnValue(1_099); + await expect( + metadataCache.getOrFetch('key', queryFn, { ttlMs: 100 }), + ).resolves.toBe('first'); + + now.mockReturnValue(1_100); + await expect( + metadataCache.getOrFetch('key', queryFn, { ttlMs: 100 }), + ).resolves.toBe('second'); + expect(queryFn).toHaveBeenCalledTimes(2); + } finally { + now.mockRestore(); + } + }); + + it('keeps a value stored without a TTL', async () => { + const now = jest.spyOn(Date, 'now').mockReturnValue(1_000); + const queryFn = jest.fn().mockResolvedValue('value'); + + try { + await metadataCache.getOrFetch('key', queryFn); + now.mockReturnValue(1_000 + 365 * 24 * 60 * 60 * 1000); + await metadataCache.getOrFetch('key', queryFn); + + expect(queryFn).toHaveBeenCalledTimes(1); + } finally { + now.mockRestore(); + } + }); }); }); @@ -168,6 +211,63 @@ describe('Metadata', () => { jest.clearAllMocks(); }); + describe('getMaterializedColumnsLookupTable', () => { + it('sees a MATERIALIZED column added after the first read once the cached columns expire', async () => { + const now = jest.spyOn(Date, 'now').mockReturnValue(0); + const client = { query: jest.fn() } as unknown as ClickhouseClient; + const md = new Metadata(client, new MetadataCache()); + const describeResult = (columns: Partial[]) => ({ + json: jest.fn().mockResolvedValue({ data: columns }), + }); + const resourceAttributes = { + name: 'ResourceAttributes', + type: 'Map(LowCardinality(String), String)', + default_type: '', + default_expression: '', + }; + const materialized = { + name: '__otel_materialized_k8s.namespace.name', + type: 'LowCardinality(String)', + default_type: 'MATERIALIZED', + default_expression: "ResourceAttributes['k8s.namespace.name']", + }; + (client.query as jest.Mock) + .mockResolvedValueOnce(describeResult([resourceAttributes])) + .mockResolvedValueOnce( + describeResult([resourceAttributes, materialized]), + ); + const table = { + databaseName: 'otel', + tableName: 'otel_metrics_gauge', + connectionId: 'conn-1', + }; + + try { + expect(await md.getMaterializedColumnsLookupTable(table)).toEqual( + new Map(), + ); + + now.mockReturnValue(COLUMNS_CACHE_TTL_MS - 1); + expect(await md.getMaterializedColumnsLookupTable(table)).toEqual( + new Map(), + ); + + now.mockReturnValue(COLUMNS_CACHE_TTL_MS); + expect(await md.getMaterializedColumnsLookupTable(table)).toEqual( + new Map([ + [ + "ResourceAttributes['k8s.namespace.name']", + '__otel_materialized_k8s.namespace.name', + ], + ]), + ); + expect(client.query).toHaveBeenCalledTimes(2); + } finally { + now.mockRestore(); + } + }); + }); + describe('getTableMetadata', () => { beforeEach(() => { mockCache.getOrFetch.mockImplementation((key, queryFn) => queryFn()); diff --git a/packages/common-utils/src/core/metadata.ts b/packages/common-utils/src/core/metadata.ts index c6a5f6431..747129695 100644 --- a/packages/common-utils/src/core/metadata.ts +++ b/packages/common-utils/src/core/metadata.ts @@ -251,17 +251,27 @@ const renderJsonStringSubcolumn = ( }; export class MetadataCache { - private cache = new Map(); + private cache = new Map(); private pendingQueries = new Map>(); // this should be getOrUpdate... or just query to follow react query get(key: string): T | undefined { - return this.cache.get(key); + const entry = this.cache.get(key); + if (entry?.expiresAt != null && Date.now() >= entry.expiresAt) { + this.cache.delete(key); + return undefined; + } + return entry?.value; } - async getOrFetch(key: string, query: () => Promise): Promise { + /** Entries stored without `ttlMs` are kept for the life of the cache. */ + async getOrFetch( + key: string, + query: () => Promise, + { ttlMs }: { ttlMs?: number } = {}, + ): Promise { // Check if value exists in cache - const cachedValue: T | undefined = this.cache.get(key); + const cachedValue: T | undefined = this.get(key); if (cachedValue != null) { return cachedValue; } @@ -279,7 +289,7 @@ export class MetadataCache { try { const result = await queryPromise; - this.cache.set(key, result); + this.set(key, result, ttlMs); return result; } finally { // Clean up the pending query map @@ -287,8 +297,11 @@ export class MetadataCache { } } - set(key: string, value: T) { - return this.cache.set(key, value); + set(key: string, value: T, ttlMs?: number) { + this.cache.set(key, { + value, + expiresAt: ttlMs == null ? undefined : Date.now() + ttlMs, + }); } // TODO: This needs to be async, and use tanstack query on frontend for cache @@ -353,6 +366,11 @@ export type SkipIndexMetadata = { const FIELD_METADATA_LOOKBACK_MS = 24 * 60 * 60 * 1000; +// The API keeps one cache for the life of the process, so without a TTL a +// column added by ALTER TABLE (such as a MATERIALIZED one) is only seen after a +// restart. #3475 +export const COLUMNS_CACHE_TTL_MS = 5 * 60 * 1000; + // Hour-aligned so a range-keyed cache rotates hourly instead of every call. export function defaultFieldMetadataDateRange(): [Date, Date] { const now = new Date(); @@ -619,6 +637,7 @@ export class Metadata { .then(d => d.data); return columns; }, + { ttlMs: COLUMNS_CACHE_TTL_MS }, ); } From cd0e9edfa8f17300dbf1609b5eb95e63d6c27776 Mon Sep 17 00:00:00 2001 From: "Andrew G. Dunn" Date: Mon, 2 Nov 2026 04:56:43 -0500 Subject: [PATCH 007/103] feat: add optional titleEmoji webhook setting to drop the emoji prefix (#3467) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Closes #3466 I know #3466 hasn't been through feedback yet and CONTRIBUTING asks for `Accepting PR` first. I had already written and tested this before filing the issue, so I'm opening it now in case it helps the discussion. Happy to rework it or close it if you want a different direction. Alert notification titles always start with 🚨 or ✅. That reads well in Slack, but a destination that already says firing or resolved, such as a webhook feeding an email relay, gets the emoji in its subject line with no way to remove it. Following review, this is now a setting on the webhook rather than the alert: an optional boolean `titleEmoji`, where `false` drops the prefix for notifications sent to that webhook. Unset or `true` leaves titles unchanged. An alert that notifies several webhooks through `@webhook-` mentions gets the prefix per destination. - The title is built once without the emoji, and the prefix is added per channel when the dispatch jobs are queued, unless that webhook opts out. - The field follows `description` through the webhook model, the internal and v2 webhook APIs, `openapi.json` and the common-utils types. - The webhook form has a "Show state emoji in notification titles" checkbox, checked by default. - The MCP `saveWebhook` tool takes the field, since its update clears omitted settings. ### How to reproduce **Starting point:** `yarn dev`, with two webhook destinations and a saved-search alert that notifies both (one as its channel, one through an `@webhook-` mention in the message). **On `main`:** 1. Trigger the alert. Both notification titles start with 🚨, and no setting removes it. **On this branch:** 1. In Team Settings, edit the first webhook and untick "Show state emoji in notification titles". 2. Trigger the alert. The first webhook's title has no prefix, the second keeps 🚨, and the resolved notifications follow the same split. 3. `GET /api/v2/webhooks` returns `"titleEmoji": false` for the first webhook. `make dev-int FILE=checkAlerts` runs the two-webhook case. ### How to test on Vercel preview Open Team Settings, edit or create a webhook, and check that the new checkbox saves and reloads. ### References - Linear Issue: - Related PRs: #1339 --- .changeset/alert-title-emoji-toggle.md | 7 + packages/api/openapi.json | 24 ++- packages/api/src/controllers/webhook.ts | 27 +++- .../api/src/mcp/tools/alerts/saveWebhook.ts | 12 +- packages/api/src/models/webhook.ts | 6 + .../api/__tests__/webhooks.int.test.ts | 57 +++++++ packages/api/src/routers/api/webhooks.ts | 28 +++- .../__tests__/webhooks.int.test.ts | 51 ++++++ .../src/routers/external-api/v2/webhooks.ts | 46 +++++- .../renderAlertTemplate.int.test.ts.snap | 68 ++++---- .../__tests__/checkAlerts.int.test.ts | 153 ++++++++++++------ .../__tests__/renderAlertTemplate.int.test.ts | 28 +--- packages/api/src/tasks/checkAlerts/index.ts | 5 +- .../api/src/tasks/checkAlerts/template.ts | 32 ++-- packages/api/src/utils/zod.ts | 2 + packages/app/src/api.ts | 6 + .../components/TeamSettings/WebhookForm.tsx | 13 +- .../__tests__/WebhookForm.test.tsx | 41 +++++ packages/common-utils/src/types.ts | 1 + 19 files changed, 470 insertions(+), 137 deletions(-) create mode 100644 .changeset/alert-title-emoji-toggle.md diff --git a/.changeset/alert-title-emoji-toggle.md b/.changeset/alert-title-emoji-toggle.md new file mode 100644 index 000000000..86158ae7c --- /dev/null +++ b/.changeset/alert-title-emoji-toggle.md @@ -0,0 +1,7 @@ +--- +'@hyperdx/api': minor +'@hyperdx/app': minor +'@hyperdx/common-utils': minor +--- + +feat: add optional `titleEmoji` webhook option; `false` removes the emoji prefix from notification titles sent through that webhook diff --git a/packages/api/openapi.json b/packages/api/openapi.json index f6ea5912f..83203b68a 100644 --- a/packages/api/openapi.json +++ b/packages/api/openapi.json @@ -5827,6 +5827,11 @@ "description": "Webhook description, shown in the UI", "example": "Sends critical alerts to the #incidents channel" }, + "titleEmoji": { + "type": "boolean", + "description": "Set to false to omit the state emoji prefix from notification titles sent through this webhook. Unset or true keeps the default prefix.", + "example": false + }, "updatedAt": { "type": "string", "format": "date-time", @@ -5879,6 +5884,11 @@ "description": "Webhook description, shown in the UI", "example": "Routes alerts to incident.io for on-call escalation" }, + "titleEmoji": { + "type": "boolean", + "description": "Set to false to omit the state emoji prefix from notification titles sent through this webhook. Unset or true keeps the default prefix.", + "example": false + }, "updatedAt": { "type": "string", "format": "date-time", @@ -5931,6 +5941,11 @@ "description": "Webhook description, shown in the UI", "example": "Forwards alert payloads to an external monitoring service" }, + "titleEmoji": { + "type": "boolean", + "description": "Set to false to omit the state emoji prefix from notification titles sent through this webhook. Unset or true keeps the default prefix.", + "example": false + }, "body": { "type": "string", "description": "Optional request body template", @@ -6023,7 +6038,7 @@ "service", "url" ], - "description": "Webhook create/update body. `body`, `headers`, and `queryParams`\nonly take effect for services that issue a templated HTTP request\n(`generic`, `incidentio`). The `slack` service posts a fixed payload\nto its incoming-webhook URL and ignores them, so supplying any of\nthese fields on a `slack` webhook is rejected. `headers` and\n`queryParams` are write-only — they are accepted here but never\nreturned by any read endpoint, so secrets such as auth tokens do\nnot leak. On\nupdate (PUT), omitted readable fields (`description`, `body`) are\ncleared, while omitted `headers`/`queryParams` are preserved —\nsend an explicit `{}` to clear them. Exception: if the destination\n(`url` or `service`) changes, omitted `headers`/`queryParams` are\ncleared rather than preserved, so stored secrets are never forwarded\nto a new destination; re-supply them for the new destination.\n", + "description": "Webhook create/update body. `body`, `headers`, and `queryParams`\nonly take effect for services that issue a templated HTTP request\n(`generic`, `incidentio`). The `slack` service posts a fixed payload\nto its incoming-webhook URL and ignores them, so supplying any of\nthese fields on a `slack` webhook is rejected. `headers` and\n`queryParams` are write-only — they are accepted here but never\nreturned by any read endpoint, so secrets such as auth tokens do\nnot leak. On\nupdate (PUT), omitted readable fields (`description`, `titleEmoji`, `body`) are\ncleared, while omitted `headers`/`queryParams` are preserved —\nsend an explicit `{}` to clear them. Exception: if the destination\n(`url` or `service`) changes, omitted `headers`/`queryParams` are\ncleared rather than preserved, so stored secrets are never forwarded\nto a new destination; re-supply them for the new destination.\n", "properties": { "name": { "type": "string", @@ -6054,6 +6069,11 @@ "description": "Webhook description, shown in the UI.", "example": "Sends critical alerts to the #incidents channel" }, + "titleEmoji": { + "type": "boolean", + "description": "Set to false to omit the state emoji prefix from notification titles sent through this webhook. Unset or true keeps the default prefix.", + "example": false + }, "body": { "type": "string", "maxLength": 16384, @@ -9178,7 +9198,7 @@ "/api/v2/webhooks/{id}": { "put": { "summary": "Update Webhook", - "description": "Replaces an existing webhook. Readable optional fields\n(`description`, `body`) are a full replace: omitting them clears\nthem. The write-only fields `headers` and `queryParams` are never\nreturned on read, so omitting them preserves the stored values;\nsend an explicit empty object (`{}`) to clear them. Exception: if the\ndestination (`url` or `service`) changes, omitted `headers`/\n`queryParams` are cleared rather than preserved so stored secrets are\nnever forwarded to a new destination.\n", + "description": "Replaces an existing webhook. Readable optional fields\n(`description`, `titleEmoji`, `body`) are a full replace: omitting them clears\nthem. The write-only fields `headers` and `queryParams` are never\nreturned on read, so omitting them preserves the stored values;\nsend an explicit empty object (`{}`) to clear them. Exception: if the\ndestination (`url` or `service`) changes, omitted `headers`/\n`queryParams` are cleared rather than preserved so stored secrets are\nnever forwarded to a new destination.\n", "operationId": "updateWebhook", "tags": [ "Webhooks" diff --git a/packages/api/src/controllers/webhook.ts b/packages/api/src/controllers/webhook.ts index a37f41fcb..5f5a66b30 100644 --- a/packages/api/src/controllers/webhook.ts +++ b/packages/api/src/controllers/webhook.ts @@ -11,6 +11,7 @@ export interface WebhookInput { service: WebhookService; url: string; description?: string; + titleEmoji?: boolean; queryParams?: Record; headers?: Record; body?: string; @@ -22,7 +23,16 @@ export interface WebhookInput { */ export async function createWebhook( team: ObjectId | string, - { name, service, url, description, queryParams, headers, body }: WebhookInput, + { + name, + service, + url, + description, + titleEmoji, + queryParams, + headers, + body, + }: WebhookInput, ) { validateWebhookConfig({ service, url, body }); @@ -32,6 +42,7 @@ export async function createWebhook( service, url, description, + titleEmoji, queryParams, headers, body, @@ -53,7 +64,16 @@ export type UpdateWebhookResult = export async function updateWebhook( team: ObjectId | string, webhookId: string, - { name, service, url, description, queryParams, headers, body }: WebhookInput, + { + name, + service, + url, + description, + titleEmoji, + queryParams, + headers, + body, + }: WebhookInput, ): Promise { const existing = await Webhook.findOne({ _id: webhookId, team }); if (existing == null) { @@ -71,6 +91,9 @@ export async function updateWebhook( if (description === undefined) unsetFields.description = 1; else setFields.description = description; + if (titleEmoji === undefined) unsetFields.titleEmoji = 1; + else setFields.titleEmoji = titleEmoji; + if (body === undefined) unsetFields.body = 1; else setFields.body = body; diff --git a/packages/api/src/mcp/tools/alerts/saveWebhook.ts b/packages/api/src/mcp/tools/alerts/saveWebhook.ts index 3d0e0f801..5542f47f6 100644 --- a/packages/api/src/mcp/tools/alerts/saveWebhook.ts +++ b/packages/api/src/mcp/tools/alerts/saveWebhook.ts @@ -59,6 +59,14 @@ const mcpSaveWebhookSchema = z.object({ 'Description shown in the UI. On update this is a full replace: ' + 'omitting it clears the stored description.', ), + titleEmoji: z + .boolean() + .optional() + .describe( + 'Set to false to omit the state emoji prefix from notification titles ' + + 'sent through this webhook. On update this is a full replace: ' + + 'omitting it restores the default prefix.', + ), headers: z .record(z.string(), z.string()) .optional() @@ -105,8 +113,8 @@ export function registerSaveWebhook({ 'clickstack_save_alert. For the slack service the url host must end ' + 'in slack.com and headers/queryParams/body are not supported. On ' + 'update, every alert using this webhook sends its next notifications ' + - 'with the new settings, including a changed url. description and body ' + - 'are a full replace (omitting them clears them), while write-only ' + + 'with the new settings, including a changed url. description, titleEmoji and ' + + 'body are a full replace (omitting them clears them), while write-only ' + 'headers/queryParams are preserved when omitted (send {} to clear); ' + 'changing url or service clears omitted headers/queryParams. ' + 'url, headers, and queryParams are never returned.', diff --git a/packages/api/src/models/webhook.ts b/packages/api/src/models/webhook.ts index c31bf1358..58a5a87f5 100644 --- a/packages/api/src/models/webhook.ts +++ b/packages/api/src/models/webhook.ts @@ -23,6 +23,8 @@ export interface IWebhook { updatedAt: Date; url?: string; description?: string; + // false drops the state emoji prefix from notification titles + titleEmoji?: boolean; // reminder to serialize/convert the Mongoose model instance to a plain javascript object when using // to strip the additional properties that are related to the Mongoose internal representation -> webhook.headers.toJSON() queryParams?: MongooseMap; @@ -50,6 +52,10 @@ const WebhookSchema = new Schema( type: String, required: false, }, + titleEmoji: { + type: Boolean, + required: false, + }, queryParams: { type: Map, of: String, diff --git a/packages/api/src/routers/api/__tests__/webhooks.int.test.ts b/packages/api/src/routers/api/__tests__/webhooks.int.test.ts index 1bd86f6bf..8fa8414e9 100644 --- a/packages/api/src/routers/api/__tests__/webhooks.int.test.ts +++ b/packages/api/src/routers/api/__tests__/webhooks.int.test.ts @@ -121,6 +121,44 @@ describe('webhooks router', () => { expect(webhooks[0].url).toBe(MOCK_WEBHOOK.url); }); + it('POST / - stores titleEmoji false and GET / returns it', async () => { + const { agent } = await getLoggedInAgent(server); + + const response = await agent + .post('/webhooks') + .send({ ...MOCK_WEBHOOK, titleEmoji: false }) + .expect(200); + + expect(response.body.data.titleEmoji).toBe(false); + + const webhooks = await Webhook.find({}); + expect(webhooks).toHaveLength(1); + expect(webhooks[0].titleEmoji).toBe(false); + + const listResponse = await agent + .get('/webhooks') + .query({ service: WebhookService.Slack }) + .expect(200); + + expect(listResponse.body.data).toHaveLength(1); + expect(listResponse.body.data[0].titleEmoji).toBe(false); + }); + + it('POST / - leaves titleEmoji unset when not provided', async () => { + const { agent } = await getLoggedInAgent(server); + + const response = await agent + .post('/webhooks') + .send(MOCK_WEBHOOK) + .expect(200); + + expect(response.body.data).not.toHaveProperty('titleEmoji'); + + const webhooks = await Webhook.find({}); + expect(webhooks).toHaveLength(1); + expect(webhooks[0].titleEmoji).toBeUndefined(); + }); + it('POST / - returns 400 when webhook with same URL already exists', async () => { const { agent, team } = await getLoggedInAgent(server); @@ -787,6 +825,25 @@ describe('webhooks router', () => { }); }); + it('sets titleEmoji on an existing webhook', async () => { + const { agent, team } = await getLoggedInAgent(server); + + const webhook = await Webhook.create({ + ...MOCK_WEBHOOK, + team: team._id, + }); + + const response = await agent + .put(`/webhooks/${webhook._id}`) + .send({ ...MOCK_WEBHOOK, titleEmoji: false }) + .expect(200); + + expect(response.body.data.titleEmoji).toBe(false); + + const updatedWebhook = await Webhook.findById(webhook._id); + expect(updatedWebhook?.titleEmoji).toBe(false); + }); + it('returns 404 when webhook does not exist', async () => { const { agent } = await getLoggedInAgent(server); diff --git a/packages/api/src/routers/api/webhooks.ts b/packages/api/src/routers/api/webhooks.ts index 516cb283a..16cec1b95 100644 --- a/packages/api/src/routers/api/webhooks.ts +++ b/packages/api/src/routers/api/webhooks.ts @@ -167,6 +167,7 @@ router.post( body: z.object({ body: z.string().optional(), description: z.string().optional(), + titleEmoji: z.boolean().optional(), headers: z .record(webhookHeaderNameSchema, webhookHeaderValueSchema) .optional(), @@ -188,8 +189,16 @@ router.post( if (teamId == null) { return res.sendStatus(403); } - const { name, service, url, description, queryParams, headers, body } = - req.body; + const { + name, + service, + url, + description, + titleEmoji, + queryParams, + headers, + body, + } = req.body; // The unique index is on (team, service, name), so the pre-flight check // must query the same fields — otherwise a name+service collision slips // past this guard and surfaces as an uncaught duplicate-key 500 below. @@ -203,6 +212,7 @@ router.post( service, url, description, + titleEmoji, queryParams, headers, body, @@ -233,6 +243,7 @@ router.put( body: z.object({ body: z.string().optional(), description: z.string().optional(), + titleEmoji: z.boolean().optional(), headers: z .record(webhookHeaderNameSchema, webhookHeaderValueSchema) .optional(), @@ -254,8 +265,16 @@ router.put( if (teamId == null) { return res.sendStatus(403); } - const { name, service, url, description, queryParams, headers, body } = - req.body; + const { + name, + service, + url, + description, + titleEmoji, + queryParams, + headers, + body, + } = req.body; const { id } = req.params; const existingWebhook = await Webhook.findOne({ @@ -323,6 +342,7 @@ router.put( service, url: resolvedUrl, description, + titleEmoji, body, }; const $unset: Record = {}; diff --git a/packages/api/src/routers/external-api/__tests__/webhooks.int.test.ts b/packages/api/src/routers/external-api/__tests__/webhooks.int.test.ts index 60ec86ef9..b5370a7b5 100644 --- a/packages/api/src/routers/external-api/__tests__/webhooks.int.test.ts +++ b/packages/api/src/routers/external-api/__tests__/webhooks.int.test.ts @@ -331,6 +331,27 @@ describe('External API v2 Webhooks', () => { .expect(401); }); + it('should round-trip titleEmoji through create and list', async () => { + const response = await authRequest('post', WEBHOOKS_BASE_URL) + .send({ ...MOCK_SLACK_WEBHOOK, titleEmoji: false }) + .expect(200); + expect(response.body.data.titleEmoji).toBe(false); + + const stored = await Webhook.findById(response.body.data.id).lean(); + expect(stored?.titleEmoji).toBe(false); + + const list = await authRequest('get', WEBHOOKS_BASE_URL).expect(200); + expect(list.body.data[0].titleEmoji).toBe(false); + }); + + it('should leave titleEmoji unset when not provided', async () => { + const response = await authRequest('post', WEBHOOKS_BASE_URL) + .send(MOCK_SLACK_WEBHOOK) + .expect(200); + + expect(response.body.data).not.toHaveProperty('titleEmoji'); + }); + it('should create a Slack webhook and never return sensitive fields', async () => { const response = await authRequest('post', WEBHOOKS_BASE_URL) .send(MOCK_GENERIC_WEBHOOK) @@ -635,6 +656,36 @@ describe('External API v2 Webhooks', () => { expect(stored?.description).toBeUndefined(); }); + it('should set titleEmoji on update and clear it when omitted', async () => { + const created = await Webhook.create({ + ...MOCK_SLACK_WEBHOOK, + team: team._id, + }); + const base = { + name: MOCK_SLACK_WEBHOOK.name, + service: WebhookService.Slack, + url: MOCK_SLACK_WEBHOOK.url, + }; + + const set = await authRequest( + 'put', + `${WEBHOOKS_BASE_URL}/${created._id}`, + ) + .send({ ...base, titleEmoji: false }) + .expect(200); + expect(set.body.data.titleEmoji).toBe(false); + expect((await Webhook.findById(created._id).lean())?.titleEmoji).toBe( + false, + ); + + await authRequest('put', `${WEBHOOKS_BASE_URL}/${created._id}`) + .send(base) + .expect(200); + expect( + (await Webhook.findById(created._id).lean())?.titleEmoji, + ).toBeUndefined(); + }); + it('should preserve omitted queryParams when the destination is unchanged', async () => { const created = await Webhook.create({ ...MOCK_GENERIC_WEBHOOK, diff --git a/packages/api/src/routers/external-api/v2/webhooks.ts b/packages/api/src/routers/external-api/v2/webhooks.ts index 479334e13..61ce85274 100644 --- a/packages/api/src/routers/external-api/v2/webhooks.ts +++ b/packages/api/src/routers/external-api/v2/webhooks.ts @@ -135,6 +135,10 @@ function formatExternalWebhook( * type: string * description: Webhook description, shown in the UI * example: "Sends critical alerts to the #incidents channel" + * titleEmoji: + * type: boolean + * description: Set to false to omit the state emoji prefix from notification titles sent through this webhook. Unset or true keeps the default prefix. + * example: false * updatedAt: * type: string * format: date-time @@ -175,6 +179,10 @@ function formatExternalWebhook( * type: string * description: Webhook description, shown in the UI * example: Routes alerts to incident.io for on-call escalation + * titleEmoji: + * type: boolean + * description: Set to false to omit the state emoji prefix from notification titles sent through this webhook. Unset or true keeps the default prefix. + * example: false * updatedAt: * type: string * format: date-time @@ -215,6 +223,10 @@ function formatExternalWebhook( * type: string * description: Webhook description, shown in the UI * example: Forwards alert payloads to an external monitoring service + * titleEmoji: + * type: boolean + * description: Set to false to omit the state emoji prefix from notification titles sent through this webhook. Unset or true keeps the default prefix. + * example: false * body: * type: string * description: Optional request body template @@ -379,7 +391,7 @@ router.get( * `queryParams` are write-only — they are accepted here but never * returned by any read endpoint, so secrets such as auth tokens do * not leak. On - * update (PUT), omitted readable fields (`description`, `body`) are + * update (PUT), omitted readable fields (`description`, `titleEmoji`, `body`) are * cleared, while omitted `headers`/`queryParams` are preserved — * send an explicit `{}` to clear them. Exception: if the destination * (`url` or `service`) changes, omitted `headers`/`queryParams` are @@ -407,6 +419,10 @@ router.get( * maxLength: 2048 * description: Webhook description, shown in the UI. * example: "Sends critical alerts to the #incidents channel" + * titleEmoji: + * type: boolean + * description: Set to false to omit the state emoji prefix from notification titles sent through this webhook. Unset or true keeps the default prefix. + * example: false * body: * type: string * maxLength: 16384 @@ -611,14 +627,23 @@ router.post( return res.status(403).json({ message: 'Forbidden' }); } - const { name, service, url, description, queryParams, headers, body } = - req.body; + const { + name, + service, + url, + description, + titleEmoji, + queryParams, + headers, + body, + } = req.body; const webhook = await createWebhook(teamId, { name, service, url, description, + titleEmoji, queryParams, headers, body, @@ -647,7 +672,7 @@ router.post( * summary: Update Webhook * description: | * Replaces an existing webhook. Readable optional fields - * (`description`, `body`) are a full replace: omitting them clears + * (`description`, `titleEmoji`, `body`) are a full replace: omitting them clears * them. The write-only fields `headers` and `queryParams` are never * returned on read, so omitting them preserves the stored values; * send an explicit empty object (`{}`) to clear them. Exception: if the @@ -721,14 +746,23 @@ router.put( return res.status(403).json({ message: 'Forbidden' }); } - const { name, service, url, description, queryParams, headers, body } = - req.body; + const { + name, + service, + url, + description, + titleEmoji, + queryParams, + headers, + body, + } = req.body; const result = await updateWebhook(teamId, req.params.id, { name, service, url, description, + titleEmoji, queryParams, headers, body, diff --git a/packages/api/src/tasks/checkAlerts/__tests__/__snapshots__/renderAlertTemplate.int.test.ts.snap b/packages/api/src/tasks/checkAlerts/__tests__/__snapshots__/renderAlertTemplate.int.test.ts.snap index a0204eb5c..3aa000f64 100644 --- a/packages/api/src/tasks/checkAlerts/__tests__/__snapshots__/renderAlertTemplate.int.test.ts.snap +++ b/packages/api/src/tasks/checkAlerts/__tests__/__snapshots__/renderAlertTemplate.int.test.ts.snap @@ -1,72 +1,72 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing -exports[`buildAlertMessageTemplateTitle saved search alerts ALERT state above threshold=5 alertValue=10 1`] = `"🚨 Alert for "My Search" - 10 lines found"`; +exports[`buildAlertMessageTemplateTitle saved search alerts ALERT state above threshold=5 alertValue=10 1`] = `"Alert for "My Search" - 10 lines found"`; -exports[`buildAlertMessageTemplateTitle saved search alerts ALERT state above_exclusive threshold=5 alertValue=10 1`] = `"🚨 Alert for "My Search" - 10 lines found"`; +exports[`buildAlertMessageTemplateTitle saved search alerts ALERT state above_exclusive threshold=5 alertValue=10 1`] = `"Alert for "My Search" - 10 lines found"`; -exports[`buildAlertMessageTemplateTitle saved search alerts ALERT state below threshold=5 alertValue=2 1`] = `"🚨 Alert for "My Search" - 2 lines found"`; +exports[`buildAlertMessageTemplateTitle saved search alerts ALERT state below threshold=5 alertValue=2 1`] = `"Alert for "My Search" - 2 lines found"`; -exports[`buildAlertMessageTemplateTitle saved search alerts ALERT state below_or_equal threshold=5 alertValue=3 1`] = `"🚨 Alert for "My Search" - 3 lines found"`; +exports[`buildAlertMessageTemplateTitle saved search alerts ALERT state below_or_equal threshold=5 alertValue=3 1`] = `"Alert for "My Search" - 3 lines found"`; -exports[`buildAlertMessageTemplateTitle saved search alerts ALERT state between threshold=5 alertValue=6 1`] = `"🚨 Alert for "My Search" - 6 lines found"`; +exports[`buildAlertMessageTemplateTitle saved search alerts ALERT state between threshold=5 alertValue=6 1`] = `"Alert for "My Search" - 6 lines found"`; -exports[`buildAlertMessageTemplateTitle saved search alerts ALERT state equal threshold=5 alertValue=5 1`] = `"🚨 Alert for "My Search" - 5 lines found"`; +exports[`buildAlertMessageTemplateTitle saved search alerts ALERT state equal threshold=5 alertValue=5 1`] = `"Alert for "My Search" - 5 lines found"`; -exports[`buildAlertMessageTemplateTitle saved search alerts ALERT state not_between threshold=5 alertValue=12 1`] = `"🚨 Alert for "My Search" - 12 lines found"`; +exports[`buildAlertMessageTemplateTitle saved search alerts ALERT state not_between threshold=5 alertValue=12 1`] = `"Alert for "My Search" - 12 lines found"`; -exports[`buildAlertMessageTemplateTitle saved search alerts ALERT state not_equal threshold=5 alertValue=10 1`] = `"🚨 Alert for "My Search" - 10 lines found"`; +exports[`buildAlertMessageTemplateTitle saved search alerts ALERT state not_equal threshold=5 alertValue=10 1`] = `"Alert for "My Search" - 10 lines found"`; -exports[`buildAlertMessageTemplateTitle saved search alerts OK state (resolved) above threshold=5 okValue=3 1`] = `"✅ Alert for "My Search" - 3 lines found"`; +exports[`buildAlertMessageTemplateTitle saved search alerts OK state (resolved) above threshold=5 okValue=3 1`] = `"Alert for "My Search" - 3 lines found"`; -exports[`buildAlertMessageTemplateTitle saved search alerts OK state (resolved) above_exclusive threshold=5 okValue=3 1`] = `"✅ Alert for "My Search" - 3 lines found"`; +exports[`buildAlertMessageTemplateTitle saved search alerts OK state (resolved) above_exclusive threshold=5 okValue=3 1`] = `"Alert for "My Search" - 3 lines found"`; -exports[`buildAlertMessageTemplateTitle saved search alerts OK state (resolved) below threshold=5 okValue=10 1`] = `"✅ Alert for "My Search" - 10 lines found"`; +exports[`buildAlertMessageTemplateTitle saved search alerts OK state (resolved) below threshold=5 okValue=10 1`] = `"Alert for "My Search" - 10 lines found"`; -exports[`buildAlertMessageTemplateTitle saved search alerts OK state (resolved) below_or_equal threshold=5 okValue=10 1`] = `"✅ Alert for "My Search" - 10 lines found"`; +exports[`buildAlertMessageTemplateTitle saved search alerts OK state (resolved) below_or_equal threshold=5 okValue=10 1`] = `"Alert for "My Search" - 10 lines found"`; -exports[`buildAlertMessageTemplateTitle saved search alerts OK state (resolved) between threshold=5 okValue=10 1`] = `"✅ Alert for "My Search" - 10 lines found"`; +exports[`buildAlertMessageTemplateTitle saved search alerts OK state (resolved) between threshold=5 okValue=10 1`] = `"Alert for "My Search" - 10 lines found"`; -exports[`buildAlertMessageTemplateTitle saved search alerts OK state (resolved) equal threshold=5 okValue=10 1`] = `"✅ Alert for "My Search" - 10 lines found"`; +exports[`buildAlertMessageTemplateTitle saved search alerts OK state (resolved) equal threshold=5 okValue=10 1`] = `"Alert for "My Search" - 10 lines found"`; -exports[`buildAlertMessageTemplateTitle saved search alerts OK state (resolved) not_between threshold=5 okValue=6 1`] = `"✅ Alert for "My Search" - 6 lines found"`; +exports[`buildAlertMessageTemplateTitle saved search alerts OK state (resolved) not_between threshold=5 okValue=6 1`] = `"Alert for "My Search" - 6 lines found"`; -exports[`buildAlertMessageTemplateTitle saved search alerts OK state (resolved) not_equal threshold=5 okValue=5 1`] = `"✅ Alert for "My Search" - 5 lines found"`; +exports[`buildAlertMessageTemplateTitle saved search alerts OK state (resolved) not_equal threshold=5 okValue=5 1`] = `"Alert for "My Search" - 5 lines found"`; -exports[`buildAlertMessageTemplateTitle tile alerts ALERT state above threshold=5 alertValue=10 1`] = `"🚨 Alert for "My Dashboard - Test Chart" - 10 meets or exceeds 5"`; +exports[`buildAlertMessageTemplateTitle tile alerts ALERT state above threshold=5 alertValue=10 1`] = `"Alert for "My Dashboard - Test Chart" - 10 meets or exceeds 5"`; -exports[`buildAlertMessageTemplateTitle tile alerts ALERT state above_exclusive threshold=5 alertValue=10 1`] = `"🚨 Alert for "My Dashboard - Test Chart" - 10 exceeds 5"`; +exports[`buildAlertMessageTemplateTitle tile alerts ALERT state above_exclusive threshold=5 alertValue=10 1`] = `"Alert for "My Dashboard - Test Chart" - 10 exceeds 5"`; -exports[`buildAlertMessageTemplateTitle tile alerts ALERT state below threshold=5 alertValue=2 1`] = `"🚨 Alert for "My Dashboard - Test Chart" - 2 falls below 5"`; +exports[`buildAlertMessageTemplateTitle tile alerts ALERT state below threshold=5 alertValue=2 1`] = `"Alert for "My Dashboard - Test Chart" - 2 falls below 5"`; -exports[`buildAlertMessageTemplateTitle tile alerts ALERT state below_or_equal threshold=5 alertValue=3 1`] = `"🚨 Alert for "My Dashboard - Test Chart" - 3 falls to or below 5"`; +exports[`buildAlertMessageTemplateTitle tile alerts ALERT state below_or_equal threshold=5 alertValue=3 1`] = `"Alert for "My Dashboard - Test Chart" - 3 falls to or below 5"`; -exports[`buildAlertMessageTemplateTitle tile alerts ALERT state between threshold=5 alertValue=6 1`] = `"🚨 Alert for "My Dashboard - Test Chart" - 6 falls between 5 and 7"`; +exports[`buildAlertMessageTemplateTitle tile alerts ALERT state between threshold=5 alertValue=6 1`] = `"Alert for "My Dashboard - Test Chart" - 6 falls between 5 and 7"`; -exports[`buildAlertMessageTemplateTitle tile alerts ALERT state decimal threshold 1`] = `"🚨 Alert for "My Dashboard - Test Chart" - 10.1 meets or exceeds 1.5"`; +exports[`buildAlertMessageTemplateTitle tile alerts ALERT state decimal threshold 1`] = `"Alert for "My Dashboard - Test Chart" - 10.1 meets or exceeds 1.5"`; -exports[`buildAlertMessageTemplateTitle tile alerts ALERT state equal threshold=5 alertValue=5 1`] = `"🚨 Alert for "My Dashboard - Test Chart" - 5 equals 5"`; +exports[`buildAlertMessageTemplateTitle tile alerts ALERT state equal threshold=5 alertValue=5 1`] = `"Alert for "My Dashboard - Test Chart" - 5 equals 5"`; -exports[`buildAlertMessageTemplateTitle tile alerts ALERT state integer threshold rounds value 1`] = `"🚨 Alert for "My Dashboard - Test Chart" - 11 meets or exceeds 5"`; +exports[`buildAlertMessageTemplateTitle tile alerts ALERT state integer threshold rounds value 1`] = `"Alert for "My Dashboard - Test Chart" - 11 meets or exceeds 5"`; -exports[`buildAlertMessageTemplateTitle tile alerts ALERT state not_between threshold=5 alertValue=12 1`] = `"🚨 Alert for "My Dashboard - Test Chart" - 12 falls outside 5 and 7"`; +exports[`buildAlertMessageTemplateTitle tile alerts ALERT state not_between threshold=5 alertValue=12 1`] = `"Alert for "My Dashboard - Test Chart" - 12 falls outside 5 and 7"`; -exports[`buildAlertMessageTemplateTitle tile alerts ALERT state not_equal threshold=5 alertValue=10 1`] = `"🚨 Alert for "My Dashboard - Test Chart" - 10 does not equal 5"`; +exports[`buildAlertMessageTemplateTitle tile alerts ALERT state not_equal threshold=5 alertValue=10 1`] = `"Alert for "My Dashboard - Test Chart" - 10 does not equal 5"`; -exports[`buildAlertMessageTemplateTitle tile alerts OK state (resolved) above threshold=5 okValue=3 1`] = `"✅ Alert for "My Dashboard - Test Chart" - 3 falls below 5"`; +exports[`buildAlertMessageTemplateTitle tile alerts OK state (resolved) above threshold=5 okValue=3 1`] = `"Alert for "My Dashboard - Test Chart" - 3 falls below 5"`; -exports[`buildAlertMessageTemplateTitle tile alerts OK state (resolved) above_exclusive threshold=5 okValue=3 1`] = `"✅ Alert for "My Dashboard - Test Chart" - 3 falls to or below 5"`; +exports[`buildAlertMessageTemplateTitle tile alerts OK state (resolved) above_exclusive threshold=5 okValue=3 1`] = `"Alert for "My Dashboard - Test Chart" - 3 falls to or below 5"`; -exports[`buildAlertMessageTemplateTitle tile alerts OK state (resolved) below threshold=5 okValue=10 1`] = `"✅ Alert for "My Dashboard - Test Chart" - 10 meets or exceeds 5"`; +exports[`buildAlertMessageTemplateTitle tile alerts OK state (resolved) below threshold=5 okValue=10 1`] = `"Alert for "My Dashboard - Test Chart" - 10 meets or exceeds 5"`; -exports[`buildAlertMessageTemplateTitle tile alerts OK state (resolved) below_or_equal threshold=5 okValue=10 1`] = `"✅ Alert for "My Dashboard - Test Chart" - 10 exceeds 5"`; +exports[`buildAlertMessageTemplateTitle tile alerts OK state (resolved) below_or_equal threshold=5 okValue=10 1`] = `"Alert for "My Dashboard - Test Chart" - 10 exceeds 5"`; -exports[`buildAlertMessageTemplateTitle tile alerts OK state (resolved) between threshold=5 okValue=10 1`] = `"✅ Alert for "My Dashboard - Test Chart" - 10 falls outside 5 and 7"`; +exports[`buildAlertMessageTemplateTitle tile alerts OK state (resolved) between threshold=5 okValue=10 1`] = `"Alert for "My Dashboard - Test Chart" - 10 falls outside 5 and 7"`; -exports[`buildAlertMessageTemplateTitle tile alerts OK state (resolved) equal threshold=5 okValue=10 1`] = `"✅ Alert for "My Dashboard - Test Chart" - 10 does not equal 5"`; +exports[`buildAlertMessageTemplateTitle tile alerts OK state (resolved) equal threshold=5 okValue=10 1`] = `"Alert for "My Dashboard - Test Chart" - 10 does not equal 5"`; -exports[`buildAlertMessageTemplateTitle tile alerts OK state (resolved) not_between threshold=5 okValue=6 1`] = `"✅ Alert for "My Dashboard - Test Chart" - 6 falls between 5 and 7"`; +exports[`buildAlertMessageTemplateTitle tile alerts OK state (resolved) not_between threshold=5 okValue=6 1`] = `"Alert for "My Dashboard - Test Chart" - 6 falls between 5 and 7"`; -exports[`buildAlertMessageTemplateTitle tile alerts OK state (resolved) not_equal threshold=5 okValue=5 1`] = `"✅ Alert for "My Dashboard - Test Chart" - 5 equals 5"`; +exports[`buildAlertMessageTemplateTitle tile alerts OK state (resolved) not_equal threshold=5 okValue=5 1`] = `"Alert for "My Dashboard - Test Chart" - 5 equals 5"`; exports[`renderAlertTemplate saved search alerts ALERT state above threshold=5 alertValue=10 1`] = ` " diff --git a/packages/api/src/tasks/checkAlerts/__tests__/checkAlerts.int.test.ts b/packages/api/src/tasks/checkAlerts/__tests__/checkAlerts.int.test.ts index 8ef7412f5..dda67b51b 100644 --- a/packages/api/src/tasks/checkAlerts/__tests__/checkAlerts.int.test.ts +++ b/packages/api/src/tasks/checkAlerts/__tests__/checkAlerts.int.test.ts @@ -1488,13 +1488,13 @@ describe('checkAlerts', () => { buildAlertMessageTemplateTitle({ view: defaultSearchView, }), - ).toMatchInlineSnapshot(`"🚨 Alert for "My Search" - 10 lines found"`); + ).toMatchInlineSnapshot(`"Alert for "My Search" - 10 lines found"`); expect( buildAlertMessageTemplateTitle({ view: defaultChartView, }), ).toMatchInlineSnapshot( - `"🚨 Alert for "My Dashboard - Test Chart" - 5 meets or exceeds 1"`, + `"Alert for "My Dashboard - Test Chart" - 5 meets or exceeds 1"`, ); // Inline alerts default to the chart config's name expect( @@ -1502,41 +1502,7 @@ describe('checkAlerts', () => { view: defaultInlineAlertView, }), ).toMatchInlineSnapshot( - `"🚨 Alert for "Chart Alert Query" - 5 meets or exceeds 1"`, - ); - }); - - it('buildAlertMessageTemplateTitle with state parameter', () => { - // Test ALERT state (should have 🚨 emoji) - expect( - buildAlertMessageTemplateTitle({ - view: defaultSearchView, - state: AlertState.ALERT, - }), - ).toMatchInlineSnapshot(`"🚨 Alert for "My Search" - 10 lines found"`); - expect( - buildAlertMessageTemplateTitle({ - view: defaultChartView, - state: AlertState.ALERT, - }), - ).toMatchInlineSnapshot( - `"🚨 Alert for "My Dashboard - Test Chart" - 5 meets or exceeds 1"`, - ); - - // Test OK state (should have ✅ emoji) - expect( - buildAlertMessageTemplateTitle({ - view: defaultSearchView, - state: AlertState.OK, - }), - ).toMatchInlineSnapshot(`"✅ Alert for "My Search" - 10 lines found"`); - expect( - buildAlertMessageTemplateTitle({ - view: defaultChartView, - state: AlertState.OK, - }), - ).toMatchInlineSnapshot( - `"✅ Alert for "My Dashboard - Test Chart" - 5 meets or exceeds 1"`, + `"Alert for "Chart Alert Query" - 5 meets or exceeds 1"`, ); }); @@ -1556,7 +1522,7 @@ describe('checkAlerts', () => { view: decimalChartView, }), ).toMatchInlineSnapshot( - `"🚨 Alert for "My Dashboard - Test Chart" - 1111.1 meets or exceeds 1.5"`, + `"Alert for "My Dashboard - Test Chart" - 1111.1 meets or exceeds 1.5"`, ); // Test with multiple decimal places @@ -1574,7 +1540,7 @@ describe('checkAlerts', () => { view: multiDecimalChartView, }), ).toMatchInlineSnapshot( - `"🚨 Alert for "My Dashboard - Test Chart" - 1.1235 meets or exceeds 0.1234"`, + `"Alert for "My Dashboard - Test Chart" - 1.1235 meets or exceeds 0.1234"`, ); // Test with integer value and decimal threshold @@ -1592,7 +1558,7 @@ describe('checkAlerts', () => { view: integerValueView, }), ).toMatchInlineSnapshot( - `"🚨 Alert for "My Dashboard - Test Chart" - 10.00 meets or exceeds 0.12"`, + `"Alert for "My Dashboard - Test Chart" - 10.00 meets or exceeds 0.12"`, ); }); @@ -1728,7 +1694,7 @@ describe('checkAlerts', () => { }, }, }, - title: '🚨 Alert for "My Search" - 10 lines found', + title: 'Alert for "My Search" - 10 lines found', teamId: team._id.toString(), teamWebhooksById: new Map([ [webhook._id.toString(), webhook], @@ -1789,7 +1755,7 @@ describe('checkAlerts', () => { webhookName: 'My_Webhook', }, }, - title: '🚨 Alert for "My Search" - 10 lines found', + title: 'Alert for "My Search" - 10 lines found', teamId: team._id.toString(), teamWebhooksById: new Map([ [webhook._id.toString(), webhook], @@ -1875,7 +1841,7 @@ describe('checkAlerts', () => { }, }, }, - title: '🚨 Alert for "My Search" - 10 lines found', + title: 'Alert for "My Search" - 10 lines found', teamId: team._id.toString(), teamWebhooksById, }); @@ -1900,7 +1866,7 @@ describe('checkAlerts', () => { host: 'web2', }, }, - title: '🚨 Alert for "My Search" - 10 lines found', + title: 'Alert for "My Search" - 10 lines found', teamId: team._id.toString(), teamWebhooksById, }); @@ -1990,7 +1956,7 @@ describe('checkAlerts', () => { }, }, }, - title: '✅ Alert for "My Search" - 10 lines found', + title: 'Alert for "My Search" - 10 lines found', teamId: team._id.toString(), teamWebhooksById: new Map([ [webhook._id.toString(), webhook], @@ -2477,6 +2443,103 @@ describe('checkAlerts', () => { ); }); + it('SAVED_SEARCH alert - titleEmoji is applied per webhook on fired and resolved titles', async () => { + const { + team, + webhook, + connection, + source, + savedSearch, + clickhouseClient, + } = await setupSavedSearchAlertTest(); + webhook.titleEmoji = false; + await webhook.save(); + const emojiWebhook = await new Webhook({ + team: team._id, + service: 'slack', + url: 'https://hooks.slack.com/services/456', + name: 'Emoji_Webhook', + }).save(); + const teamWebhooksById = new Map([ + [webhook._id.toString(), webhook], + [emojiWebhook._id.toString(), emojiWebhook], + ]); + + const details = await createAlertDetails( + team, + source, + { + source: AlertSource.SAVED_SEARCH, + channel: { + type: 'webhook', + webhookId: webhook._id.toString(), + }, + interval: '5m', + thresholdType: AlertThresholdType.ABOVE, + threshold: 1, + savedSearchId: savedSearch.id, + message: '@webhook-Emoji_Webhook', + }, + { + taskType: AlertTaskType.SAVED_SEARCH, + savedSearch, + }, + ); + + await bulkInsertLogs([ + { + ServiceName: 'api', + Timestamp: new Date('2023-11-16T22:05:00.000Z'), + SeverityText: 'error', + Body: 'Oh no! Something went wrong!', + }, + { + ServiceName: 'api', + Timestamp: new Date('2023-11-16T22:05:00.000Z'), + SeverityText: 'error', + Body: 'Oh no! Something went wrong!', + }, + ]); + + await processAlertAtTime( + new Date('2023-11-16T22:12:00.000Z'), + details, + clickhouseClient, + connection.id, + alertProvider, + teamWebhooksById, + ); + expect((await Alert.findById(details.alert.id))!.state).toBe('ALERT'); + + await processAlertAtTime( + new Date('2023-11-16T22:20:00.000Z'), + details, + clickhouseClient, + connection.id, + alertProvider, + teamWebhooksById, + ); + expect((await Alert.findById(details.alert.id))!.state).toBe('OK'); + + const textsFor = (url: string) => + jest + .mocked(slack.postMessageToWebhook) + .mock.calls.filter(([calledUrl]) => calledUrl === url) + .map(([, payload]) => payload.text); + + const [plainFired, plainResolved] = textsFor( + 'https://hooks.slack.com/services/123', + ); + expect(plainFired).toBe('Alert for "My Search" - 2 lines found'); + expect(plainResolved).toMatch(/^Alert for "My Search"/); + + const [emojiFired, emojiResolved] = textsFor( + 'https://hooks.slack.com/services/456', + ); + expect(emojiFired).toBe('🚨 Alert for "My Search" - 2 lines found'); + expect(emojiResolved).toMatch(/^✅ Alert for "My Search"/); + }); + // The scheduled alert task and the app search page both go through // `buildSearchChartConfig`, which prepends the Log source's // `tableFilterExpression` (when set) as a SQL filter. This regression diff --git a/packages/api/src/tasks/checkAlerts/__tests__/renderAlertTemplate.int.test.ts b/packages/api/src/tasks/checkAlerts/__tests__/renderAlertTemplate.int.test.ts index c3e09091b..c9d6f5ecc 100644 --- a/packages/api/src/tasks/checkAlerts/__tests__/renderAlertTemplate.int.test.ts +++ b/packages/api/src/tasks/checkAlerts/__tests__/renderAlertTemplate.int.test.ts @@ -773,7 +773,6 @@ describe('buildAlertMessageTemplateTitle', () => { threshold, value: alertValue, }), - state: AlertState.ALERT, }); expect(result).toMatchSnapshot(); }, @@ -786,7 +785,6 @@ describe('buildAlertMessageTemplateTitle', () => { ({ thresholdType, threshold, okValue }) => { const result = buildAlertMessageTemplateTitle({ view: makeSearchView({ thresholdType, threshold, value: okValue }), - state: AlertState.OK, }); expect(result).toMatchSnapshot(); }, @@ -806,7 +804,6 @@ describe('buildAlertMessageTemplateTitle', () => { thresholdMax, value: alertValue, }), - state: AlertState.ALERT, }); expect(result).toMatchSnapshot(); }, @@ -819,7 +816,6 @@ describe('buildAlertMessageTemplateTitle', () => { threshold: 1.5, value: 10.123, }), - state: AlertState.ALERT, }); expect(result).toMatchSnapshot(); }); @@ -831,7 +827,6 @@ describe('buildAlertMessageTemplateTitle', () => { threshold: 5, value: 10.789, }), - state: AlertState.ALERT, }); expect(result).toMatchSnapshot(); }); @@ -848,7 +843,6 @@ describe('buildAlertMessageTemplateTitle', () => { thresholdMax, value: okValue, }), - state: AlertState.OK, }); expect(result).toMatchSnapshot(); }, @@ -864,10 +858,9 @@ describe('buildAlertMessageTemplateTitle', () => { const result = buildAlertMessageTemplateTitle({ view: { ...view, alert: { ...view.alert, name: 'Custom title' } }, - state: AlertState.ALERT, }); - expect(result).toBe('🚨 Custom title'); + expect(result).toBe('Custom title'); }); it('renders Handlebars against the view', () => { @@ -878,10 +871,9 @@ describe('buildAlertMessageTemplateTitle', () => { ...view, alert: { ...view.alert, name: '{{value}} over {{alert.threshold}}' }, }, - state: AlertState.ALERT, }); - expect(result).toBe('🚨 10 over 5'); + expect(result).toBe('10 over 5'); }); it('uses a malformed template verbatim instead of failing', () => { @@ -889,10 +881,9 @@ describe('buildAlertMessageTemplateTitle', () => { const result = buildAlertMessageTemplateTitle({ view: { ...view, alert: { ...view.alert, name: 'Errors {{spike' } }, - state: AlertState.ALERT, }); - expect(result).toBe('🚨 Errors {{spike'); + expect(result).toBe('Errors {{spike'); }); }); @@ -905,10 +896,9 @@ describe('buildAlertMessageTemplateTitle', () => { ...view, alert: { ...view.alert, displayName: 'Checkout errors' }, }, - state: AlertState.ALERT, }); - expect(result).toBe('🚨 Alert for "Checkout errors" - 10 lines found'); + expect(result).toBe('Alert for "Checkout errors" - 10 lines found'); }); it('names a tile alert', () => { @@ -919,7 +909,6 @@ describe('buildAlertMessageTemplateTitle', () => { ...view, alert: { ...view.alert, displayName: 'Error rate' }, }, - state: AlertState.ALERT, }); expect(result).toContain('Alert for "Error rate" -'); @@ -931,7 +920,6 @@ describe('buildAlertMessageTemplateTitle', () => { const result = buildAlertMessageTemplateTitle({ view: { ...view, alert: { ...view.alert, displayName: 'p99 latency' } }, - state: AlertState.ALERT, }); expect(result).toContain('Alert for "p99 latency"'); @@ -948,12 +936,9 @@ describe('buildAlertMessageTemplateTitle', () => { where: 'level:error', chartName: 'Inline Chart', }), - state: AlertState.ALERT, }); - expect(result).toBe( - '🚨 Alert for "Inline Chart" - 10 meets or exceeds 5', - ); + expect(result).toBe('Alert for "Inline Chart" - 10 meets or exceeds 5'); }); it('falls back when an inline chart config has no name', () => { @@ -967,10 +952,9 @@ describe('buildAlertMessageTemplateTitle', () => { chartConfig: { ...view.alert.chartConfig!, name: undefined }, }, }, - state: AlertState.ALERT, }); - expect(result).toBe('🚨 Alert for "Alert" - 10 meets or exceeds 5'); + expect(result).toBe('Alert for "Alert" - 10 meets or exceeds 5'); }); }); }); diff --git a/packages/api/src/tasks/checkAlerts/index.ts b/packages/api/src/tasks/checkAlerts/index.ts index 17a6b66c3..4ae9d167f 100644 --- a/packages/api/src/tasks/checkAlerts/index.ts +++ b/packages/api/src/tasks/checkAlerts/index.ts @@ -553,10 +553,7 @@ const fireChannelEvent = async ({ clickhouseClient, metadata, state, - title: buildAlertMessageTemplateTitle({ - view: templateView, - state, - }), + title: buildAlertMessageTemplateTitle({ view: templateView }), template: alert.message, view: templateView, teamId, diff --git a/packages/api/src/tasks/checkAlerts/template.ts b/packages/api/src/tasks/checkAlerts/template.ts index 11335c5a1..94e96d1dd 100644 --- a/packages/api/src/tasks/checkAlerts/template.ts +++ b/packages/api/src/tasks/checkAlerts/template.ts @@ -265,6 +265,9 @@ export const isAlertResolved = (state?: AlertState): boolean => { return state === AlertState.OK; }; +const stateTitleEmoji = (state?: AlertState): string => + isAlertResolved(state) ? '✅ ' : '🚨 '; + /** * Formats the value to match the decimal precision of the threshold. * This ensures consistent display of numbers in alert messages. @@ -342,10 +345,8 @@ export const buildAlertMessageTemplateHdxLink = ( export const buildAlertMessageTemplateTitle = ({ view, - state, }: { view: AlertMessageTemplateDefaultView; - state?: AlertState; }) => { const { alert, dashboard, savedSearch, value } = view; const handlebars = createHandlebarsWithHelpers(); @@ -367,17 +368,14 @@ export const buildAlertMessageTemplateTitle = ({ dashboard, }); - // Add emoji prefix based on alert state - const emoji = isAlertResolved(state) ? '✅ ' : '🚨 '; - if (alert.source === AlertSource.SAVED_SEARCH) { if (savedSearch == null) { throw new Error(`Source is ${alert.source} but savedSearch is null`); } // TODO: using template engine to render the title - const baseTitle = - renderedTemplate ?? `Alert for "${displayName}" - ${value} lines found`; - return `${emoji}${baseTitle}`; + return ( + renderedTemplate ?? `Alert for "${displayName}" - ${value} lines found` + ); } else if (alert.source === AlertSource.TILE) { if (dashboard == null) { throw new Error(`Source is ${alert.source} but dashboard is null`); @@ -389,27 +387,27 @@ export const buildAlertMessageTemplateTitle = ({ ); } const formattedValue = formatValueToMatchThreshold(value, alert.threshold); - const baseTitle = + return ( renderedTemplate ?? `Alert for "${displayName}" - ${formattedValue} ${ doesExceedThreshold(alert, value) ? describeThresholdViolation(alert.thresholdType) : describeThresholdResolution(alert.thresholdType) - } ${describeThreshold(alert)}`; - return `${emoji}${baseTitle}`; + } ${describeThreshold(alert)}` + ); } else if (alert.source === AlertSource.INLINE) { const formattedValue = formatValueToMatchThreshold(value, alert.threshold); // Inline alerts have no saved search/tile to name them; the alert's `name` // doubles as the title template, so the default falls back to the resolved // display name (itself derived from the chart config's name). - const baseTitle = + return ( renderedTemplate ?? `Alert for "${displayName}" - ${formattedValue} ${ doesExceedThreshold(alert, value) ? describeThresholdViolation(alert.thresholdType) : describeThresholdResolution(alert.thresholdType) - } ${describeThreshold(alert)}`; - return `${emoji}${baseTitle}`; + } ${describeThreshold(alert)}` + ); } throw new Error(`Unsupported alert source: ${alert.source}`); @@ -739,7 +737,11 @@ export const renderAlertTemplate = async ({ populatedChannel: channel, message: { hdxLink: buildAlertMessageTemplateHdxLink(alertProvider, view), - title, + // The state emoji is added per channel; a webhook can opt out. + title: + channel.channel.titleEmoji === false + ? title + : `${stateTitleEmoji(state)}${title}`, body: renderedBody, state, startTime: view.startTime.getTime(), diff --git a/packages/api/src/utils/zod.ts b/packages/api/src/utils/zod.ts index 8ec394afd..f4510fb74 100644 --- a/packages/api/src/utils/zod.ts +++ b/packages/api/src/utils/zod.ts @@ -1276,6 +1276,7 @@ const baseWebhookSchema = { name: z.string(), url: z.string().optional(), description: z.string().optional(), + titleEmoji: z.boolean().optional(), updatedAt: z.string(), createdAt: z.string(), }; @@ -1379,6 +1380,7 @@ export const externalWebhookCreateSchema = z service: z.nativeEnum(WebhookService), url: z.string().url().max(MAX_WEBHOOK_URL_LENGTH), description: z.string().max(MAX_WEBHOOK_DESCRIPTION_LENGTH).optional(), + titleEmoji: z.boolean().optional(), queryParams: z .record(webhookQueryParamKeySchema, webhookQueryParamValueSchema) .refine(m => Object.keys(m).length <= MAX_WEBHOOK_QUERY_PARAMS, { diff --git a/packages/app/src/api.ts b/packages/app/src/api.ts index 34a49630c..5271dcfdb 100644 --- a/packages/app/src/api.ts +++ b/packages/app/src/api.ts @@ -628,6 +628,7 @@ const api = { url: string; name: string; description: string; + titleEmoji?: boolean; queryParams?: Record; headers?: Record; body?: string; @@ -638,6 +639,7 @@ const api = { url, name, description, + titleEmoji, queryParams, headers, body, @@ -649,6 +651,7 @@ const api = { service, url, description, + titleEmoji, queryParams: queryParams || {}, headers: headers || {}, body, @@ -670,6 +673,7 @@ const api = { url: string; name: string; description: string; + titleEmoji?: boolean; queryParams?: Record; headers?: Record; body?: string; @@ -681,6 +685,7 @@ const api = { url, name, description, + titleEmoji, queryParams, headers, body, @@ -692,6 +697,7 @@ const api = { service, url, description, + titleEmoji, queryParams: queryParams || {}, headers: headers || {}, body, diff --git a/packages/app/src/components/TeamSettings/WebhookForm.tsx b/packages/app/src/components/TeamSettings/WebhookForm.tsx index 6cf1720e5..63d10c22f 100644 --- a/packages/app/src/components/TeamSettings/WebhookForm.tsx +++ b/packages/app/src/components/TeamSettings/WebhookForm.tsx @@ -16,6 +16,7 @@ import { isValidSlackUrl } from '@hyperdx/common-utils/dist/validation'; import { Alert, Button, + Checkbox, Code, Group, Radio, @@ -90,6 +91,7 @@ type WebhookForm = { url: string; service: WebhookService; description?: string; + titleEmoji: boolean; body?: string; headers?: string; }; @@ -115,6 +117,7 @@ export function WebhookForm({ name: webhook?.name || '', url: webhook?.url || '', description: webhook?.description || '', + titleEmoji: webhook?.titleEmoji !== false, body: webhook?.body || '', headers: webhook?.headers ? JSON.stringify(webhook.headers, null, 2) : '', }, @@ -128,6 +131,7 @@ export function WebhookForm({ name: webhook.name, url: webhook.url, description: webhook.description, + titleEmoji: webhook.titleEmoji !== false, body: webhook.body, headers: webhook.headers ? JSON.stringify(webhook.headers, null, 2) @@ -215,7 +219,8 @@ export function WebhookForm({ }; const onSubmit: SubmitHandler = async values => { - const { service, name, url, description, body, headers } = values; + const { service, name, url, description, titleEmoji, body, headers } = + values; try { // Parse headers JSON if provided (API will validate the content) @@ -247,6 +252,7 @@ export function WebhookForm({ name, url, description: description || '', + titleEmoji, body: defaultBody, headers: parsedHeaders, }; @@ -380,6 +386,11 @@ export function WebhookForm({ error={form.formState.errors.description?.message} {...form.register('description')} /> + {service === WebhookService.Generic && [