Skip to content

[FEATURE] Table: migrate Grafana absolute thresholds to cellSettings - #808

Merged
AntoineThebaud merged 1 commit into
perses:mainfrom
colivi:feat/table-migrate-thresholds-color-text
Sep 16, 2026
Merged

AntoineThebaud merged 1 commit into
perses:mainfrom
colivi:feat/table-migrate-thresholds-color-text

Conversation

@colivi

@colivi colivi commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Description

Add the necessary logic into the Table migration schema to remap the Grafana table "fieldConfig.defaults.thresholds" (absolute mode) into Perses "cellSettings" with "Range" conditions.

When

  • "color.mode" is "thresholds"
  • "thresholds.mode" is "absolute"
  • at least one step has a numeric "value"
  • cell style is "color-text" (defaults or byName override) or "color-background"

How

  • Steps ordered highest "min" first (Table UI: first match wins)
  • Base step ("value: null") → "Range" with "min: 0"
  • "color-text" → "textColor"; "color-background" → "backgroundColor"
  • Named colors via "common/migrate" color map; hex colors passed through
  • Skips plain "auto" cellOptions and base-only ladders (e.g. green@null only) so existing migrate fixtures stay stable

Test

  • "table/schemas/migrate/tests/thresholds-color-text-absolute" (Uptime-style blue / green@1d / yellow@90d / red@180d)

Screenshots

N/A — migrate schema only (no UI change).

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the "[<catalog_entry>] " naming convention using one of the
    following "catalog_entry" values: "FEATURE", "ENHANCEMENT", "BUGFIX", "BREAKINGCHANGE", "DOC","IGNORE".
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Threshold migration loses field-override scope and mishandles base ranges for negative values.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds Grafana absolute-threshold migration to Perses Table conditional cell formatting.

Changes:

  • Converts threshold steps into ordered Range cell settings.
  • Maps threshold colors to text or background colors.
  • Adds an Uptime migration fixture.
File summaries
File Description
table/schemas/migrate/migrate.cue Implements threshold conversion.
table/schemas/migrate/tests/thresholds-color-text-absolute/input.json Provides Grafana input coverage.
table/schemas/migrate/tests/thresholds-color-text-absolute/expected.json Defines expected Perses output.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread table/schemas/migrate/migrate.cue Outdated
Comment thread table/schemas/migrate/migrate.cue Outdated
@shahrokni
shahrokni self-requested a review September 11, 2026 11:11
@colivi
colivi force-pushed the feat/table-migrate-thresholds-color-text branch 2 times, most recently from f3e0aba to e340365 Compare September 12, 2026 14:51
@colivi
colivi requested a review from a team as a code owner September 12, 2026 14:51
@AntoineThebaud AntoineThebaud changed the title [FEATURE](table): equivalent of Grafana absolute thresholds to cellSettings [FEATURE] Table: equivalent of Grafana absolute thresholds to cellSettings Sep 14, 2026
const timeRange = getPrometheusTimeRange(context.timeRange);
const step = getRangeStep(timeRange, minStep, undefined, context.suggestedStepMs); // TODO: resolution

// `spec.instant` is a per-query override: `true` forces instant, `false` forces range.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess these changes in the prometheus plugin are not relevant/related to this PR and should be removed?

@AntoineThebaud AntoineThebaud changed the title [FEATURE] Table: equivalent of Grafana absolute thresholds to cellSettings [FEATURE] Table: migrate Grafana absolute thresholds to cellSettings Sep 16, 2026
Map fieldConfig.defaults.thresholds (absolute) to Range cellSettings when
color.mode is thresholds and cellOptions is color-text (or color-background).

Table migrate only — no prometheus plugin changes.

Signed-off-by: colivi <charles.olivi@gmail.com>
@colivi
colivi force-pushed the feat/table-migrate-thresholds-color-text branch from 130653c to 47ffe58 Compare September 16, 2026 13:34

@AntoineThebaud AntoineThebaud left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🙏

@AntoineThebaud
AntoineThebaud added this pull request to the merge queue Sep 16, 2026
Merged via the queue into perses:main with commit 7f1bc0a Sep 16, 2026
17 checks passed
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