-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ref(generic-metrics): Remove 10 seconds granularity #4396
Conversation
This PR has a migration; here is the generated SQL -- start migrations
-- forward migration generic_metrics : 0014_sets_mv_2
Local op: CREATE MATERIALIZED VIEW IF NOT EXISTS generic_metric_sets_aggregation_mv_2 TO generic_metric_sets_local (org_id UInt64, project_id UInt64, metric_id UInt64, granularity UInt8, timestamp DateTime CODEC (DoubleDelta), retention_days UInt16, tags Nested(key UInt64, indexed_value UInt64, raw_value String), value AggregateFunction(uniqCombined64, UInt64), use_case_id LowCardinality(String)) AS
SELECT
use_case_id,
org_id,
project_id,
metric_id,
arrayJoin(granularities) as granularity,
tags.key,
tags.indexed_value,
tags.raw_value,
toDateTime(multiIf(granularity=1,60,granularity=2,3600,granularity=3,86400,-1) *
intDiv(toUnixTimestamp(timestamp),
multiIf(granularity=1,60,granularity=2,3600,granularity=3,86400,-1))) as timestamp,
retention_days,
uniqCombined64State(arrayJoin(set_values)) as value
FROM generic_metric_sets_raw_local
WHERE materialization_version = 2
AND metric_type = 'set'
GROUP BY
use_case_id,
org_id,
project_id,
metric_id,
tags.key,
tags.indexed_value,
tags.raw_value,
timestamp,
granularity,
retention_days
;
-- end forward migration generic_metrics : 0014_sets_mv_2
-- backward migration generic_metrics : 0014_sets_mv_2
Local op: DROP TABLE IF EXISTS generic_metric_sets_aggregation_mv_2;
-- end backward migration generic_metrics : 0014_sets_mv_2
-- forward migration generic_metrics : 0015_distributions_mv_2
Local op: CREATE MATERIALIZED VIEW IF NOT EXISTS generic_metric_distributions_aggregation_mv_2 TO generic_metric_distributions_aggregated_local (org_id UInt64, project_id UInt64, metric_id UInt64, granularity UInt8, timestamp DateTime CODEC (DoubleDelta), retention_days UInt16, tags Nested(key UInt64, indexed_value UInt64, raw_value String), value AggregateFunction(uniqCombined64, UInt64), use_case_id LowCardinality(String)) AS
SELECT
use_case_id,
org_id,
project_id,
metric_id,
arrayJoin(granularities) as granularity,
tags.key,
tags.indexed_value,
tags.raw_value,
toDateTime(multiIf(granularity=1,60,granularity=2,3600,granularity=3,86400,-1) *
intDiv(toUnixTimestamp(timestamp),
multiIf(granularity=1,60,granularity=2,3600,granularity=3,86400,-1))) as timestamp,
retention_days,
quantilesState(0.5, 0.75, 0.9, 0.95, 0.99)((arrayJoin(distribution_values) AS values_rows)) as percentiles,
minState(values_rows) as min,
maxState(values_rows) as max,
avgState(values_rows) as avg,
sumState(values_rows) as sum,
countState(values_rows) as count,
histogramState(250)(values_rows) as histogram_buckets
FROM generic_metric_distributions_raw_local
WHERE materialization_version = 2
AND metric_type = 'distribution'
GROUP BY
use_case_id,
org_id,
project_id,
metric_id,
tags.key,
tags.indexed_value,
tags.raw_value,
timestamp,
granularity,
retention_days
;
-- end forward migration generic_metrics : 0015_distributions_mv_2
-- backward migration generic_metrics : 0015_distributions_mv_2
Local op: DROP TABLE IF EXISTS generic_metric_distributions_aggregation_mv_2;
-- end backward migration generic_metrics : 0015_distributions_mv_2
-- forward migration generic_metrics : 0016_counters_mv_2
Local op: CREATE MATERIALIZED VIEW IF NOT EXISTS generic_metric_counters_aggregation_mv_2 TO generic_metric_counters_aggregated_local (org_id UInt64, project_id UInt64, metric_id UInt64, granularity UInt8, timestamp DateTime CODEC (DoubleDelta), retention_days UInt16, tags Nested(key UInt64, indexed_value UInt64, raw_value String), value AggregateFunction(sum, Float64), use_case_id LowCardinality(String)) AS
SELECT
use_case_id,
org_id,
project_id,
metric_id,
arrayJoin(granularities) as granularity,
tags.key,
tags.indexed_value,
tags.raw_value,
toDateTime(multiIf(granularity=1,60,granularity=2,3600,granularity=3,86400,-1) *
intDiv(toUnixTimestamp(timestamp),
multiIf(granularity=1,60,granularity=2,3600,granularity=3,86400,-1))) as timestamp,
retention_days,
sumState(count_value) as value
FROM generic_metric_counters_raw_local
WHERE materialization_version = 2
AND metric_type = 'counter'
GROUP BY
use_case_id,
org_id,
project_id,
metric_id,
tags.key,
tags.indexed_value,
tags.raw_value,
timestamp,
granularity,
retention_days
;
-- end forward migration generic_metrics : 0016_counters_mv_2
-- backward migration generic_metrics : 0016_counters_mv_2
Local op: DROP TABLE IF EXISTS generic_metric_counters_aggregation_mv_2;
-- end backward migration generic_metrics : 0016_counters_mv_2 |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #4396 +/- ##
==========================================
+ Coverage 90.34% 90.35% +0.01%
==========================================
Files 802 806 +4
Lines 39388 39558 +170
Branches 245 245
==========================================
+ Hits 35584 35743 +159
- Misses 3772 3783 +11
Partials 32 32
☔ View full report in Codecov by Sentry. |
Updated the pr to remove the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the migration plan makes sense here.
If you have to change the processor in the same PR as the migration, then that means there will be a period of time where the processor is broken.
I think I'm going to close this due to some additional changes I'd like to make to the matview. But quick (and pedantic) question, would this really break? Wouldn't this need another pr to set the materialized version in the processor to the one specified in the migration for the matview to kick in? |
Overview
Create migrations for materialized view of sets, counters, and distributions to remove granularity of 10 seconds.
Testing
Ran snuba locally with migrations applied and sent 9 messages in total, a single (set, counter, distribution) kafka payload for 3 use case IDs.