GTI-686: normalize Redis Cluster zone values in Region#25
Merged
Conversation
Redis Cluster node-level metrics expose a `location` label whose value is a zone (e.g. us-central1-a). That zone was being written verbatim into the Region column, which caused downstream redis2re grouping to emit one row per zone per cluster. Add _normalize_location() to split a GCP location string into its (region, zone) components and apply it in _accumulate_commands. Explicit `zone` labels (Valkey, Redis standalone with a zone metric label) keep their precedence over the derived value. Region-shaped strings (e.g. us-east4) are passed through unchanged.
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.
Problem
GCP exposes Redis Cluster and Valkey metrics under node-level monitored resources,
redis.googleapis.com/ClusterNodeandmemorystore.googleapis.com/InstanceNode, whoselocationlabel is a zone (for exampleus-central1-b), not a region.memorystore.pywas writing that value verbatim into theRegioncolumn, so a 4-node cluster spread across 3 zones produced 3 distinctRegionvalues for what is actually a single regional cluster.Downstream,
redis2regroups byRegionwhen sizing, so the same cluster surfaced as multiple duplicate rows in the Salesforce sizing CSV, one per zone, with throughput split across them.Standalone Redis (
redis_instance) is unaffected because it exposesregionexplicitly. The bug only appears on cluster / Valkey node-level metrics.Fix
_normalize_location(value) -> (region, zone)to detect zone-shaped GCP location strings using^([a-z]+(?:-[a-z]+)+\d+)-[a-z]$and split them into region and zone components.us-east4, plus values likeus,global, and empty strings, pass through unchanged as the region with an empty zone._accumulate_commandswhen resolvingREGION_LABELS.zonelabels as higher precedence when present, preserving existing behavior for resources that already populate both fields.The regex was validated against the current GCP namespace:
130/130current zones matched and mapped to the correct parent region43/43current regions were correctly rejectedThe multi-segment form
(?:-[a-z]+)+also supports hypothetical 3+ word-segment regions without changing behavior for names currently in use.Verification
Reproduced end-to-end against a live multi-zone cluster,
redislabs-sales-pivotal/memorystore-redis-cluster, with 2 shards × 2 replicas acrossus-central1-{b,c,f}after generating mixed-command traffic.memorystore.pyRegioncolumnus-central1-b,us-central1-c,us-central1-fus-central1for all 4 nodesmemorystore.pyZonecolumn-b/-c/-f)redis2resizing rows for the cluster0.01 + 0.01 + 0.10ops)0.04ops, throughput aggregated correctly)Verification artifacts, including
memorystore.pyCSV before/after andredis2resizing CSV before/after, are attached to the Jira ticket.Tests
Added in
test_msstats.py:test_normalize_location_zone_form— splitsus-central1-ainto("us-central1", "us-central1-a")test_normalize_location_region_form— passesus-east4,us,global, and""through unchangedtest_accumulate_commands_cluster_node_splits_zone_from_loc— drives_accumulate_commandswith a syntheticClusterNodetime series carrying a zone-shapedlocationand asserts the resultingRegion/ZonesplitValidation:
pytest test_msstats.py->27/27passingblack --checkclean