Skip to main content

Agent differences

This page lists the places where agent configuration differs.

Settings and sources

Difference

Agent support

What to do

Java system properties (-Dcontrast.*)

Java only

Other agents have no command line or system property source.

Use environment variables.

inventory.tags

Not supported by Node.js or Go

api.url has no default

Python and PHP

Set the URL, or use the agent token.

Setting both application.session_id and application.session_metadata

Java, Node.js, and Go don't start the agent

Set only one.

Environment variables for a few settings

PHP reads environment variables only for some settings, for example not assess.sampling.request_frequency or protect.stacktraces

Set these in the YAML file.

Hyphenated setting names, such as protect.rules.sql-injection.mode

Java and Go accept a hyphen or an underscore

Node.js needs an underscore

Python needs the hyphen

Most organizations set protect rules in the web interface instead.

server.environment

The Node.js agent doesn't start when the value isn't QA, PRODUCTION or DEVELOPMENT

Use one of the three values in upper case.

Where each agent looks for a YAML file

Every agent checks CONTRAST_CONFIG_PATH first, and then the following locations, in the order listed.

Tip

/etc/contrast/contrast_security.yaml is the one location that all agents read.

Agent

Locations, in order

Files used

Java

/etc/contrast/java/contrast_security.yaml, then /etc/contrast/contrast_security.yaml.

On Windows, %ProgramData%\Contrast\java\ and %ProgramData%\Contrast\.

The agent doesn't search the working directory. The contrast.config.path property comes before CONTRAST_CONFIG_PATH

Both files, combined setting by setting.

The Java folder file wins.

Node.js

The working directory.

Then /etc/contrast/node/ and /etc/contrast/.

Then ~/.config/contrast/node/ and ~/.config/contrast/.

On Windows, %ProgramData%\contrast\ and %USERPROFILE%\.config\contrast\

The first of the three locations that has a file.

Inside it, the node folder file and its parent folder file are combined and the node file wins.

A file in the working directory hides the others.

Python

The working directory, then ./settings, then /etc/contrast/python/, then /etc/contrast/.

On Windows, %ProgramData%\contrast\python\ and %ProgramData%\contrast\.

Each location accepts both .yaml and .yml.

All files found, combined setting by setting. The earlier location wins.

PHP

/etc/contrast/php/, then /etc/contrast/, then /etc/.

Each location accepts both .yaml and .yml.

The agent doesn't read the working directory, and warns if it finds a file there.

The first file found only.

Go

The working directory, then /etc/contrast/go/, then /etc/contrast/, then the contrast folder in your user configuration directory, then its go folder.

The user directory is $XDG_CONFIG_HOME or ~/.config on Linux and ~/Library/Preferences on macOS.

Go agents don't run on Windows.

The first file found only.

.NET

YAML syntax

  • The PHP agent reads only block style YAML. Don't start the file with ---, and don't use JSON, flow style, anchors or tabs. When it can't read the file, it ignores the logging settings in it.

  • The Python agent requires quote values that look like numbers or booleans. An unquoted 1.10 becomes 1.1 and an unquoted true becomes True.

Agent logs

The agent log shows the configuration the agent used. The default log name and location differ as follows:

Agent

Default log

What to look for

Java

~/.contrast/contrast.log

A line that starts current configuration at INFO level.

The console shows a Starting Contrast line.

Node.js

contrast.log in the working directory, and the console

An Agent configuration line at INFO level that lists the YAML files used.

The command npx -p @contrast/cli config-diagnostics <entrypoint> prints the effective configuration.

Python

contrast-agent.log in the working directory

Loading configuration file and Current Configuration lines at INFO level.

The command contrast-validate-config checks the configuration and the connection.

PHP

$HOME/.contrast/contrast_agent.log

The agent doesn't log which file it read.

Set agent.diagnostics.enable to true to write contrast_effective_config.json, which names the file and the source of each value.

Log levels must be in upper case.

Go

contrast_agent.log in the working directory

A finished line at INFO level that shows success and a session ID.

.NET

Flex Agent

N/A

Run contrast-flex config global list, or contrast-flex apps <ID> for a running process.

Kubernetes Operator

N/A

Run kubectl exec <pod> -- env to see the CONTRAST__ variables on the pod.