Configuration in Ruby

Sqreen settings can be adjusted according to your needs. This section lists the possible configuration options you have with the Sqreen Ruby agent.

Configuration sources

The Sqreen agent reads its configuration from different places. This is the order of precedence:

  • Environment variables
  • A sqreen.yml file
  • Default configuration options

The sqreen.yml file can be located in:

  • Your application config directory.
  • In a custom location set by SQREEN_CONFIG_FILE environment variable:

export SQREEN_CONFIG_FILE=/custom/path/sqreen.yml

Edit configuration file options

The Ruby agent configuration file sqreen.yml uses standard yaml format. As with Ruby on Rails, you can use ERB inside sqreen.yml.

The most important configuration option is the Sqreen token, used to identify the application on Sqreen.

YAML indentation

When you edit the config file, make sure you indent only with two spaces. If you do not indent correctly, the Sqreen agent throws an error at Startup ("Unable to parse configuration file")

Deploying Sqreen configuration

You must deploy the configuration file on the servers running Sqreen

Configuration variables

The SQREEN_TOKEN is required, the other settings are optional. Here are the settings you can change:

Variable name Role YAML key name Default value Allowed values
SQREEN_TOKEN The Sqreen token. This identifies the agent to Sqreen backend servers token Empty String
SQREEN_CONFIG_FILE Custom location for the YAML based config Empty String
SQREEN_LOG_LOCATION Specify a custom file to write Sqreen logs log_location log/sqreen.log String
SQREEN_REPORT_PERF Report overhead for each request in the log (WARN level) report_perf false (disabled) Boolean
SQREEN_REPORT_PERF_NR Report overhead for each request to NewRelic as custom transaction attributes report_perf_newrelic 0 (disabled) 0 (disabled), 1 (global overhead), 2 (report duration for each protection category)
SQREEN_IP_HEADER Specify the preferred request header for extracting the client IP address ip_header Empty a header name (case insensitive)
SQREEN_DISABLE Prevent the Sqreen agent from starting. Any value in this environment variable will disable Sqreen. disable false (Sqreen is enabled) Boolean
SQREEN_STRIP_SENSITIVE_DATA Remove sensitive data before sending them to Sqreen strip_sensitive_data true Boolean
SQREEN_STRIP_SENSITIVE_KEYS Comma separated list of keys to strip, refer to the dedicated section below for details strip_sensitive_keys Empty (use default values) (arbitrary)
SQREEN_STRIP_SENSITIVE_REGEX Regular expression used for value stripping, refer to the dedicated section below for details strip_sentitive_regex Empty (use default values) (arbitrary)
HTTP_PROXY, http_proxy HTTP proxy for the agent's reporting connection to Sqreen backend servers - - proxy URI (e.g. http://proxy:port )

Multiple Rails environments

The YAML configuration supports different section per Rails environment:

token: mysecrettoken #general configuration

    token:  mysecretproductiontoken # override general configuration

PII scrubbing

Unless you set strip_sensitive_data to false, the Sqreen gem redacts certain data prior to sending to Sqreen's servers. It redacts the values of key-value pairs where the key is listed in strip_sensitive_keys (in a case insensitive manner), and it also redacts any values, including array elements (but not keys) that fully match the strip_sensitive_regex configuration setting.

The default PII scrubbing values are listed in the PII Scrubbing section.

Changing strip_sensitive_keys or strip_sensitive_regex overrides the defaults. Therefore, you probably want to append your extra keys to the list of predefined keys and combine the default regular expression with your new one.