Skip to content

Autocomplete inserts duplicate prefix for metric names containing dots #493

@arturminchukov

Description

@arturminchukov

Problem

When using autocomplete for metric names that contain dots (e.g. kubernetes.pod.id), selecting a suggestion produces a duplicated prefix.

Steps to reproduce:

  1. Open the query editor
  2. Start typing a dotted metric name, e.g. kubernetes.pod
  3. Autocomplete suggests kubernetes.pod.id
  4. Select the suggestion

Expected result: kubernetes.pod.id

Actual result: kubernetes.kubernetes.pod.id

Root cause

Monaco's getWordAtPosition() relies on the wordPattern regex defined in promql.ts, which treats dots (.) as word separators. When the cursor is at kubernetes.pod|, Monaco identifies only pod as the current word.
The completion replace range covers only pod, but insertText contains the full metric name kubernetes.pod.id. As a result, the text before the dot (kubernetes.) is preserved and the full metric name is inserted
after it.

Affected metrics

Any metric name containing dots, commonly seen in environments using Kubernetes, OpenTelemetry, or other systems that use dot-separated naming conventions (e.g. container.cpu.usage, k8s.node.memory,
process.runtime.gc.count).

Metadata

Metadata

Labels

bugSomething isn't workingvm-datasourcewaiting for releaseThe pull request was merged to upstream but not released yet.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions