-
Notifications
You must be signed in to change notification settings - Fork 542
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ingesting analytics tags (#2698)
* wip: analytics tags * [autofix.ci] apply automated fixes * feat: add verifications_per_hour_v2 * feat: insert tags * docs: specify 10 tags per request * test: run serially cause gh actions suck --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
9a140d7
commit 6b9f353
Showing
29 changed files
with
1,073 additions
and
557 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,31 @@ | ||
name: ClickHouse Migration Production | ||
on: | ||
workflow_call: | ||
secrets: | ||
CLICKHOUSE_URL: | ||
required: true | ||
|
||
|
||
|
||
jobs: | ||
deploy: | ||
environment: ClickHouse Production Migration | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install | ||
uses: ./.github/actions/install | ||
with: | ||
go: true | ||
|
||
- name: Install goose | ||
run: go install github.com/pressly/goose/v3/cmd/goose@latest | ||
|
||
|
||
- name: Deploy | ||
run: goose up | ||
working-directory: internal/clickhouse/schema | ||
env: | ||
GOOSE_DRIVER: clickhouse | ||
GOOSE_DB_STRING: ${{ secrets.CLICKHOUSE_URL }} |
31 changes: 31 additions & 0 deletions
31
.github/workflows/job_clickhouse_migration_production.yaml
This file contains 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,31 @@ | ||
name: ClickHouse Migration Preview | ||
on: | ||
workflow_call: | ||
secrets: | ||
CLICKHOUSE_URL: | ||
required: true | ||
|
||
|
||
|
||
jobs: | ||
deploy: | ||
environment: Preview | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install | ||
uses: ./.github/actions/install | ||
with: | ||
go: true | ||
|
||
- name: Install gooes | ||
run: go install github.com/pressly/goose/v3/cmd/goose@latest | ||
|
||
|
||
- name: Deploy | ||
run: goose up | ||
working-directory: internal/clickhouse/schema | ||
env: | ||
GOOSE_DRIVER: clickhouse | ||
GOOSE_DB_STRING: ${{ secrets.CLICKHOUSE_URL }} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
11 changes: 11 additions & 0 deletions
11
internal/clickhouse/schema/027_add_tags_to_verifications.raw_key_verifications_v1.sql
This file contains 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,11 @@ | ||
-- +goose up | ||
ALTER TABLE verifications.raw_key_verifications_v1 | ||
ADD COLUMN IF NOT EXISTS tags Array(String) DEFAULT []; | ||
|
||
|
||
-- +goose down | ||
|
||
|
||
|
||
ALTER TABLE verifications.raw_key_verifications_v1 | ||
DROP COLUMN IF EXISTS tags; |
19 changes: 19 additions & 0 deletions
19
internal/clickhouse/schema/028_create_verifications.key_verifications_per_hour_v2.sql
This file contains 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,19 @@ | ||
-- +goose up | ||
CREATE TABLE verifications.key_verifications_per_hour_v2 | ||
( | ||
time DateTime, | ||
workspace_id String, | ||
key_space_id String, | ||
identity_id String, | ||
key_id String, | ||
outcome LowCardinality(String), | ||
tags Array(String), | ||
count Int64 | ||
) | ||
ENGINE = SummingMergeTree() | ||
ORDER BY (workspace_id, key_space_id, identity_id, key_id, time, tags) | ||
; | ||
|
||
|
||
-- +goose down | ||
DROP TABLE verifications.key_verifications_per_hour_v2; |
27 changes: 27 additions & 0 deletions
27
internal/clickhouse/schema/029_create_verifications.key_verifications_per_hour_mv_v2.sql
This file contains 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,27 @@ | ||
-- +goose up | ||
CREATE MATERIALIZED VIEW verifications.key_verifications_per_hour_mv_v2 | ||
TO verifications.key_verifications_per_hour_v2 | ||
AS | ||
SELECT | ||
workspace_id, | ||
key_space_id, | ||
identity_id, | ||
key_id, | ||
outcome, | ||
count(*) as count, | ||
toStartOfHour(fromUnixTimestamp64Milli(time)) AS time, | ||
tags | ||
FROM verifications.raw_key_verifications_v1 | ||
GROUP BY | ||
workspace_id, | ||
key_space_id, | ||
identity_id, | ||
key_id, | ||
outcome, | ||
time, | ||
tags | ||
; | ||
|
||
|
||
-- +goose down | ||
DROP VIEW verifications.key_verifications_per_hour_mv_v2; |
19 changes: 19 additions & 0 deletions
19
internal/clickhouse/schema/030_create_verifications.key_verifications_per_day_v2.sql
This file contains 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,19 @@ | ||
-- +goose up | ||
CREATE TABLE verifications.key_verifications_per_day_v2 | ||
( | ||
time DateTime, | ||
workspace_id String, | ||
key_space_id String, | ||
identity_id String, | ||
key_id String, | ||
outcome LowCardinality(String), | ||
tags Array(String), | ||
count Int64 | ||
) | ||
ENGINE = SummingMergeTree() | ||
ORDER BY (workspace_id, key_space_id, identity_id, key_id, time, tags) | ||
; | ||
|
||
|
||
-- +goose down | ||
DROP TABLE verifications.key_verifications_per_day_v2; |
27 changes: 27 additions & 0 deletions
27
internal/clickhouse/schema/031_create_verifications.key_verifications_per_day_mv_v2.sql
This file contains 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,27 @@ | ||
-- +goose up | ||
CREATE MATERIALIZED VIEW verifications.key_verifications_per_day_mv_v2 | ||
TO verifications.key_verifications_per_day_v2 | ||
AS | ||
SELECT | ||
workspace_id, | ||
key_space_id, | ||
identity_id, | ||
key_id, | ||
outcome, | ||
count(*) as count, | ||
toStartOfDay(fromUnixTimestamp64Milli(time)) AS time, | ||
tags | ||
FROM verifications.raw_key_verifications_v1 | ||
GROUP BY | ||
workspace_id, | ||
key_space_id, | ||
identity_id, | ||
key_id, | ||
outcome, | ||
time, | ||
tags | ||
; | ||
|
||
|
||
-- +goose down | ||
DROP VIEW verifications.key_verifications_per_day_mv_v2; |
19 changes: 19 additions & 0 deletions
19
internal/clickhouse/schema/032_create_verifications.key_verifications_per_month_v2.sql
This file contains 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,19 @@ | ||
-- +goose up | ||
CREATE TABLE verifications.key_verifications_per_month_v2 | ||
( | ||
time DateTime, | ||
workspace_id String, | ||
key_space_id String, | ||
identity_id String, | ||
key_id String, | ||
outcome LowCardinality(String), | ||
tags Array(String), | ||
count Int64 | ||
) | ||
ENGINE = SummingMergeTree() | ||
ORDER BY (workspace_id, key_space_id, identity_id, key_id, time, tags) | ||
; | ||
|
||
|
||
-- +goose down | ||
DROP TABLE verifications.key_verifications_per_month_v2; |
Oops, something went wrong.