Agent configuration
Every Contrast agent needs some configuration before it reports to Contrast. At a minimum, the agent needs to know where to send data and how to authenticate. You can also name your application and server, add tags and metadata, and change how the agent behaves. This page explains how agent configuration works, the options you have for providing it, and the order to follow.
Configuration follows this order of precedence.
Note
An expired license or exceeding a license quota disables all agent behavior regardless of configuration.
How agent configuration works
An agent reads its configuration once, when it starts. For each setting, the agent uses the value from the highest source that provides one. A value from a higher source replaces the same setting from a lower source. This lets you set a value in a shared file and override it for a single application.
The agent doesn't read local configuration again while it runs, so restart the application after you change a setting.
These are the sources, listed from highest priority to lowest. The first source on the list applies:
Java system properties (for the Java agent only)
Environment variables
A
contrast_security.yamlfileSettings from the Contrast web interface. This is a small set, such as Assess and Protect modes, Protect rule modes, and the server environment.
Defaults built into the agent
A value that you set locally is never replaced by the web interface. For the full list and the exceptions, see Order of precedence.
How to provide configuration
Start with the simplest way and move to the next only when you need more:
Use the agent wizard. The wizard gives you the commands and values for your language and platform, including your agent token. For many applications this is all you need.
Add environment variables. Set the agent token and any other settings as environment variables.
Use a YAML file. When you have many settings, or want to share settings between applications on a server, put them in a
contrast_security.yamlfile. See YAML configuration, and use the Agent configuration editor to write it.
If you install with the Flex Agent or the Agent Operator, they provide the values for you:
Flex sets them as environment variables when each application process starts, and a Flex value replaces the application's own variable of the same name.
The Operator turns an
AgentConfigurationresource into environment variables on each pod, and a variable already set on the container wins over the Operator's value.
Configuration order
Follow these steps in order:
Get your agent token. The token is a single value that authenticates the agent. The wizard shows it for you. Otherwise, see Find the agent keys.
Choose how to provide configuration. Start with the wizard. If you need more control, use environment variables, and then a YAML file.
Set the required connection setting. Set the agent token.
Agents older than the versions listed in Find the agent keys need the Contrast URL, API key, service key, and user name instead. Without these values the agent doesn't report, and the application keeps running without it.
Name your application and server. Set the application name and the server name, and the server environment if it isn't Development. This makes the agent easy to recognize in Contrast. See Common agent settings.
Add optional settings. Add tags to applications, application metadata, and session metadata to organize and filter your data. See Common agent settings.
Start or restart the application. The agent reads its configuration at startup.
Verify the configuration. Confirm that the agent connected and used the values you set.
Adjust. Change a value, restart the application, and check again. If a setting seems to be ignored, a higher source is probably providing a different value. See Order of precedence and Resolve agent configuration conflicts.
Verify your configuration
Open the agent dashboard:
In Northstar: Select Administration on the left, and then select Agent management.
In Contrast: Select Administration at the top, and then select the Agent Management tab.
Select your agent to see its effective configuration and the source of each value.
If your agent isn't listed, check the agent log. The log name and location differ by agent. See Agent differences for details.
Note
Most agents don't warn about unknown or misspelled settings, and some agents stop silently when a value is invalid. Use true or false for yes or no values, and check spelling with the Agent configuration editor.