Skip to content

[FEATURE] Add optional links to the Exemplar type (perses#3445) - #118

Merged
Nexucis merged 2 commits into
perses:mainfrom
julianocosta89:exemplars/3445-exemplar-links
Nov 3, 2026
Merged

Nexucis merged 2 commits into
perses:mainfrom
julianocosta89:exemplars/3445-exemplar-links

Conversation

@julianocosta89

Copy link
Copy Markdown
Contributor

Description

First step of the "embed links" part of the exemplars roadmap (perses/perses#3445, step 2): extends the query-result contract with an optional links field on Exemplar.

The design keeps the division of responsibilities clean:

  • The query plugin (PrometheusTimeSeriesQuery, follow-up PR) reads the datasource exemplars configuration (URL template + trace ID label) and computes the final URLs per exemplar, attaching them here.
  • The panels and the shared tooltip stay datasource-agnostic: they just render ExemplarLink[] as clickable buttons. Any panel that displays exemplars gets link support for free, and any query plugin can produce links without the UI knowing anything about the datasource.
export interface ExemplarLink {
  /** Optional display label for the link (e.g. shown on the button in the tooltip). */
  name?: string;
  /** Final URL, with variables and trace ID placeholders already resolved. */
  url: string;
}

export interface Exemplar {
  labels: Labels;
  value: number;
  timestamp: UnixTimeMs;
  /**
   * Links related to this exemplar (e.g. to a tracing UI), computed by the query
   * plugin from the datasource exemplars configuration. Optional so plugins that
   * don't support links keep the payload unchanged.
   */
  links?: ExemplarLink[];
}

The field is optional, so the change is fully backwards compatible: older dashboards/datasources load unchanged, and plugins that don't produce links keep the payload identical.

Testing

  • Type-check and the full existing spec test suite pass (14 tests).
  • No CUE / Go / Java counterpart: TimeSeriesData and its exemplar types exist only in the TS part of the spec (query-result contract, not a persisted resource) — verified there are no exemplar references in cue/, go/ or java/.

@jgbernalp

Copy link
Copy Markdown
Contributor

@julianocosta89 can you please sign your commits?

@Nexucis

Nexucis commented Oct 26, 2026

Copy link
Copy Markdown
Member

@julianocosta89 do you mind to signoff your commit, we will then be able to move forward

@julianocosta89
julianocosta89 force-pushed the exemplars/3445-exemplar-links branch from a29b35c to 357a1fb Compare October 27, 2026 10:08
@julianocosta89

Copy link
Copy Markdown
Contributor Author

@jgbernalp and @Nexucis sorry, I was off last week and couldn't do it.
I've just pushed the signed commit, sorry about that

@julianocosta89

Copy link
Copy Markdown
Contributor Author

I believe the failing CI is not related to this PR

Query plugins (e.g. PrometheusTimeSeriesQuery) will compute these links
from the datasource exemplars configuration (URL template + trace ID
label) so that exemplar tooltips can offer a jump to a tracing UI without
the panels or the shared tooltip knowing anything about the datasource.

Signed-off-by: Juliano Costa <julianocosta89@outlook.com>
@julianocosta89
julianocosta89 force-pushed the exemplars/3445-exemplar-links branch from 357a1fb to ed01fba Compare October 27, 2026 11:13
@jgbernalp

Copy link
Copy Markdown
Contributor

We fixed the CI in #125, mind rebasing?

@Nexucis Nexucis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thank you @julianocosta89 🙏

@Nexucis
Nexucis added this pull request to the merge queue Nov 3, 2026
Merged via the queue into perses:main with commit 3b4f5b2 Nov 3, 2026
14 checks passed
@julianocosta89
julianocosta89 deleted the exemplars/3445-exemplar-links branch November 3, 2026 22:34
austinlparker added a commit to austinlparker/perses-plugins that referenced this pull request Nov 24, 2026
Second step of the exemplars roadmap: the Prometheus datasource accepts
an optional `exemplars.links` list. Each link has a `url` template, the
`traceIDLabel` naming the exemplar label that holds the trace ID, and an
optional `name`.

PrometheusTimeSeriesQuery resolves the links of each exemplar and
attaches them to the `links` field added to the exemplar contract by
perses/spec#118, so every panel displaying exemplars gets them without
knowing about the datasource:

- `${traceId}` in the URL is replaced with the value of the trace ID
  label, as in the links of the TraceTable panel. It is URL encoded
  unless a format is given, as in the cell links of the Table panel.
- Dashboard variables are replaced in the URL and the name.
- An exemplar without the trace ID label does not get the link.

The change covers the CUE schema, the datasource editor, the Go SDK
(`AddExemplarLink`) and the documentation. `EnableExemplars` no longer
discards links added before it.

The URL of a link uses the #linkURL definition of perses/shared, so a
disallowed scheme (e.g. javascript:) is rejected.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Austin Parker <austin@ap2.io>
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.

3 participants