-
Notifications
You must be signed in to change notification settings - Fork 727
feat: add sink dashboard metrics (CM-811) #3670
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
Open
ulemons
wants to merge
14
commits into
main
Choose a base branch
from
feat/add-sink-dashboard-metrics
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+59
−0
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
daccc8d
feat: add cdp_metrics_sink
ulemons 5489c25
feat: add cdp_metrics_sink
ulemons d48a4bc
fix: adjust pipes name for total metrics
ulemons ff5f282
feat: add custom smt
ulemons 5fbcf64
feat: add per segment pipe
ulemons 06df96d
fix: segments - child permutation
ulemons c26a0c2
fix: add check on parent granparent
ulemons 0c0d3df
fix: hierarky in tb
ulemons fa2a8d8
fix: segment pipe
ulemons 437daa6
feat: update dockerfile image version
ulemons 411a62b
feat: update docker image
ulemons 3e95e3a
feat: revert changes for total
ulemons 698457a
feat: revert changes for total
ulemons 50e6955
feat: revert changes for total
ulemons File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
services/libs/tinybird/pipes/cdp_dashboard_metrics_total_sink.pipe
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| DESCRIPTION > | ||
| Global metrics for activities, organizations, and members used for CDP dashboard. | ||
| Uses cdp_member_segment_aggregates_MV and cdp_organization_segment_aggregates_MV. | ||
| "Last30Days" is based on lastActive >= now() - 30 days. | ||
|
|
||
| NODE cdpDashboardMetricsTotal | ||
| SQL > | ||
| SELECT | ||
| ms.activitiesTotal, | ||
| ms.activitiesLast30Days, | ||
| ms.membersTotal, | ||
| ms.membersLast30Days, | ||
| os.organizationsTotal, | ||
| os.organizationsLast30Days | ||
| FROM | ||
| ( | ||
| -- member-based global metrics (single scan over cdp_member_segment_aggregates_MV) | ||
| SELECT | ||
| sum(activityCount) AS activitiesTotal, | ||
| sumIf(activityCount, lastActive >= now() - INTERVAL 30 DAY) AS activitiesLast30Days, | ||
| uniqCombined(memberId) AS membersTotal, | ||
| uniqCombinedIf(memberId, lastActive >= now() - INTERVAL 30 DAY) AS membersLast30Days | ||
| FROM | ||
| ( | ||
| -- finalize AggregateFunction states per member | ||
| SELECT | ||
| memberId, | ||
| countMerge(activityCountState) AS activityCount, | ||
| maxMerge(lastActiveState) AS lastActive | ||
| FROM cdp_member_segment_aggregates_MV | ||
| GROUP BY | ||
| memberId | ||
| ) AS m | ||
| ) AS ms | ||
| CROSS JOIN | ||
| ( | ||
| -- organization-based global metrics (single scan over cdp_organization_segment_aggregates_MV) | ||
| SELECT | ||
| uniqCombined(organizationId) AS organizationsTotal, | ||
| uniqCombinedIf(organizationId, lastActive >= now() - INTERVAL 30 DAY) AS organizationsLast30Days | ||
| FROM | ||
| ( | ||
| -- finalize AggregateFunction states per organization | ||
| SELECT | ||
| organizationId, | ||
| maxMerge(lastActiveState) AS lastActive | ||
| FROM cdp_organization_segment_aggregates_MV | ||
| GROUP BY | ||
| organizationId | ||
| ) AS o | ||
| ) AS os | ||
|
|
||
| TYPE SINK | ||
| EXPORT_SERVICE kafka | ||
| EXPORT_CONNECTION_NAME lfx-oracle-kafka-streaming | ||
| EXPORT_SCHEDULE 0 9 * * * | ||
| EXPORT_FORMAT json | ||
| EXPORT_STRATEGY @new | ||
| EXPORT_KAFKA_TOPIC cdp_dashboard_metrics_total_sink | ||
Oops, something went wrong.
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.
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.
Missing date column in dashboard metrics sink
Medium Severity
The sink output is missing a
datecolumn that other Kafka sink pipes in the codebase include (usingtoStartOfDay(now()) as date). Bothhealth_score_sink.pipeandinsights_projects_populated_sink.pipefollow this pattern. Without a date column, downstream consumers cannot determine when the metrics snapshot was generated, making historical analysis, deduplication, and data tracking difficult.