Skip to content

Read Nezha v2 monitor names for the latency rows - #2

Open
Hansen1018 wants to merge 2 commits into
foru17:mainfrom
Hansen1018:fix/nezha-latency-monitor-name
Open

Hansen1018 wants to merge 2 commits into
foru17:mainfrom
Hansen1018:fix/nezha-latency-monitor-name

Conversation

@Hansen1018

@Hansen1018 Hansen1018 commented Oct 24, 2026 •

Copy link
Copy Markdown

🔖 Type of Change

  • Bug fix

Affected Area

  • Nezha adapter

What

The latency rows on a Nezha v2 panel have no name: each row shows only the colour dash, and every point collapses onto a single chart series.

Why

Nezha v2 renamed the two fields the dashboard sends. model.ServiceInfos is serialised with the JSON tags monitor_id / monitor_name (model/service_history_api.go, v2.0.0 onwards); Nezha v1 sent them as service_id / service_name.

The adapter read the v1 spelling only, so against a v2 panel every entry came back with name === undefined and id === undefined: the row label rendered as an empty string next to the colour dash, and id: undefined made every task share one key, so the chart drew all points as a single series instead of one line per monitor.

Both spellings are read now, with the v1 names kept as a fallback for v1 panels. Nothing else changes: no styles, no layout, no new fields.

Verification

  • pnpm check passes: typecheck, 219 tests, and the i18n check.
  • New test tests/nezha-ping.test.ts covers the v2 payload, the v1 payload and the per-task point split.
  • Built with pnpm build and checked on a Nezha v2.4.1 panel: the four latency rows now carry their monitor names (China Telecom - Hebei, China Unicom - Langfang (Hebei), China Mobile - Hebei, China Telecom - Shenzhen (Guangdong)), and the chart draws one line per monitor.

Nezha v2 renamed the service fields: model.ServiceInfos is serialised with the
JSON tags "monitor_id" / "monitor_name" (model/service_history_api.go, v2.0.0
onwards). Nezha v1 sent them as "service_id" / "service_name".

The adapter read the v1 spelling, so on a v2 panel every latency row had an
undefined name and an undefined id: the rows showed a bare colour dash, and all
points collapsed onto one series in the chart. Both spellings are read now, with
the v1 names kept as a fallback.
@Hansen1018

Hansen1018 commented Oct 24, 2026 •

Copy link
Copy Markdown
Author

Before:
Screenshot 2026-10-25 01:41:56

After:
Screenshot 2026-10-25 02:16:16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant