Question
Why does my server name show up as localhost in the Contrast UI?
Answer
Contrast agents attempt to obtain the name of the server name primarily by using operating system commands to determine the hostname set. In cases where we cannot obtain the server name, we set the value to localhost.
Contrast agents allow the customization of the server name to override the obtained value.
If you're using a contrast_security.yaml file:
server:
name: foo
If you're using environment variables:
CONTRAST__SERVER__NAME=foo
If you're using JVM arguments:
-Dcontrast.server.name=foo
If you're using a web.config file for .NET agents:
<configuration> <appSettings> <add key="contrast.server.name" value="foo" /> </appSettings> <system.web> ...
In addition to configuring the server name, the following options are also available for configuring the server metadata:
# ==============================================================================
# server
# Use the settings in this section to set metadata for the server
# hosting this agent. Contrast recognizes common, supported server
# names, paths, types and environments. Doing this may require a new
# server or license, and it may affect functionality of some features.
# ==============================================================================
# server:
# Override the reported server name.
# name: localhost
# Override the reported server path.
# path: NEEDS_TO_BE_SET
# Override the reported server type.
# type: NEEDS_TO_BE_SET
# Set the environment directly to override the default set
# by the Contrast UI. This allows the user to configure the
# environment dynamically at startup rather than manually
# updating the Server in the Contrast UI themselves afterwards.
#
# Valid values include `QA`, `PRODUCTION` and `DEVELOPMENT`.
# For example, `PRODUCTION` registers this Server as
# running in a `PRODUCTION` environment, regardless of the
# organization's default environment in the Contrast UI.
#
# environment: NEEDS_TO_BE_SET
# Apply a list of labels to the server. Labels
# must be formatted as a comma-delimited list.
# Example - `label1,label2,label3`
#
# tags: NEEDS_TO_BE_SET
You can view other YAML configuration options here: Java YAML configuration template.
There is an example template for each agent language on our docs site here as well.