tikv / tikv/pd

keyspace: expose an opt-in keyspace ID-to-name mapping metric

Open
#11,175 0 comments 0 reactions 0 assignees View on GitHub
type/enhancement
Dominant language
Go
Stars
1.2k
Forks
783
Avg merge
5d 21h
Merged PRs (30d)
36

Description

## Enhancement Task

Expose an opt-in Prometheus info metric for translating keyspace IDs observed in keyspace-level metrics into keyspace names.

Example:

```promql
pd_keyspace_info{keyspace_id="42", keyspace_name="example"} 1
```

Requirements:

- The metric is disabled by default to avoid unnecessary cardinality.
- Provide a common startup configuration option for keyspace-level metrics so future metrics can reuse the same switch.
- Enable the option through deployment configuration for Essential v2 and Premium clusters.
- Populate mappings from successful `GetAllKeyspaces`, `LoadKeyspace`, and `LoadKeyspaceByID` client requests.
- Do not introduce additional etcd scans or internal keyspace watchers.
- Cache the metric child for each observed keyspace ID.
- Replace the old series if the same ID is later observed with a different name.
- Clean up an observed series after a keyspace removal transaction commits.

The metric represents client-observed mappings, not an authoritative inventory of every keyspace stored in PD. Consumers should join it with active keyspace-level metrics and should not use it to determine whether a keyspace currently exists.

PD does not have a reliable runtime service-plan identifier, so deployment configuration decides whether to enable the metric.

Contributor guide

Open the contributing guide

Research direction

Start by locating the keyspace-level metrics startup configuration and the successful GetAllKeyspaces, LoadKeyspace, and LoadKeyspaceByID client request paths. Trace the removal transaction commit path and the Essential v2 and Premium deployment configuration. Done means the opt-in metric follows the stated caching, replacement, cleanup, and cardinality rules without extra scans or watchers.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, prometheus
Domain
backend, observability
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.