From 7a39a6b3c946a3fb3f53d07b971d5e5e40cf89bc Mon Sep 17 00:00:00 2001 From: Riccardo Busetti Date: Tue, 10 Dec 2024 16:46:53 +0100 Subject: [PATCH 1/9] Fix --- scripts/relay-init.sh | 52 ++++++++++++++++++++++++++ sentry-relay/Chart.yaml | 6 +++ sentry-relay/templates/NOTES.txt | 16 ++++++++ sentry-relay/templates/configmap.yaml | 11 ++++++ sentry-relay/templates/deployment.yaml | 43 +++++++++++++++++++++ sentry-relay/templates/secret.yaml | 12 ++++++ sentry-relay/templates/service.yaml | 15 ++++++++ sentry-relay/values.yaml | 23 ++++++++++++ 8 files changed, 178 insertions(+) create mode 100644 scripts/relay-init.sh create mode 100644 sentry-relay/Chart.yaml create mode 100644 sentry-relay/templates/NOTES.txt create mode 100644 sentry-relay/templates/configmap.yaml create mode 100644 sentry-relay/templates/deployment.yaml create mode 100644 sentry-relay/templates/secret.yaml create mode 100644 sentry-relay/templates/service.yaml create mode 100644 sentry-relay/values.yaml diff --git a/scripts/relay-init.sh b/scripts/relay-init.sh new file mode 100644 index 00000000000..04350c871e3 --- /dev/null +++ b/scripts/relay-init.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +set -euo pipefail + +CONFIG_DIR="config" + +# Ensure the config directory is cleaned up on exit +trap "rm -rf ${CONFIG_DIR}" EXIT + +# Prompt the user for the Sentry upstream URL +read -p "Enter your Sentry upstream URL (e.g. https://oXXXX.ingest.sentry.io): " SENTRY_UPSTREAM + +# Create a configuration directory for relay if it doesn't exist +mkdir -p "${CONFIG_DIR}" + +echo "Initializing Relay configuration..." +# Run relay config init to create config files (.relay/config.yml and credentials.json) +# We assume you'll choose the default configuration by pressing enter. +docker run --rm -it \ + -v "$(pwd)/${CONFIG_DIR}":/work/.relay \ + getsentry/relay \ + config init + +# At this point, config.yml and credentials.json should be in ${CONFIG_DIR} +CREDENTIALS_FILE="${CONFIG_DIR}/credentials.json" + +if [ ! -f "${CREDENTIALS_FILE}" ]; then + echo "Error: ${CREDENTIALS_FILE} not found. Make sure relay config init completed successfully." + exit 1 +fi + +echo "Reading credentials from ${CREDENTIALS_FILE}..." +# Parse the credentials file directly with jq +SECRET_KEY=$(jq -r '.secret_key' "${CREDENTIALS_FILE}") +PUBLIC_KEY=$(jq -r '.public_key' "${CREDENTIALS_FILE}") +RELAY_ID=$(jq -r '.id' "${CREDENTIALS_FILE}") + +echo "Credentials and upstream URL obtained successfully." + +cat <@oX.ingest.sentry.io/ + Relay DSN: http://@localhost:3000/ + +3. Test with sentry-cli: + export SENTRY_DSN='http://@localhost:3000/' + sentry-cli send-event -m 'A test event' + +4. Check in your Sentry project for the event. \ No newline at end of file diff --git a/sentry-relay/templates/configmap.yaml b/sentry-relay/templates/configmap.yaml new file mode 100644 index 00000000000..fcd54438e43 --- /dev/null +++ b/sentry-relay/templates/configmap.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "my-sentry-relay.fullname" . }}-config +data: + config.yml: | + relay: + mode: {{ .Values.relay.mode }} + upstream: {{ .Values.relay.upstream }} + host: {{ .Values.relay.host }} + port: {{ .Values.relay.port }} \ No newline at end of file diff --git a/sentry-relay/templates/deployment.yaml b/sentry-relay/templates/deployment.yaml new file mode 100644 index 00000000000..0912049cb62 --- /dev/null +++ b/sentry-relay/templates/deployment.yaml @@ -0,0 +1,43 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "my-sentry-relay.fullname" . }} + labels: + app: {{ include "my-sentry-relay.name" . }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ include "my-sentry-relay.name" . }} + template: + metadata: + labels: + app: {{ include "my-sentry-relay.name" . }} + spec: + containers: + - name: relay + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: ["run"] + ports: + - containerPort: {{ .Values.relay.port }} + volumeMounts: + - name: relay-config + mountPath: /work/.relay + - name: relay-credentials + mountPath: /work/.relay + readOnly: true + resources: + requests: + cpu: {{ .Values.resources.requests.cpu }} + memory: {{ .Values.resources.requests.memory }} + limits: + cpu: {{ .Values.resources.limits.cpu }} + memory: {{ .Values.resources.limits.memory }} + volumes: + - name: relay-config + configMap: + name: {{ include "my-sentry-relay.fullname" . }}-config + - name: relay-credentials + secret: + secretName: {{ include "my-sentry-relay.fullname" . }}-credentials \ No newline at end of file diff --git a/sentry-relay/templates/secret.yaml b/sentry-relay/templates/secret.yaml new file mode 100644 index 00000000000..66bc9826b26 --- /dev/null +++ b/sentry-relay/templates/secret.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "my-sentry-relay.fullname" . }}-credentials +type: Opaque +stringData: + credentials.json: | + { + "secret_key": "{{ .Values.credentials.secretKey }}", + "public_key": "{{ .Values.credentials.publicKey }}", + "id": "{{ .Values.credentials.relayId }}" + } \ No newline at end of file diff --git a/sentry-relay/templates/service.yaml b/sentry-relay/templates/service.yaml new file mode 100644 index 00000000000..1c3a19efe7d --- /dev/null +++ b/sentry-relay/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "my-sentry-relay.fullname" . }} + labels: + app: {{ include "my-sentry-relay.name" . }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.relay.port }} + protocol: TCP + name: http + selector: + app: {{ include "my-sentry-relay.name" . }} \ No newline at end of file diff --git a/sentry-relay/values.yaml b/sentry-relay/values.yaml new file mode 100644 index 00000000000..6486aa90602 --- /dev/null +++ b/sentry-relay/values.yaml @@ -0,0 +1,23 @@ +image: + repository: getsentry/relay + tag: latest + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 3000 + +relay: + mode: managed + host: 127.0.0.0 + port: 3000 + +credentials: + +resources: + requests: + cpu: 100m + memory: 128Mi + limits: + cpu: 500m + memory: 512Mi \ No newline at end of file From 85c21deb8c0fe19c6d3d798bf6eb9936ef1f7741 Mon Sep 17 00:00:00 2001 From: Riccardo Busetti Date: Tue, 10 Dec 2024 17:19:37 +0100 Subject: [PATCH 2/9] Fix --- sentry-relay/Chart.yaml | 6 ---- sentry-relay/templates/NOTES.txt | 16 ---------- sentry-relay/templates/configmap.yaml | 11 ------- sentry-relay/templates/deployment.yaml | 43 -------------------------- sentry-relay/templates/secret.yaml | 12 ------- sentry-relay/templates/service.yaml | 15 --------- sentry-relay/values.yaml | 23 -------------- 7 files changed, 126 deletions(-) delete mode 100644 sentry-relay/Chart.yaml delete mode 100644 sentry-relay/templates/NOTES.txt delete mode 100644 sentry-relay/templates/configmap.yaml delete mode 100644 sentry-relay/templates/deployment.yaml delete mode 100644 sentry-relay/templates/secret.yaml delete mode 100644 sentry-relay/templates/service.yaml delete mode 100644 sentry-relay/values.yaml diff --git a/sentry-relay/Chart.yaml b/sentry-relay/Chart.yaml deleted file mode 100644 index a932a4f7931..00000000000 --- a/sentry-relay/Chart.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v2 -name: sentry-relay -description: A Helm chart for deploying Sentry Relay -type: application -version: 0.1.0 -appVersion: "latest" \ No newline at end of file diff --git a/sentry-relay/templates/NOTES.txt b/sentry-relay/templates/NOTES.txt deleted file mode 100644 index 1d61fcbf010..00000000000 --- a/sentry-relay/templates/NOTES.txt +++ /dev/null @@ -1,16 +0,0 @@ -Thank you for installing my-sentry-relay! - -To test your Relay instance: - -1. Port forward the service: - kubectl port-forward svc/{{ include "my-sentry-relay.fullname" . }} 3000:3000 - -2. Update your DSN to point to Relay: - Original DSN: https://@oX.ingest.sentry.io/ - Relay DSN: http://@localhost:3000/ - -3. Test with sentry-cli: - export SENTRY_DSN='http://@localhost:3000/' - sentry-cli send-event -m 'A test event' - -4. Check in your Sentry project for the event. \ No newline at end of file diff --git a/sentry-relay/templates/configmap.yaml b/sentry-relay/templates/configmap.yaml deleted file mode 100644 index fcd54438e43..00000000000 --- a/sentry-relay/templates/configmap.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ include "my-sentry-relay.fullname" . }}-config -data: - config.yml: | - relay: - mode: {{ .Values.relay.mode }} - upstream: {{ .Values.relay.upstream }} - host: {{ .Values.relay.host }} - port: {{ .Values.relay.port }} \ No newline at end of file diff --git a/sentry-relay/templates/deployment.yaml b/sentry-relay/templates/deployment.yaml deleted file mode 100644 index 0912049cb62..00000000000 --- a/sentry-relay/templates/deployment.yaml +++ /dev/null @@ -1,43 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "my-sentry-relay.fullname" . }} - labels: - app: {{ include "my-sentry-relay.name" . }} -spec: - replicas: 1 - selector: - matchLabels: - app: {{ include "my-sentry-relay.name" . }} - template: - metadata: - labels: - app: {{ include "my-sentry-relay.name" . }} - spec: - containers: - - name: relay - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - args: ["run"] - ports: - - containerPort: {{ .Values.relay.port }} - volumeMounts: - - name: relay-config - mountPath: /work/.relay - - name: relay-credentials - mountPath: /work/.relay - readOnly: true - resources: - requests: - cpu: {{ .Values.resources.requests.cpu }} - memory: {{ .Values.resources.requests.memory }} - limits: - cpu: {{ .Values.resources.limits.cpu }} - memory: {{ .Values.resources.limits.memory }} - volumes: - - name: relay-config - configMap: - name: {{ include "my-sentry-relay.fullname" . }}-config - - name: relay-credentials - secret: - secretName: {{ include "my-sentry-relay.fullname" . }}-credentials \ No newline at end of file diff --git a/sentry-relay/templates/secret.yaml b/sentry-relay/templates/secret.yaml deleted file mode 100644 index 66bc9826b26..00000000000 --- a/sentry-relay/templates/secret.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - name: {{ include "my-sentry-relay.fullname" . }}-credentials -type: Opaque -stringData: - credentials.json: | - { - "secret_key": "{{ .Values.credentials.secretKey }}", - "public_key": "{{ .Values.credentials.publicKey }}", - "id": "{{ .Values.credentials.relayId }}" - } \ No newline at end of file diff --git a/sentry-relay/templates/service.yaml b/sentry-relay/templates/service.yaml deleted file mode 100644 index 1c3a19efe7d..00000000000 --- a/sentry-relay/templates/service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "my-sentry-relay.fullname" . }} - labels: - app: {{ include "my-sentry-relay.name" . }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: {{ .Values.relay.port }} - protocol: TCP - name: http - selector: - app: {{ include "my-sentry-relay.name" . }} \ No newline at end of file diff --git a/sentry-relay/values.yaml b/sentry-relay/values.yaml deleted file mode 100644 index 6486aa90602..00000000000 --- a/sentry-relay/values.yaml +++ /dev/null @@ -1,23 +0,0 @@ -image: - repository: getsentry/relay - tag: latest - pullPolicy: IfNotPresent - -service: - type: ClusterIP - port: 3000 - -relay: - mode: managed - host: 127.0.0.0 - port: 3000 - -credentials: - -resources: - requests: - cpu: 100m - memory: 128Mi - limits: - cpu: 500m - memory: 512Mi \ No newline at end of file From 703fe2b767f0668752156dac99b14712454bc5fd Mon Sep 17 00:00:00 2001 From: Riccardo Busetti Date: Wed, 11 Dec 2024 09:30:20 +0100 Subject: [PATCH 3/9] Fix --- scripts/relay-init.sh | 109 +++++++++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 33 deletions(-) mode change 100644 => 100755 scripts/relay-init.sh diff --git a/scripts/relay-init.sh b/scripts/relay-init.sh old mode 100644 new mode 100755 index 04350c871e3..6ab79207ed0 --- a/scripts/relay-init.sh +++ b/scripts/relay-init.sh @@ -2,51 +2,94 @@ set -euo pipefail -CONFIG_DIR="config" +# Usage: ./setup_relay.sh [--open] +if [[ $# -lt 2 ]]; then + echo "Usage: $0 [--open]" + exit 1 +fi -# Ensure the config directory is cleaned up on exit -trap "rm -rf ${CONFIG_DIR}" EXIT +DSN="$1" +ORG_SLUG="$2" +OPEN_PAGE="false" + +if [[ "${3:-}" == "--open" ]]; then + OPEN_PAGE="true" +fi -# Prompt the user for the Sentry upstream URL -read -p "Enter your Sentry upstream URL (e.g. https://oXXXX.ingest.sentry.io): " SENTRY_UPSTREAM +# Extract the host part from the DSN +# DSN format could be: https://o[org_id].ingest.us.sentry.io/[project_id] +# or even just https://o[org_id].ingest.us.sentry.io +# We'll strip the protocol and any trailing path: +UPSTREAM_HOST=$(echo "$DSN" | sed -E 's@^https://([^/]+).*@\1@') +UPSTREAM="https://$UPSTREAM_HOST" + +if [[ -z "$UPSTREAM_HOST" ]]; then + echo "Failed to parse upstream from DSN. Check the DSN format." + exit 1 +fi -# Create a configuration directory for relay if it doesn't exist -mkdir -p "${CONFIG_DIR}" +# Create the config directory +mkdir -p config echo "Initializing Relay configuration..." -# Run relay config init to create config files (.relay/config.yml and credentials.json) -# We assume you'll choose the default configuration by pressing enter. docker run --rm -it \ - -v "$(pwd)/${CONFIG_DIR}":/work/.relay \ + -v "$(pwd)/config/:/work/.relay/:z" \ getsentry/relay \ - config init + config init </dev/null; then + xdg-open "$RELAY_URL" + elif command -v open &>/dev/null; then + open "$RELAY_URL" + else + echo "Please open the following URL in your browser to register the Relay:" + echo "$RELAY_URL" + fi +else + echo "To register this Relay, visit:" + echo "$RELAY_URL" + echo "and add the public key: $PUBLIC_KEY" +fi -Your relay chart can now be installed with the following command: - helm install sentry-relay ../sentry-relay \\ - --set relay.upstream="${SENTRY_UPSTREAM}" \\ - --set credentials.secretKey="${SECRET_KEY}" \\ - --set credentials.publicKey="${PUBLIC_KEY}" \\ - --set credentials.relayId="${RELAY_ID}" +echo "Starting Relay on port 3000..." +docker run -d \ + -v "$(pwd)/config/:/work/.relay/" \ + -p 3000:3000 \ + getsentry/relay \ + run -Once deployed, you can port-forward and test sending events as noted in the chart's NOTES.txt. -EOF \ No newline at end of file +echo "Relay is now running on http://localhost:3000" +echo "Using DSN: $DSN" +echo "Upstream is set to: $UPSTREAM" +echo "Relay public key: $PUBLIC_KEY" +echo +echo "To send events through Relay, modify your DSN to point to http://localhost:3000." +echo "For example, if your original DSN was: $DSN" +echo "Replace the host part with localhost:3000 (use http, not https)." \ No newline at end of file From c4e57e338e490f7d26d59955c176c35ce2b3df57 Mon Sep 17 00:00:00 2001 From: Riccardo Busetti Date: Wed, 11 Dec 2024 09:48:32 +0100 Subject: [PATCH 4/9] Fix --- scripts/config/.relay/config.yml | 10 ++++ scripts/config/config.yml | 10 ++++ scripts/relay-init.sh | 93 +++++++++++++++++++------------- 3 files changed, 76 insertions(+), 37 deletions(-) create mode 100644 scripts/config/.relay/config.yml create mode 100644 scripts/config/config.yml diff --git a/scripts/config/.relay/config.yml b/scripts/config/.relay/config.yml new file mode 100644 index 00000000000..04223286d74 --- /dev/null +++ b/scripts/config/.relay/config.yml @@ -0,0 +1,10 @@ +# Please see the relevant documentation. +# Performance tuning: https://docs.sentry.io/product/relay/operating-guidelines/ +# All config options: https://docs.sentry.io/product/relay/options/ +relay: + mode: managed + instance: default + upstream: https://sentry.io/ + host: 0.0.0.0 + port: 3000 + diff --git a/scripts/config/config.yml b/scripts/config/config.yml new file mode 100644 index 00000000000..9e7c158b5de --- /dev/null +++ b/scripts/config/config.yml @@ -0,0 +1,10 @@ +# Please see the relevant documentation. +# Performance tuning: https://docs.sentry.io/product/relay/operating-guidelines/ +# All config options: https://docs.sentry.io/product/relay/options/ +relay: + mode: managed + instance: default + upstream: https://o19635.ingest.us.sentry.io + host: 0.0.0.0 + port: 3000 + diff --git a/scripts/relay-init.sh b/scripts/relay-init.sh index 6ab79207ed0..9e2a60297e4 100755 --- a/scripts/relay-init.sh +++ b/scripts/relay-init.sh @@ -2,24 +2,37 @@ set -euo pipefail -# Usage: ./setup_relay.sh [--open] +# Usage: ./setup_relay.sh [--open] [--config-path ] if [[ $# -lt 2 ]]; then - echo "Usage: $0 [--open]" + echo "Usage: $0 [--open] [--config-path ]" exit 1 fi DSN="$1" ORG_SLUG="$2" OPEN_PAGE="false" +CONFIG_PATH="$(pwd)/config" -if [[ "${3:-}" == "--open" ]]; then - OPEN_PAGE="true" -fi +# Parse optional arguments +shift 2 +while [[ $# -gt 0 ]]; do + case $1 in + --open) + OPEN_PAGE="true" + shift + ;; + --config-path) + CONFIG_PATH="$2" + shift 2 + ;; + *) + echo "Unknown option: $1" + exit 1 + ;; + esac +done # Extract the host part from the DSN -# DSN format could be: https://o[org_id].ingest.us.sentry.io/[project_id] -# or even just https://o[org_id].ingest.us.sentry.io -# We'll strip the protocol and any trailing path: UPSTREAM_HOST=$(echo "$DSN" | sed -E 's@^https://([^/]+).*@\1@') UPSTREAM="https://$UPSTREAM_HOST" @@ -29,39 +42,40 @@ if [[ -z "$UPSTREAM_HOST" ]]; then fi # Create the config directory -mkdir -p config +mkdir -p "$CONFIG_PATH" -echo "Initializing Relay configuration..." +echo -e "\n=== Initializing Relay ===\n" +echo "Initializing Relay configuration in $CONFIG_PATH..." docker run --rm -it \ - -v "$(pwd)/config/:/work/.relay/:z" \ + -v "$CONFIG_PATH/.relay/:/work/.relay/:z" \ getsentry/relay \ - config init </dev/null; then @@ -69,27 +83,32 @@ if [[ "$OPEN_PAGE" == "true" ]]; then elif command -v open &>/dev/null; then open "$RELAY_URL" else - echo "Please open the following URL in your browser to register the Relay:" + echo "šŸ“ Please open the following URL in your browser to register the Relay:" echo "$RELAY_URL" fi else - echo "To register this Relay, visit:" + echo "šŸ“ To register this Relay, visit:" echo "$RELAY_URL" echo "and add the public key: $PUBLIC_KEY" fi -echo "Starting Relay on port 3000..." +echo -e "\n=== Starting Relay ===\n" +echo "Launching Relay container on port 3000..." docker run -d \ - -v "$(pwd)/config/:/work/.relay/" \ + -v "$CONFIG_PATH/.relay/:/work/.relay/" \ -p 3000:3000 \ getsentry/relay \ run -echo "Relay is now running on http://localhost:3000" -echo "Using DSN: $DSN" -echo "Upstream is set to: $UPSTREAM" -echo "Relay public key: $PUBLIC_KEY" -echo -echo "To send events through Relay, modify your DSN to point to http://localhost:3000." -echo "For example, if your original DSN was: $DSN" -echo "Replace the host part with localhost:3000 (use http, not https)." \ No newline at end of file +echo -e "\n=== Setup Complete ===\n" +echo "āœ… Relay is now running on http://localhost:3000" +echo "šŸ“‹ Configuration Summary:" +echo "------------------------" +echo "DSN: $DSN" +echo "Upstream: $UPSTREAM" +echo "Public Key: $PUBLIC_KEY" +echo -e "\nšŸ“Œ Next Steps:" +echo "------------------------" +echo "To send events through Relay, modify your DSN to point to http://localhost:3000" +echo "Example: If your original DSN was: $DSN" +echo "Replace the host part with localhost:3000 (use http, not https)" From 2a8961e9fca7a04ece7edb08ee7bdea70008b567 Mon Sep 17 00:00:00 2001 From: Riccardo Busetti Date: Wed, 11 Dec 2024 09:52:26 +0100 Subject: [PATCH 5/9] Fix --- scripts/relay-init.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/relay-init.sh b/scripts/relay-init.sh index 9e2a60297e4..b23e933a0ad 100755 --- a/scripts/relay-init.sh +++ b/scripts/relay-init.sh @@ -47,11 +47,11 @@ mkdir -p "$CONFIG_PATH" echo -e "\n=== Initializing Relay ===\n" echo "Initializing Relay configuration in $CONFIG_PATH..." docker run --rm -it \ - -v "$CONFIG_PATH/.relay/:/work/.relay/:z" \ + -v "$CONFIG_PATH/:/work/.relay/:z" \ getsentry/relay \ config init -# The default config is now in $CONFIG_PATH/.relay/config.yml +# The default config is now in $CONFIG_PATH/config.yml echo -e "\n=== Configuring Relay ===\n" echo "Updating configuration settings..." sed -i '' "s|mode:.*|mode: managed|" "$CONFIG_PATH/config.yml" @@ -62,7 +62,7 @@ sed -i '' "s|port:.*|port: 3000|" "$CONFIG_PATH/config.yml" echo -e "\n=== Retrieving Credentials ===\n" echo "Fetching Relay public key..." PUBLIC_KEY=$(docker run --rm -it \ - -v "$CONFIG_PATH/.relay/:/work/.relay/" \ + -v "$CONFIG_PATH/:/work/.relay/" \ getsentry/relay \ credentials show | grep 'public key' | awk '{print $3}') @@ -95,7 +95,7 @@ fi echo -e "\n=== Starting Relay ===\n" echo "Launching Relay container on port 3000..." docker run -d \ - -v "$CONFIG_PATH/.relay/:/work/.relay/" \ + -v "$CONFIG_PATH/:/work/.relay/" \ -p 3000:3000 \ getsentry/relay \ run From 93a3b5270fe584a3a038ba00a01bc5284bb3a494 Mon Sep 17 00:00:00 2001 From: Riccardo Busetti Date: Wed, 11 Dec 2024 09:53:27 +0100 Subject: [PATCH 6/9] Fix --- scripts/config/.relay/config.yml | 10 ---------- scripts/config/config.yml | 10 ---------- 2 files changed, 20 deletions(-) delete mode 100644 scripts/config/.relay/config.yml delete mode 100644 scripts/config/config.yml diff --git a/scripts/config/.relay/config.yml b/scripts/config/.relay/config.yml deleted file mode 100644 index 04223286d74..00000000000 --- a/scripts/config/.relay/config.yml +++ /dev/null @@ -1,10 +0,0 @@ -# Please see the relevant documentation. -# Performance tuning: https://docs.sentry.io/product/relay/operating-guidelines/ -# All config options: https://docs.sentry.io/product/relay/options/ -relay: - mode: managed - instance: default - upstream: https://sentry.io/ - host: 0.0.0.0 - port: 3000 - diff --git a/scripts/config/config.yml b/scripts/config/config.yml deleted file mode 100644 index 9e7c158b5de..00000000000 --- a/scripts/config/config.yml +++ /dev/null @@ -1,10 +0,0 @@ -# Please see the relevant documentation. -# Performance tuning: https://docs.sentry.io/product/relay/operating-guidelines/ -# All config options: https://docs.sentry.io/product/relay/options/ -relay: - mode: managed - instance: default - upstream: https://o19635.ingest.us.sentry.io - host: 0.0.0.0 - port: 3000 - From 549d9e82fab8d8ff6a2f48393c8e6b536332381e Mon Sep 17 00:00:00 2001 From: Riccardo Busetti Date: Wed, 11 Dec 2024 09:59:52 +0100 Subject: [PATCH 7/9] Fix --- scripts/config/config.yml | 10 ++++++++++ scripts/relay-init.sh | 30 +++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 scripts/config/config.yml diff --git a/scripts/config/config.yml b/scripts/config/config.yml new file mode 100644 index 00000000000..9e7c158b5de --- /dev/null +++ b/scripts/config/config.yml @@ -0,0 +1,10 @@ +# Please see the relevant documentation. +# Performance tuning: https://docs.sentry.io/product/relay/operating-guidelines/ +# All config options: https://docs.sentry.io/product/relay/options/ +relay: + mode: managed + instance: default + upstream: https://o19635.ingest.us.sentry.io + host: 0.0.0.0 + port: 3000 + diff --git a/scripts/relay-init.sh b/scripts/relay-init.sh index b23e933a0ad..224ec6da012 100755 --- a/scripts/relay-init.sh +++ b/scripts/relay-init.sh @@ -2,9 +2,9 @@ set -euo pipefail -# Usage: ./setup_relay.sh [--open] [--config-path ] +# Usage: ./setup_relay.sh [--open] [--config-path ] [--port ] [--host ] if [[ $# -lt 2 ]]; then - echo "Usage: $0 [--open] [--config-path ]" + echo "Usage: $0 [--open] [--config-path ] [--port ] [--host ]" exit 1 fi @@ -12,6 +12,8 @@ DSN="$1" ORG_SLUG="$2" OPEN_PAGE="false" CONFIG_PATH="$(pwd)/config" +RELAY_PORT="3000" +RELAY_HOST="0.0.0.0" # Parse optional arguments shift 2 @@ -25,6 +27,14 @@ while [[ $# -gt 0 ]]; do CONFIG_PATH="$2" shift 2 ;; + --port) + RELAY_PORT="$2" + shift 2 + ;; + --host) + RELAY_HOST="$2" + shift 2 + ;; *) echo "Unknown option: $1" exit 1 @@ -56,8 +66,8 @@ echo -e "\n=== Configuring Relay ===\n" echo "Updating configuration settings..." sed -i '' "s|mode:.*|mode: managed|" "$CONFIG_PATH/config.yml" sed -i '' "s|upstream:.*|upstream: $UPSTREAM|" "$CONFIG_PATH/config.yml" -sed -i '' "s|host:.*|host: 0.0.0.0|" "$CONFIG_PATH/config.yml" -sed -i '' "s|port:.*|port: 3000|" "$CONFIG_PATH/config.yml" +sed -i '' "s|host:.*|host: $RELAY_HOST|" "$CONFIG_PATH/config.yml" +sed -i '' "s|port:.*|port: $RELAY_PORT|" "$CONFIG_PATH/config.yml" echo -e "\n=== Retrieving Credentials ===\n" echo "Fetching Relay public key..." @@ -93,22 +103,24 @@ else fi echo -e "\n=== Starting Relay ===\n" -echo "Launching Relay container on port 3000..." +echo "Launching Relay container on port $RELAY_PORT..." docker run -d \ -v "$CONFIG_PATH/:/work/.relay/" \ - -p 3000:3000 \ + -p "$RELAY_PORT:$RELAY_PORT" \ getsentry/relay \ run echo -e "\n=== Setup Complete ===\n" -echo "āœ… Relay is now running on http://localhost:3000" +echo "āœ… Relay is now running on http://$RELAY_HOST:$RELAY_PORT" echo "šŸ“‹ Configuration Summary:" echo "------------------------" echo "DSN: $DSN" echo "Upstream: $UPSTREAM" echo "Public Key: $PUBLIC_KEY" +echo "Local Host: $RELAY_HOST" +echo "Local Port: $RELAY_PORT" echo -e "\nšŸ“Œ Next Steps:" echo "------------------------" -echo "To send events through Relay, modify your DSN to point to http://localhost:3000" +echo "To send events through Relay, modify your DSN to point to http://$RELAY_HOST:$RELAY_PORT" echo "Example: If your original DSN was: $DSN" -echo "Replace the host part with localhost:3000 (use http, not https)" +echo "Replace the host part with $RELAY_HOST:$RELAY_PORT (use http, not https)" From 881fd3a1356780b4a29aff72cb6d3ef3d422b9e3 Mon Sep 17 00:00:00 2001 From: Riccardo Busetti Date: Wed, 11 Dec 2024 10:14:51 +0100 Subject: [PATCH 8/9] Fix --- scripts/config/config.yml | 2 +- scripts/relay-init.sh | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/config/config.yml b/scripts/config/config.yml index 9e7c158b5de..36357a373b4 100644 --- a/scripts/config/config.yml +++ b/scripts/config/config.yml @@ -5,6 +5,6 @@ relay: mode: managed instance: default upstream: https://o19635.ingest.us.sentry.io - host: 0.0.0.0 + host: 127.0.0.0 port: 3000 diff --git a/scripts/relay-init.sh b/scripts/relay-init.sh index 224ec6da012..651ab5dcf00 100755 --- a/scripts/relay-init.sh +++ b/scripts/relay-init.sh @@ -88,6 +88,15 @@ RELAY_URL="https://${ORG_SLUG}.sentry.io/settings/relay" echo -e "\n=== Registration Information ===\n" if [[ "$OPEN_PAGE" == "true" ]]; then echo "Opening Relay registration page: $RELAY_URL" + echo -e "\nšŸ“‹ Registration Instructions:" + echo "------------------------" + echo "1. On the Relay page, click 'Register Key'" + echo "2. Enter the following public key in the 'Public Key' field:" + echo -e "\n$PUBLIC_KEY\n" + echo "3. Enter a display name for your Relay" + echo "4. Optionally add a description" + echo "5. Click 'Register' to complete registration" + if command -v xdg-open &>/dev/null; then xdg-open "$RELAY_URL" elif command -v open &>/dev/null; then @@ -97,9 +106,14 @@ if [[ "$OPEN_PAGE" == "true" ]]; then echo "$RELAY_URL" fi else - echo "šŸ“ To register this Relay, visit:" - echo "$RELAY_URL" - echo "and add the public key: $PUBLIC_KEY" + echo "šŸ“ To register this Relay:" + echo "1. Visit: $RELAY_URL" + echo "2. Click 'Register Key'" + echo "3. Enter the following public key in the 'Public Key' field:" + echo -e "\n$PUBLIC_KEY\n" + echo "4. Enter a display name for your Relay" + echo "5. Optionally add a description" + echo "6. Click 'Register' to complete registration" fi echo -e "\n=== Starting Relay ===\n" From 91e51b4e76b89aa131ccd7f5f227615188211d3b Mon Sep 17 00:00:00 2001 From: Riccardo Busetti Date: Wed, 11 Dec 2024 10:15:13 +0100 Subject: [PATCH 9/9] Fix --- scripts/config/config.yml | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 scripts/config/config.yml diff --git a/scripts/config/config.yml b/scripts/config/config.yml deleted file mode 100644 index 36357a373b4..00000000000 --- a/scripts/config/config.yml +++ /dev/null @@ -1,10 +0,0 @@ -# Please see the relevant documentation. -# Performance tuning: https://docs.sentry.io/product/relay/operating-guidelines/ -# All config options: https://docs.sentry.io/product/relay/options/ -relay: - mode: managed - instance: default - upstream: https://o19635.ingest.us.sentry.io - host: 127.0.0.0 - port: 3000 -