Skip to content

Commit

Permalink
metric_kind
Browse files Browse the repository at this point in the history
  • Loading branch information
bretthoerner committed Jul 16, 2024
1 parent f23a84e commit 29f851e
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions posthog/models/app_metrics2/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@
-- This may be ommitted if app_source is a singleton.
-- Examples: A plugin config id, a hog application config id
instance_id String,
metric_kind LowCardinality(String),
metric_name LowCardinality(String),
successes SimpleAggregateFunction(sum, Int64),
skipped SimpleAggregateFunction(sum, Int64),
failures SimpleAggregateFunction(sum, Int64)
count SimpleAggregateFunction(sum, Int64)
""".strip()

# NOTE: We have producers that take advantage of the timestamp being truncated to the hour,
Expand All @@ -48,7 +47,7 @@
)
ENGINE = {SHARDED_APP_METRICS2_TABLE_ENGINE()}
PARTITION BY toYYYYMM(timestamp)
ORDER BY (team_id, app_source, app_source_id, instance_id, {APP_METRICS2_TIMESTAMP_TRUNCATION}, metric_name)
ORDER BY (team_id, app_source, app_source_id, instance_id, {APP_METRICS2_TIMESTAMP_TRUNCATION}, metric_kind, metric_name)
{ttl_period("timestamp", APP_METRICS2_TTL_DAYS, unit="DAY")}
"""
)
Expand All @@ -73,10 +72,9 @@
app_source LowCardinality(String),
app_source_id String,
instance_id String,
metric_kind String,
metric_name String,
successes Int64,
skipped Int64,
failures Int64
count Int64
)
ENGINE={kafka_engine(topic=KAFKA_APP_METRICS2)}
"""
Expand All @@ -92,10 +90,9 @@
app_source,
app_source_id,
instance_id,
metric_kind,
metric_name,
successes,
skipped,
failures
count
FROM {settings.CLICKHOUSE_DATABASE}.kafka_app_metrics2
"""
)
Expand All @@ -109,10 +106,9 @@
app_source,
app_source_id,
instance_id,
metric_kind,
metric_name,
successes,
skipped,
failures,
count,
_timestamp,
_offset,
_partition
Expand All @@ -126,7 +122,9 @@
%(successes)s,
%(skipped)s,
%(failures)s,
%(metric_kind)s,
%(metric_name)s,
%(count)s,
now(),
0,
0
Expand Down

0 comments on commit 29f851e

Please sign in to comment.