Go SDK: labelvalues.Datasource("$var") emits typed struct instead of raw variable reference, breaking variable queries
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start at labelvalues.Datasource and promDatasource.Selector in the Go SDK datasource package, then compare the emitted JSON with the raw-string representation confirmed by PR #775. Reproduce the PrometheusLabelValues example and trace how the selector is marshaled. Done means datasource variable references serialize as a bare "$datasource" string while typed datasource selectors remain supported.
索引モデルが issue の本文から書いたものです。
説明
Description
When building Perses dashboards programmatically with the Go SDK, calling labelvalues.Datasource("$datasource") to bind a PrometheusLabelValuesVariable to the selected datasource variable produces output that silently breaks all variable queries.
What the SDK emits (wrong)
"datasource": {
"kind": "PrometheusDatasource",
"name": "$datasource"
}
What Perses requires for a variable reference (correct)
"datasource": "$datasource"
PR #775 already confirmed this is the correct representation for datasource variable references. The CUE schema for spec.datasource is a disjunction that allows either a raw $variable string or a typed struct — but only the raw string triggers variable substitution at runtime.
Consequence
When the typed struct form is used with a variable name, Perses resolves it as a literal datasource name lookup. Since no registered datasource is named "$datasource", every label-values variable query returns no data — silently, with no visible error in the dashboard.
Steps to reproduce
labelvalues.PrometheusLabelValues("region",
labelvalues.Datasource("$datasource"),
labelvalues.Matchers("my_metric"),
)
Produces:
{
"kind": "PrometheusLabelValuesVariable",
"spec": {
"datasource": { "kind": "PrometheusDatasource", "name": "$datasource" },
"labelName": "region",
"matchers": ["my_metric"]
}
}
All region variable queries return no data.
Root cause
labelvalues.Datasource(name) calls promDatasource.Selector(name) which returns &datasource.Selector{Kind: PluginKind, Name: name}. This struct always serializes as the typed object form — there is no code path in the SDK to emit a bare "$variable" string.
Suggested fix
One of:
- In
github.com/perses/perses/go-sdk/datasource, add a customMarshalJSONtoSelectorthat emits a plain string whenNamematches^\$\w+$andKindis empty. - Add a new option
labelvalues.DatasourceVariable(variableName string)in this package that setsspec.datasourceto the raw string"$variableName"instead of constructing aSelectorstruct.
Related
- perses/plugins#775 — confirmed the typed struct is wrong for variable references (migration fix)
- perses/perses#3407 — runtime failure when using a datasource variable in variable plugin specs
- 主要言語
- TypeScript
- スター
- 33
- フォーク
- 88
- 平均マージ
- 1日 17時間
- マージ済み PR(30日)
- 37
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
perses/plugins のほかの issue
-
[BUG] splunk: export parsing, job polling and missing values are not handled robustly対応中かも @AnKiT-GaRG2 が 1 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
[BUG] clickhouse: getTimeSeriesData drops dimension columns, collapsing long-format results into one series対応中かも @aminadojava が 29 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 58/100
メンテナーはふだん 1 日以内に返信
-
[BUG] clickhouse: FORMAT substring check, envelope fallback and swallowed errors対応中かも @Yash121l が 17 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
perses/plugins#842 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
perses/plugins#501 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 91/100
caelestia-dots/caelestia#534 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
bobadilla-tech/biasmarket.com#402 ·
メンテナーはふだん 1 日以内に返信
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
javvadivijayprasad/sel2pw#28 ·
-
Area: Infrastructure Chore Difficulty: Low Good First Issue Priority: Low
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
DouglasNeuroInformatics/OpenDataCapture#1836 ·
メンテナーはふだん 1 日以内に返信
-
Two wording fixes: the init PROVIDER comment and the confirm page's lede対応中かも @kurtbruns が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信