Compare commits

...
4 changed files with 44 additions and 0 deletions
+11
View File
@@ -266,3 +266,14 @@ AZURE_APP_SECRET=
# Set to true if you want to remove stale contact inboxes
# contact_inboxes with no conversation older than 90 days will be removed
# REMOVE_STALE_CONTACT_INBOX_JOB_STATUS=false
# Sidekiq CloudWatch Metrics Configuration
# Enable CloudWatch metrics collection for Sidekiq (Chatwoot Cloud only)
# Uses EC2 instance role for AWS credentials - no additional AWS config needed
# ENABLE_SIDEKIQ_CLOUDWATCH=true
# CloudWatch namespace for Sidekiq metrics (default: Chatwoot/Sidekiq)
# SIDEKIQ_CLOUDWATCH_NAMESPACE=Chatwoot/Sidekiq
# Metrics publishing interval in seconds (default: 60)
# SIDEKIQ_CLOUDWATCH_INTERVAL=60
+1
View File
@@ -126,6 +126,7 @@ gem 'sentry-sidekiq', '>= 5.19.0', require: false
##-- background job processing --##
gem 'sidekiq', '>= 7.3.1'
gem 'sidekiq-cloudwatchmetrics'
# We want cron jobs
gem 'sidekiq-cron', '>= 1.12.0'
# for sidekiq healthcheck
+7
View File
@@ -138,6 +138,9 @@ GEM
activesupport (>= 5.0, < 7.7)
aws-eventstream (1.2.0)
aws-partitions (1.760.0)
aws-sdk-cloudwatch (1.73.0)
aws-sdk-core (~> 3, >= 3.165.0)
aws-sigv4 (~> 1.1)
aws-sdk-core (3.171.1)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.651.0)
@@ -858,6 +861,9 @@ GEM
logger
rack (>= 2.2.4)
redis-client (>= 0.22.2)
sidekiq-cloudwatchmetrics (2.9.0)
aws-sdk-cloudwatch (~> 1.6)
sidekiq (>= 5.0, < 9.0)
sidekiq-cron (1.12.0)
fugit (~> 1.8)
globalid (>= 1.0.1)
@@ -1099,6 +1105,7 @@ DEPENDENCIES
shopify_api
shoulda-matchers
sidekiq (>= 7.3.1)
sidekiq-cloudwatchmetrics
sidekiq-cron (>= 1.12.0)
sidekiq_alive
simplecov (>= 0.21)
+25
View File
@@ -15,6 +15,31 @@ Sidekiq.configure_server do |config|
config[:skip_default_job_logging] = true
config.logger.level = Logger.const_get(ENV.fetch('LOG_LEVEL', 'info').upcase.to_s)
end
# Configure Sidekiq CloudWatch metrics in the server process
if ENV['ENABLE_SIDEKIQ_CLOUDWATCH'].present?
require 'sidekiq/cloudwatchmetrics'
Rails.logger.info '================================================'
Rails.logger.info 'Sidekiq::CloudWatchMetrics defined (Server Process)'
Rails.logger.info "ENV['ENABLE_SIDEKIQ_CLOUDWATCH'] #{ENV.fetch('ENABLE_SIDEKIQ_CLOUDWATCH', nil)}"
Rails.logger.info "ENV['SIDEKIQ_CLOUDWATCH_NAMESPACE'] #{ENV.fetch('SIDEKIQ_CLOUDWATCH_NAMESPACE', nil)}"
Rails.logger.info "ENV['SIDEKIQ_CLOUDWATCH_INTERVAL'] #{ENV.fetch('SIDEKIQ_CLOUDWATCH_INTERVAL', nil)}"
Rails.logger.info '================================================'
# Configure AWS CloudWatch client with explicit instance role credentials
cloudwatch_client = Aws::CloudWatch::Client.new(
region: ENV.fetch('AWS_REGION', 'us-east-1'),
credentials: Aws::InstanceProfileCredentials.new
)
# Enable Sidekiq CloudWatch metrics with the configured client
Sidekiq::CloudWatchMetrics.enable!(
namespace: ENV.fetch('SIDEKIQ_CLOUDWATCH_NAMESPACE', 'Chatwoot/Sidekiq'),
interval: ENV.fetch('SIDEKIQ_CLOUDWATCH_INTERVAL', '60').to_i,
client: cloudwatch_client
)
end
end
# https://github.com/ondrejbartas/sidekiq-cron