Skip to content

optimize: add grafana json#7988

Merged
funky-eyes merged 4 commits intoapache:2.xfrom
slievrly:2.x_26_02_09
Mar 4, 2026
Merged

optimize: add grafana json#7988
funky-eyes merged 4 commits intoapache:2.xfrom
slievrly:2.x_26_02_09

Conversation

@slievrly
Copy link
Member

@slievrly slievrly commented Feb 8, 2026

Ⅰ. Describe what this PR did

add grafana json

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a Grafana dashboard JSON under script/server/grafana/ intended to visualize Seata transaction metrics exported to Prometheus.

Changes:

  • Add script/server/grafana/panel.json containing a Grafana dashboard with panels for transaction counts, latency, and TPS.
  • Add dashboard templating variables for instance, group, and pod to filter panels.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +564 to +567
"datasource": {
"type": "prometheus",
"uid": "hJ8_mPCnk"
},
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

The templating variables hardcode the Prometheus datasource UID ("hJ8_mPCnk"). If you switch to Grafana __inputs / a datasource placeholder for portability, make sure to apply it to the templating datasources too (not just panel datasources).

Copilot uses AI. Check for mistakes.
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 707,
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

The exported dashboard includes a fixed numeric "id" (707). Grafana dashboard JSON meant for import should typically omit "id" or set it to null so imports don’t try to update a non-existent dashboard or collide with an existing one.

Suggested change
"id": 707,
"id": null,

Copilot uses AI. Check for mistakes.
Comment on lines +32 to +35
"datasource": {
"type": "prometheus",
"uid": "hJ8_mPCnk"
},
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

The Prometheus datasource is hardcoded to a specific Grafana datasource UID ("hJ8_mPCnk"). This makes the dashboard non-portable (imports will fail unless the target Grafana has the same UID). Consider using Grafana’s datasource input mechanism (e.g., __inputs) or a datasource variable placeholder so the UID can be selected at import time.

Copilot uses AI. Check for mistakes.
"type": "prometheus",
"uid": "hJ8_mPCnk"
},
"expr": "sum(seata_transaction{kubeone_ali_appinstance_name=\"$instance\",group=~\"$group\",meter=\"counter\",pod=\"$pod\"}) by (status)",
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

These PromQL queries filter on the label key "kubeone_ali_appinstance_name", which is not a label produced by Seata’s metrics exporter (the standard key is "applicationId" per metrics IdConstants). As written, the dashboard won’t work out-of-the-box unless the Prometheus scrape/relabeling injects this custom label; consider switching to Seata’s built-in labels (applicationId/group/role/status/...) or documenting the required relabeling.

Suggested change
"expr": "sum(seata_transaction{kubeone_ali_appinstance_name=\"$instance\",group=~\"$group\",meter=\"counter\",pod=\"$pod\"}) by (status)",
"expr": "sum(seata_transaction{applicationId=\"$instance\",group=~\"$group\",meter=\"counter\",pod=\"$pod\"}) by (status)",

Copilot uses AI. Check for mistakes.
"type": "prometheus",
"uid": "hJ8_mPCnk"
},
"expr": "sum(seata_transaction{kubeone_ali_appinstance_name=\"$instance\",group=~\"$group\",meter=\"counter\",pod=\"$pod\"}) by (status)",
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

The "$pod" template variable is configured as multi-select + includeAll, but the query uses an exact-match selector pod="$pod". For multi/all selections Grafana expands the variable to a regex or $__all, so this selector can match nothing. Use a regex matcher (pod=~"$pod") or make the variable single-select without includeAll.

Suggested change
"expr": "sum(seata_transaction{kubeone_ali_appinstance_name=\"$instance\",group=~\"$group\",meter=\"counter\",pod=\"$pod\"}) by (status)",
"expr": "sum(seata_transaction{kubeone_ali_appinstance_name=\"$instance\",group=~\"$group\",meter=\"counter\",pod=~\"$pod\"}) by (status)",

Copilot uses AI. Check for mistakes.
"type": "prometheus",
"uid": "hJ8_mPCnk"
},
"expr": "sum(seata_transaction{kubeone_ali_appinstance_name=\"$instance\",group=~\"$group\",meter=\"summary\",statistic=\"count\",status=~\"unretry|timeout\",pod=\"$pod\"}) by (status)",
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

The "异常事务统计" query matches status=~"unretry|timeout", but Seata’s exported transaction statuses are things like "failed" and "2phaseTimeout" (plus retrying statuses), not "unretry"/"timeout". Update the status matcher to reflect actual Seata metric label values so the panel returns data.

Suggested change
"expr": "sum(seata_transaction{kubeone_ali_appinstance_name=\"$instance\",group=~\"$group\",meter=\"summary\",statistic=\"count\",status=~\"unretry|timeout\",pod=\"$pod\"}) by (status)",
"expr": "sum(seata_transaction{kubeone_ali_appinstance_name=\"$instance\",group=~\"$group\",meter=\"summary\",statistic=\"count\",status=~\"failed|2phaseTimeout|retrying\",pod=\"$pod\"}) by (status)",

Copilot uses AI. Check for mistakes.
},
"expr": "sum(rate(seata_transaction{kubeone_ali_appinstance_name=\"$instance\",group=~\"$group\",meter=\"counter\",pod=\"$pod\",status=~\"committed|rollbacked\"}[1m])) by (kubeone_ali_appinstance_name)",
"interval": "",
"legendFormat": "{{kubeone_ali_appinstance_name}}{{pod}}",
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

This query aggregates ... by (kubeone_ali_appinstance_name) but the legend format includes {{pod}}. Since pod is not in the grouping labels, it will be dropped from the output series and the legend will render empty/incorrect for pod. Either include pod in the aggregation labels or remove it from the legend template.

Suggested change
"legendFormat": "{{kubeone_ali_appinstance_name}}{{pod}}",
"legendFormat": "{{kubeone_ali_appinstance_name}}",

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.29%. Comparing base (bd5afab) to head (902a754).

Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #7988      +/-   ##
============================================
+ Coverage     72.28%   72.29%   +0.01%     
  Complexity      876      876              
============================================
  Files          1310     1310              
  Lines         49977    49977              
  Branches       5945     5945              
============================================
+ Hits          36124    36131       +7     
+ Misses        10902    10890      -12     
- Partials       2951     2956       +5     

see 10 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@funky-eyes funky-eyes added this to the 2.7.0 milestone Mar 4, 2026
Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

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

LGTM

@funky-eyes funky-eyes merged commit b5e8fd8 into apache:2.x Mar 4, 2026
11 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