-
-
Notifications
You must be signed in to change notification settings - Fork 4
feat(gizmosql): add #289
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
HMDank
wants to merge
8
commits into
main
Choose a base branch
from
feat/gizmosql/add
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.
Open
feat(gizmosql): add #289
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
400456c
fix(postgraphile): correct sentry dsn environment variable name
dargmuesli 57d6362
feat(gizmosql): add
HMDank 94e4c85
Merge branch 'main' into feat/gizmosql/add
HMDank 089157f
chore: rename variables
HMDank e988bc4
chore: add environment variable placeholder
HMDank 8d4b6bc
feat(gizmo): hook to grafana
HMDank 6d9dc9f
chore(docs): update docs and comments
HMDank 54fd4ee
chore: migrate secrets
HMDank 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
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
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
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
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,41 @@ | ||
| secrets: | ||
| gizmosql-password: | ||
| # The gizmosql server's password. | ||
| file: ~~/artifacts/secrets/gizmosql-password.secret | ||
| services: | ||
| gizmosql: | ||
| # You can query the event stream's parquet lakehouse using `grafana`. | ||
| command: /run/entrypoint.sh | ||
| deploy: | ||
| labels: | ||
| - dargstack.profiles=event-streaming | ||
| entrypoint: sh | ||
| environment: | ||
| GIZMOSQL_USERNAME: gizmosql | ||
| INIT_SQL_COMMANDS_FILE: /tmp/gizmosql-init.sql | ||
| PRINT_QUERIES: "1" | ||
| TLS_ENABLED: "0" | ||
| healthcheck: | ||
| test: ["CMD-SHELL", "GIZMOSQL_PASSWORD=$$(cat /run/environment-variables/GIZMOSQL_PASSWORD) gizmosql_client --host 127.0.0.1 --port 31337 --username gizmosql --command 'SELECT 1'"] | ||
| interval: 30s | ||
| timeout: 10s | ||
| retries: 3 | ||
| start_period: 60s | ||
| image: gizmodata/gizmosql:v1.35.1 | ||
| secrets: | ||
| - source: gizmosql-password | ||
| target: /run/environment-variables/GIZMOSQL_PASSWORD | ||
| - source: s3-account-id | ||
| target: /run/environment-variables/S3_ACCOUNT_ID | ||
| - source: s3-aws-credentials-access-key-id | ||
| target: /run/environment-variables/S3_ACCESS_KEY_ID | ||
| - source: s3-aws-credentials-access-key | ||
| target: /run/environment-variables/S3_SECRET_ACCESS_KEY | ||
| volumes: | ||
| - ./configurations/entrypoint.sh:/run/entrypoint.sh:ro | ||
| - ./configurations/init.sql.template:/run/init.sql.template:ro | ||
| x-dargstack: | ||
| secrets: | ||
| gizmosql-password: | ||
| special_characters: false | ||
| type: random_string |
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,51 @@ | ||
| #!/bin/sh | ||
| set -eu | ||
|
|
||
| # START of maevsi entrypoint script customization | ||
| ENVIRONMENT_VARIABLES_PATH="/run/environment-variables" | ||
|
|
||
| is_valid_var_name() { | ||
| case "$1" in | ||
| ''|[!a-zA-Z_]*|*[!a-zA-Z0-9_]*) return 1 ;; | ||
| *) return 0 ;; | ||
| esac | ||
| } | ||
|
|
||
| load_env_file() { | ||
| file="$1" | ||
| name=$(basename "$file") | ||
| is_valid_var_name "$name" || return 0 | ||
| value=$(cat "$file") | ||
| export "$name=$value" | ||
| } | ||
|
|
||
| load_environment_variables() { | ||
| [ -d "$ENVIRONMENT_VARIABLES_PATH" ] || return 0 | ||
| set -- "$ENVIRONMENT_VARIABLES_PATH"/* | ||
| [ -e "$1" ] || return 0 | ||
|
|
||
| for file in "$ENVIRONMENT_VARIABLES_PATH"/*; do | ||
| [ -f "$file" ] && load_env_file "$file" | ||
| done | ||
| } | ||
|
|
||
| load_environment_variables | ||
| # END of maevsi entrypoint script customization | ||
|
|
||
| # DuckDB in this image has no getenv() function, so the S3 values are rendered | ||
| # into init.sql. sed treats `&` and `\` specially in replacements, so escape | ||
| # them first (S3 keys are hex today, but this keeps arbitrary values safe). | ||
| escape_sed_replacement() { | ||
| printf '%s\n' "$1" | sed 's/[&\\]/\\&/g' | ||
| } | ||
|
|
||
| S3_ACCOUNT_ID="$(escape_sed_replacement "${S3_ACCOUNT_ID}")" | ||
| S3_ACCESS_KEY_ID="$(escape_sed_replacement "${S3_ACCESS_KEY_ID}")" | ||
| S3_SECRET_ACCESS_KEY="$(escape_sed_replacement "${S3_SECRET_ACCESS_KEY}")" | ||
|
|
||
| sed -e "s|__S3_ACCOUNT_ID__|${S3_ACCOUNT_ID}|g" \ | ||
| -e "s|__S3_ACCESS_KEY_ID__|${S3_ACCESS_KEY_ID}|g" \ | ||
| -e "s|__S3_SECRET_ACCESS_KEY__|${S3_SECRET_ACCESS_KEY}|g" \ | ||
| /run/init.sql.template > /tmp/gizmosql-init.sql | ||
|
|
||
| exec /opt/gizmosql/scripts/start_gizmosql.sh |
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,38 @@ | ||
| INSTALL httpfs; | ||
| LOAD httpfs; | ||
|
|
||
| CREATE SECRET s3_secret (TYPE r2, KEY_ID '__S3_ACCESS_KEY_ID__', SECRET '__S3_SECRET_ACCESS_KEY__', ACCOUNT_ID '__S3_ACCOUNT_ID__'); | ||
|
|
||
| CREATE SCHEMA IF NOT EXISTS analytics; | ||
|
|
||
| -- The event stream's parquet lakehouse, written by redpanda-connect to S3 | ||
| -- (bucket "test", prefix "events/"). The raw parquet columns are strings, so | ||
| -- ids and timestamps are cast to proper types (try_cast keeps bad values NULL). | ||
| CREATE OR REPLACE VIEW analytics.events AS | ||
| SELECT | ||
| try_cast(id AS UUID) AS id, | ||
| name, | ||
| slug, | ||
| try_cast(start AS TIMESTAMPTZ) AS start, | ||
| try_cast("end" AS TIMESTAMPTZ) AS "end", | ||
| visibility, | ||
| is_archived, | ||
| is_in_person, | ||
| is_remote, | ||
| language, | ||
| url, | ||
| try_cast(address_id AS UUID) AS address_id, | ||
| guest_count_maximum, | ||
| try_cast(created_at AS TIMESTAMPTZ) AS created_at, | ||
| try_cast(created_by AS UUID) AS created_by, | ||
| operation | ||
| FROM read_parquet('r2://test/events/*.parquet'); | ||
|
|
||
| -- Example aggregate over the lakehouse. | ||
| CREATE OR REPLACE VIEW analytics.events_daily AS | ||
| SELECT | ||
| try_cast(created_at AS DATE) AS day, | ||
| count(*) AS events | ||
| FROM read_parquet('r2://test/events/*.parquet') | ||
| GROUP BY 1 | ||
| ORDER BY 1; |
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
14 changes: 14 additions & 0 deletions
14
src/development/grafana/configurations/provisioning/datasources/gizmosql.yaml
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,14 @@ | ||
| apiVersion: 1 | ||
|
|
||
| datasources: | ||
| - access: proxy | ||
| editable: true | ||
| jsonData: | ||
| host: gizmosql | ||
| port: 31337 | ||
| useTLS: false | ||
| username: gizmosql | ||
| name: GizmoSQL | ||
| secureJsonData: | ||
| password: $__file{/run/secrets/gizmosql-password} | ||
| type: gizmodata-gizmosql-datasource |
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,30 @@ | ||
| secrets: | ||
| s3-aws-credentials: | ||
| # The event stream ingestion's s3 credentials file. | ||
| file: ~~/artifacts/secrets/s3-aws-credentials.secret | ||
| services: | ||
| redpanda-connect: | ||
| # You cannot access the event stream connector directly. | ||
| deploy: | ||
| labels: | ||
| - dargstack.profiles=event-streaming | ||
| environment: | ||
| AWS_SHARED_CREDENTIALS_FILE: /run/secrets/s3-aws-credentials | ||
| healthcheck: | ||
| test: ["CMD-SHELL", "wget -q --spider http://127.0.0.1:4195/ready"] | ||
| interval: 30s | ||
| timeout: 5s | ||
| retries: 3 | ||
| start_period: 30s | ||
| image: redpandadata/connect:4.103.1 | ||
| secrets: | ||
| - s3-aws-credentials | ||
| volumes: | ||
| - ./configurations/config.yaml:/connect.yaml:ro | ||
| x-dargstack: | ||
| secrets: | ||
| s3-aws-credentials: | ||
| template: | | ||
| [default] | ||
| aws_access_key_id = {{secret:s3-aws-credentials-access-key-id}} | ||
| aws_secret_access_key = {{secret:s3-aws-credentials-access-key}} |
77 changes: 77 additions & 0 deletions
77
src/development/redpanda-connect/configurations/config.yaml
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,77 @@ | ||
| input: | ||
| kafka_franz: | ||
| seed_brokers: ["redpanda:9092"] | ||
| topics: ["vibetype.vibetype.event"] | ||
| consumer_group: "rp_connect_s3_ingest" | ||
| pipeline: | ||
| processors: | ||
| # Tombstone messages (Debezium deletes) carry no payload and must be dropped. | ||
| - bloblang: | | ||
| root = if this.payload.after.or(this.after) == null { deleted() } | ||
| - mapping: | | ||
| root = this.payload.after.or(this.after) | ||
| root.operation = this.payload.op.or(this.op) | ||
|
Comment on lines
+8
to
+13
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this handles all tombstone messages correctly, I'd need to research a bit more. |
||
| output: | ||
| aws_s3: | ||
| bucket: test | ||
| endpoint: ${S3_ENDPOINT_URL} | ||
|
HMDank marked this conversation as resolved.
|
||
| region: weur | ||
| force_path_style_urls: true | ||
| credentials: | ||
| profile: default | ||
| path: 'events/${! timestamp_unix_nano() }-${! uuid_v4() }.parquet' | ||
| batching: | ||
| count: 10000 | ||
| period: 15s | ||
| processors: | ||
| - parquet_encode: | ||
| schema: | ||
| - name: id | ||
| type: UTF8 | ||
| optional: true | ||
| - name: name | ||
| type: UTF8 | ||
| optional: true | ||
| - name: slug | ||
| type: UTF8 | ||
| optional: true | ||
| - name: start | ||
| type: UTF8 | ||
| optional: true | ||
| - name: end | ||
| type: UTF8 | ||
| optional: true | ||
| - name: visibility | ||
| type: UTF8 | ||
| optional: true | ||
| - name: is_archived | ||
| type: BOOLEAN | ||
| optional: true | ||
| - name: is_in_person | ||
| type: BOOLEAN | ||
| optional: true | ||
| - name: is_remote | ||
| type: BOOLEAN | ||
| optional: true | ||
| - name: language | ||
| type: UTF8 | ||
| optional: true | ||
| - name: url | ||
| type: UTF8 | ||
| optional: true | ||
| - name: address_id | ||
| type: UTF8 | ||
| optional: true | ||
| - name: guest_count_maximum | ||
| type: INT64 | ||
| optional: true | ||
| - name: created_at | ||
| type: UTF8 | ||
| optional: true | ||
| - name: created_by | ||
| type: UTF8 | ||
| optional: true | ||
| - name: operation | ||
| type: UTF8 | ||
| optional: true | ||
| default_compression: zstd | ||
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,5 @@ | ||
| services: | ||
| gizmosql: | ||
| deploy: | ||
| update_config: | ||
| order: stop-first |
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,5 @@ | ||
| services: | ||
| redpanda-connect: | ||
| deploy: | ||
| update_config: | ||
| order: stop-first | ||
|
dargmuesli marked this conversation as resolved.
|
||
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.
I think about removing all the provisioning code for Grafana and instead configure it in the live system. Provisioning codifies the initial setup and makes it more explicit in that sense but also is quite rigid and disallows changing the config in the live Grafana instance. As we want to persist configurations done in the Grafana UI anyway, we can safe ourselves from config being too rigid and extensive and just configure those connectors in the UI, I'd say.