Skip to content

Commit

Permalink
add: timeseries dependencies sqlmesh model
Browse files Browse the repository at this point in the history
  • Loading branch information
Jabolol committed Dec 4, 2024
1 parent 353d6dc commit 5f36e82
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions warehouse/metrics_mesh/models/metrics_factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,15 @@
),
entity_types=["artifact", "project", "collection"],
),
"dependencies": MetricQueryDef(
ref="dependencies.sql",
rolling=RollingConfig(
windows=[180],
unit="day",
cron="@daily",
),
entity_types=["artifact", "project", "collection"],
),
},
default_dialect="clickhouse",
)
14 changes: 14 additions & 0 deletions warehouse/metrics_mesh/oso_metrics/dependencies.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
select @metrics_sample_date(events.bucket_day) as metrics_sample_date,
events.event_source,
events.to_artifact_id,
'' as from_artifact_id,
@metric_name() as metric,
SUM(events.amount) as amount
from metrics.events_daily_to_artifact as events
where event_type = 'ADD_DEPENDENCY'
and events.bucket_day BETWEEN @metrics_start('DATE') AND @metrics_end('DATE')
group by 1,
metric,
from_artifact_id,
to_artifact_id,
event_source

0 comments on commit 5f36e82

Please sign in to comment.