The infrastructure agent can be configured in a variety of ways. The default method is to edit the configuration variables in the newrelic-infra.yml file.
Always restart the agent after changing settings.
Integration config updates do not require an agent restart (hot-reload is supported).
Configuration methods and precedence
The default method to configure the infrastructure agent is the newrelic-infra.yml config file. You can override the config file by setting environment variables, which is ideal for containerized environments.
Environment variables override the config file. The config file overrides the agent defaults.
Here are detailed descriptions of each configuration method:
To configure the infrastructure agent, use the newrelic-infra.yml file. Its default location is:
To set an environment variable, use the variable name from the config file in all caps and prefix with NRIA_; for example, NRIA_LICENSE_KEY. In containerized environments, populate configuration properties such as license key and tags via environment variables.
You can also define environment variables in the configuration file with double curly brackets {{MY_ENV_VAR}}. For example:
license_key:{{MY_LICENSE_KEY}}
重要
Often the infrastructure agent runs as a system service in the host, managed globally (e.g. systemd for Linux, Windows Services, launchd for macOS, etc).
To apply configuration changes with environment variables in this setup, these environment variables need to be set and made visible to the isolated context where the infrastructure agent service is running.
The way of doing this is platform-dependent, check the documentation for your platform's service manager to know how to add environment variables to system services.
You can use environment variables to control config settings for on-host integrations, which can then be passed through to the infrastructure agent. Variables that can be used with each on-host integration are listed in the documentation for each integration, and can be set through one of the following methods.
The passthrough_environment option supports regex for variable names.
From inside the config file: Add an entry to the infrastructure config file to allow the agent to get the environment variables you've set.
passthrough_environment:
- HTTPS_PROXY
- HTTP_PROXY
- HTTP.*
- .*
From the command line: Use another environment variable to pass through these settings.
Each integration has a set of variables that can be overwritten by defining and passing an environment variable with the exact same name as the argument (for example, a PORT environment variable to replace the redis port argument).
You can also define environment variables in the integrations config file with the {{}} notation. For example:
integration_name: com.newrelic.redis
instances:
-name: redis-metrics
command: metrics
arguments:
hostname: localhost
port:6379
password:{{MY_REDIS_PASSWORD}}
ヒント
Make sure the newrelic-infra service has visibility to any custom environment variable defined in the host. Service managers such as systemd will not set all env vars by default and might need additional steps.
Explore configuration options
For a list of all settings you can configure, including definitions, defaults, and related environment variables, see Infrastructure configuration settings.
Configuration file structure
When editing agent or integration YAML config files:
Do not modify the casing of the configuration options: YAML keys are case sensitive.
Respect the indentation levels. All indentations are in similar increments, typically of two space characters. Data in the same section of the file must use the same level of indentation. Indent any sub-sections by two spaces (see examples in Custom attributes and Network interface filters).
YAML format distinguish between numbers and strings. Use quotes to parse configuration values as string.
A template of newrelic-infra.yml is available in the infrastructure agent repository. Use a validator to ensure the syntax is accurate before using the file with the infrastructure agent.
Configuration management tools
To install and manage the infrastructure agent with configuration management tools, see the docs for: