Fix metrics chart not rendering (Redis TS 1.8+ QUERYINDEX compatibility)#16
Open
mgodwin wants to merge 1 commit into
Open
Fix metrics chart not rendering (Redis TS 1.8+ QUERYINDEX compatibility)#16mgodwin wants to merge 1 commit into
mgodwin wants to merge 1 commit into
Conversation
…raint
Redis TimeSeries 1.8+ requires at least one equality filter in TS.QUERYINDEX.
The previous code used only existence filters (name!= compaction!=), which
raised "ERR TSDB: please provide at least one matcher". This was silently
caught, leaving @all_series empty, causing the controller to default to the
wrong compaction type and return no chart data.
Fixes:
- index action: add .where(compaction: %w[sum avg min max]) to satisfy the
equality filter requirement while still returning all metric series
- labels action: use query_index(metric_name) directly, which generates a
name=<value> equality filter and is more efficient than filtering in Ruby
- routes: add constraints: { name: /[^\/]+/ } so dotted metric names like
request.count route correctly to the labels member endpoint
- view: add explicit empty state when a metric is selected but has no data
in the current time range (previously rendered nothing at all)
Adds MetricsControllerTest with 18 tests covering index, autocomplete,
and labels endpoints.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
label=value) inTS.QUERYINDEX. The previous code used only existence filters (name!=compaction!=), which raisesERR TSDB: please provide at least one matcher. This error was silently caught, leaving@all_series = []— which caused the controller to fall back to the wrong default compaction (avginstead ofsumfor counters), produce no chart data, and render a blank section with no feedback.indexaction (chart rendering) and thelabelsaction (group-by options).request.count) also failed to route to thelabelsmember endpoint without an explicit constraint.Changes
metrics_controller.rbindex: add.where(compaction: %w[sum avg min max])to provide required equality filter;labels: usequery_index(metric_name)directly (generatesname=valueequality filter, more efficient)metrics/index.html.erbconfig/routes.rbconstraints: { name: /[^\/]+/ }so metric names containing dots route correctly to thelabelsendpointmetrics_controller_test.rbindex(summary stats, chart rendering, data format, stacking, explicit params),autocomplete, andlabelsendpointstest/dummy/db/schema.rbTest plan
bin/rails test test/controllers/rails_observatory/metrics_controller_test.rb— all 18 tests pass/observatory/metrics, click the search field, select a metric, verify the chart renders