diff --git a/.env b/.env index 7a768f2..d75f181 100644 --- a/.env +++ b/.env @@ -26,3 +26,8 @@ HEALTHCHECK_FILE_RETRIES=3 HEALTHCHECK_FILE_START_PERIOD=600s # Set SETUP_JS_SDK_ASSETS to 1 to enable the setup of JS SDK assets # SETUP_JS_SDK_ASSETS=1 +# +# Sentry (and its' surrounding services) uses Statsd for metrics collection. +# It's also the proper way to monitor self-hosted Sentry systems. +# Set STATSD_ADDR to a valid IP:PORT combination to enable Statsd metrics collection. +# STATSD_ADDR=127.0.0.1:8125 diff --git a/docker-compose.yml b/docker-compose.yml index 8e8d50b..4017e52 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -69,6 +69,7 @@ x-sentry-defaults: &sentry_defaults SENTRY_EVENT_RETENTION_DAYS: SENTRY_MAIL_HOST: SENTRY_MAX_EXTERNAL_SOURCEMAP_SIZE: + SENTRY_STATSD_ADDR: "${STATSD_ADDR:-}" volumes: - "sentry-data:/data" - "./sentry:/etc/sentry" @@ -96,8 +97,7 @@ x-snuba-defaults: &snuba_defaults SENTRY_EVENT_RETENTION_DAYS: # If you have statsd server, you can utilize that to monitor self-hosted Snuba containers. # To start, state these environment variables below on your `.env.` file and adjust the options as needed. - SNUBA_STATSD_HOST: # Example value: "100.100.123.123". Must be an IP address, not domain name - SNUBA_STATSD_PORT: # Example value: 8125 + SNUBA_STATSD_ADDR: "${STATSD_ADDR:-}" services: smtp: <<: *restart_policy @@ -466,6 +466,8 @@ services: symbolicator: <<: *restart_policy image: "$SYMBOLICATOR_IMAGE" + environment: + SYMBOLICATOR_STATSD_ADDR: ${STATSD_ADDR:-127.0.0.1:8125} command: run -c /etc/symbolicator/config.yml volumes: - "sentry-symbolicator:/data" @@ -700,6 +702,8 @@ services: relay: <<: *restart_policy image: "$RELAY_IMAGE" + environment: + RELAY_STATSD_ADDR: ${STATSD_ADDR:-127.0.0.1:8125} volumes: - type: bind read_only: true @@ -726,6 +730,7 @@ services: TASKBROKER_KAFKA_CLUSTER: "kafka:9092" TASKBROKER_KAFKA_DEADLETTER_CLUSTER: "kafka:9092" TASKBROKER_DB_PATH: "/opt/sqlite/taskbroker-activations.sqlite" + TASKBROKER_STATSD_ADDR: ${STATSD_ADDR:-127.0.0.1:8125} volumes: - sentry-taskbroker:/opt/sqlite depends_on: @@ -794,6 +799,7 @@ services: # Separated by commas. Leaving this unset will default to the systems dns # resolver. #UPTIME_CHECKER_HTTP_CHECKER_DNS_NAMESERVERS: "8.8.8.8,8.8.4.4" + UPTIME_CHECKER_STATSD_ADDR: ${STATSD_ADDR:-127.0.0.1:8125} depends_on: kafka: <<: *depends_on-healthy diff --git a/relay/config.example.yml b/relay/config.example.yml index 06c7307..007f813 100644 --- a/relay/config.example.yml +++ b/relay/config.example.yml @@ -27,9 +27,9 @@ processing: # If you have statsd server, you can utilize that to monitor self-hosted Relay. # To start, uncomment the following `metrics` section and adjust the options as needed. # -# metrics: -# statsd: "100.100.123.123:8125" # It is recommended to use IP address instead of domain name -# prefix: "sentry.relay" # Adjust this to your needs, default is "sentry.relay" +metrics: + statsd: "${RELAY_STATSD_ADDR}" + prefix: "sentry.relay" # Adjust this to your needs, default is "sentry.relay" # sample_rate: 1.0 # Adjust this to your needs, default is 1.0 # # `periodic_secs` is the interval for periodic metrics emitted from Relay. # # Setting it to `0` seconds disables the periodic metrics. diff --git a/sentry/sentry.conf.example.py b/sentry/sentry.conf.example.py index f6f2b65..26a3910 100644 --- a/sentry/sentry.conf.example.py +++ b/sentry/sentry.conf.example.py @@ -521,10 +521,14 @@ JS_SDK_LOADER_DEFAULT_SDK_URL = "https://browser.sentry-cdn.com/%s/bundle%s.min. # # To start, uncomment the following line and adjust the options as needed. -# SENTRY_METRICS_BACKEND = 'sentry.metrics.statsd.StatsdMetricsBackend' -# SENTRY_METRICS_OPTIONS: dict[str, Any] = { -# 'host': '100.100.123.123', # It is recommended to use IP address instead of domain name -# 'port': 8125, -# } +SENTRY_STATSD_ADDR = env("SENTRY_STATSD_ADDR") +if SENTRY_STATSD_ADDR: + host, _, port = SENTRY_STATSD_ADDR.partition(":") + port = int(port or 8125) + SENTRY_METRICS_BACKEND = 'sentry.metrics.statsd.StatsdMetricsBackend' + SENTRY_METRICS_OPTIONS: dict[str, Any] = { + 'host': host, + 'port': port, + } # SENTRY_METRICS_SAMPLE_RATE = 1.0 # Adjust this to your needs, default is 1.0 # SENTRY_METRICS_PREFIX = "sentry." # Adjust this to your needs, default is "sentry." diff --git a/symbolicator/config.example.yml b/symbolicator/config.example.yml index de716de..f0da86d 100644 --- a/symbolicator/config.example.yml +++ b/symbolicator/config.example.yml @@ -3,13 +3,10 @@ cache_dir: "/data" bind: "0.0.0.0:3021" logging: level: "warn" -metrics: - statsd: null + sentry_dsn: null # TODO: Automatically fill this with the internal project DSN # If you have statsd server, you can utilize that to monitor self-hosted Symbolicator. -# To start, uncomment the following line and adjust the options as needed. -# -# metrics: -# statsd: "100.100.123.123:8125" # It is recommended to use IP address instead of domain name -# prefix: "sentry.symbolicator" # Adjust this to your needs, default is "symbolicator" +metrics: + statsd: "${SYMBOLICATOR_STATSD_ADDR}" # It is recommended to use IP address instead of domain name + prefix: "sentry.symbolicator" # Adjust this to your needs, default is "symbolicator"