Skip to content

cluster: support ng-monitoring config via server_configs and per-instance overrides#2685

Open
boltandrke wants to merge 2 commits intopingcap:masterfrom
boltandrke:feat/ng-monitoring-server-configs
Open

cluster: support ng-monitoring config via server_configs and per-instance overrides#2685
boltandrke wants to merge 2 commits intopingcap:masterfrom
boltandrke:feat/ng-monitoring-server-configs

Conversation

@boltandrke
Copy link

What problem does this PR solve

Adds support for configuring ng-monitoring via topology YAML, addressing
the gap described in #2325.

Currently there is no way to set ng-monitoring configuration (e.g.
storage.type, storage.path, continuous_profiling.*) through
the topology YAML. The NgMonitoringConfig template is hardcoded with
no user-config merge step, unlike other components (PD/TiKV/TiDB) which
support server_configs + per-instance config overrides.

What is changed and how it works

  1. ServerConfigs.NGMonitoring — added ng_monitoring map[string]any to ServerConfigs for global ng-monitoring config
  2. PrometheusSpec.NgMonitoringConfig — added ng_monitoring_config map[string]any for per-instance overrides
  3. MonitorInstance.InitConfig — replaced template-based ngmonitoring.toml generation with map-based approach using Merge2Toml, following the same pattern as PD/TiKV/TiDB
  4. Example topology — updated with documented ng_monitoring and ng_monitoring_config sections

Usage

server_configs:
  ng_monitoring:
    storage.type: "sqlite"
    storage.path: "/tidb-data/prometheus-9090/docdb_sqlite"
    continuous_profiling.enable: true
    continuous_profiling.profile_seconds: 5

monitoring_servers:
  - host: 10.0.1.21
    ng_port: 12020
    ng_monitoring_config:
      continuous_profiling.data_retention_seconds: 259200

Check List

  • Code compiles (go build ./...)
  • All existing tests pass (go test ./pkg/cluster/spec/...)
  • New test added (TestNGMonitoringServerConfig)
  • Lint passes (make check — 0 issues)

Ref #2325

…ance overrides

Add ng_monitoring to ServerConfigs and NgMonitoringConfig to PrometheusSpec
so that ng-monitoring configuration (e.g. storage.type, storage.path,
continuous_profiling.*) can be set through the topology YAML.

Global config is set under server_configs.ng_monitoring, and per-instance
overrides under monitoring_servers[].ng_monitoring_config, following the
same merge pattern as PD/TiKV/TiDB.

Ref pingcap#2325
@ti-chi-bot ti-chi-bot bot requested review from breezewish and srstack February 21, 2026 13:43
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Feb 21, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign bb7133 for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Feb 21, 2026

Welcome @boltandrke! It looks like this is your first PR to pingcap/tiup 🎉

@pingcap-cla-assistant
Copy link

pingcap-cla-assistant bot commented Feb 21, 2026

CLA assistant check
All committers have signed the CLA.

@ti-chi-bot ti-chi-bot bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 21, 2026
Comment on lines -489 to +494
pds := []string{}
pdAddrs := []string{}
if servers, found := topoHasField("PDServers"); found {
for i := 0; i < servers.Len(); i++ {
pd := servers.Index(i).Interface().(*PDSpec)
pds = append(pds, fmt.Sprintf("\"%s\"", utils.JoinHostPort(pd.Host, pd.ClientPort)))
pdAddrs = append(pdAddrs, utils.JoinHostPort(pd.Host, pd.ClientPort))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this renames pds to pdAddrs and adds quotes around it? Is that needed?

"advertise-address": utils.JoinHostPort(i.GetHost(), spec.NgPort),
"log.path": paths.Log,
"log.level": "INFO",
"pd.endpoints": pdAddrs,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"pd.endpoints": pdAddrs,
"pd.endpoints": strconv.Quote(pdAddrs),

Maybe adding a quote here and using strconv.Quote() might be better

@dveeden
Copy link
Contributor

dveeden commented Feb 23, 2026

/cc @xhebox

@ti-chi-bot ti-chi-bot bot requested a review from xhebox February 23, 2026 14:52
@codecov-commenter
Copy link

codecov-commenter commented Feb 24, 2026

Codecov Report

❌ Patch coverage is 0% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.32%. Comparing base (c567110) to head (ddbd272).

Files with missing lines Patch % Lines
pkg/cluster/spec/monitoring.go 0.00% 21 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2685      +/-   ##
==========================================
- Coverage   42.37%   42.32%   -0.05%     
==========================================
  Files         424      424              
  Lines       47043    47052       +9     
==========================================
- Hits        19932    19911      -21     
- Misses      24425    24452      +27     
- Partials     2686     2689       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dveeden
Copy link
Contributor

dveeden commented Feb 24, 2026

/retest

Add explicit test assertion verifying that pd.endpoints with multiple
PD addresses serializes to a correct TOML array:
  endpoints = ["10.0.1.10:2379", "10.0.1.11:2379"]

This confirms the TOML encoder handles []string correctly, matching
the old template-based output format.
@boltandrke
Copy link
Author

Thanks for the review @dveeden!

Regarding the pd.endpoints question: the rename from pds to pdAddrs is intentional — the old code built manually-quoted strings (fmt.Sprintf("\"%s\"", addr)) because the template interpolated them directly into endpoints = [{{.PDAddrs}}]. The new code collects plain addresses as a []string because the TOML encoder (via Merge2Toml) handles serialization and quoting automatically.

strconv.Quote() would not work here since pdAddrs is []string, not string. The Go TOML encoder already serializes []string{"10.0.1.10:2379", "10.0.1.11:2379"} into the correct TOML array format:

[pd]
endpoints = ["10.0.1.10:2379", "10.0.1.11:2379"]

This matches the output produced by the old template.

I have pushed a new commit adding an explicit test assertion that verifies this behavior with multiple PD addresses, confirming the serialization is correct.

@dveeden
Copy link
Contributor

dveeden commented Feb 27, 2026

CLA assistant check Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.You have signed the CLA already but the status is still pending? Let us recheck it.

@boltandrke did you sign the CLA?

@boltandrke
Copy link
Author

CLA assistant check Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.You have signed the CLA already but the status is still pending? Let us recheck it.

@boltandrke did you sign the CLA?

Now I did!

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

Labels

contribution first-time-contributor size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants