Skip to content

feat(cluster_read): Batch Grafana queries via look-ahead in iterator#170

Merged
jhutar merged 4 commits into
redhat-performance:mainfrom
pablomh:grafana-batch-prefetch
Jun 8, 2026
Merged

feat(cluster_read): Batch Grafana queries via look-ahead in iterator#170
jhutar merged 4 commits into
redhat-performance:mainfrom
pablomh:grafana-batch-prefetch

Conversation

@pablomh

@pablomh pablomh commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Reduce Grafana HTTP round-trips by batching consecutive targets into a single render request. Plugins opt in by implementing measure_many() and batch_size; the iterator groups and delegates automatically.

On batch failure, falls back to individual measure() calls with per-target @Retry, preserving the original resilience.

  • Targets sent as POST body (data=) to avoid URI length limits
  • requests.Session() reuses connections across requests
  • --grafana-chunk-size default raised to 50 (configurable)
  • NoDataException restored for Prometheus plugin

28s → 9s per node in production (49 requests → 1).

@pablomh pablomh force-pushed the grafana-batch-prefetch branch from 057e83e to 2620f9a Compare June 6, 2026 21:58
…in iterator

Group consecutive Grafana items in RequestedInfo.__next__() and fetch
them in a single HTTP POST to the Graphite render API, up to
--grafana-chunk-size targets per request (default 50).

On batch failure, falls back to individual measure() calls with
per-target @Retry. Uses POST body (data=) instead of query string
to avoid URI length limits. Adds requests.Session() for TCP/TLS reuse.

Measured: 28s -> 9s per node (3.2x speedup) on a 49-metric config.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pablomh pablomh force-pushed the grafana-batch-prefetch branch from fe30860 to 44004d2 Compare June 7, 2026 06:07
pablomh and others added 3 commits June 8, 2026 16:08
Extract shared batch fixtures, RequestedInfo construction, and common
assertions in test_cluster_read to satisfy jscpd without changing test
coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
Switch cluster_read to absolute opl imports so pylint resolves the
namespace package correctly in CI.

Fixes: 5fbb2fc ("feat: I'm going to duplicate a ton of code here, I just need a quick way how to install core OPL without extra dependencies")
Fixes: a44a56c ("chore: Sync main and core bits")
Fixes: 7fb348c ("Rebase core/opl and cleanup")
Co-authored-by: Cursor <cursoragent@cursor.com>
Factor repeated copy_from and simple Grafana test setup into helpers to
reduce duplication and satisfy jscpd without changing test behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jhutar jhutar merged commit 82e4d49 into redhat-performance:main Jun 8, 2026
1 check passed
@pablomh pablomh deleted the grafana-batch-prefetch branch June 8, 2026 20:22
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.

2 participants