Skip to content

Commit 7a03e3f

Browse files
hmstepanekTimPansinolrafeei
committed
Update Python configuration settings
Co-authored-by: Tim Pansino <[email protected]> Co-authored-by: Lalleh Rafeei <[email protected]>
1 parent e31f784 commit 7a03e3f

File tree

1 file changed

+224
-2
lines changed

1 file changed

+224
-2
lines changed

src/content/docs/apm/agents/python-agent/configuration/python-agent-configuration.mdx

+224-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,44 @@ Here are detailed descriptions of each configuration method:
4949
OR
5050
* Set the `NEW_RELIC_CONFIG_FILE` environment variable. If you use the `newrelic-admin` wrapper script, you must use the environment variable because the wrapper script calls the agent automatically.
5151

52-
The configuration file uses a structure similar to Microsoft Windows `.ini` files. For more information, see the Python ConfigParser module's [file format documentation](http://docs.python.org/library/configparser.html).
52+
The agent supports two types of configuration files, older agents must use the `.ini` syntax while newer versions support `.toml` files as well.
53+
54+
<Collapser
55+
className="freq-link"
56+
id="agent-configuration-file-ini"
57+
title="`.ini` configuration file format"
58+
>
59+
The configuration file uses a structure similar to Microsoft Windows `.ini` files. For more information, see the Python ConfigParser module's [file format documentation](https://docs.python.org/3/library/configparser.html).
60+
61+
The basic structure should look like the following:
62+
63+
```ini
64+
[newrelic]
65+
license_key = <license key>
66+
app_name = Python Application
67+
```
68+
</Collapser>
69+
70+
<Collapser
71+
className="freq-link"
72+
id="agent-configuration-file-toml"
73+
title="`.toml` configuration file format"
74+
>
75+
<Callout variant="tip">
76+
Starting with Python 3.11 the newer `.toml` syntax for configuration was added to the [standard library](https://docs.python.org/3/library/tomllib.html). Agent version `10.3.0` added support for using this newer format.
77+
</Callout>
78+
The configuration file uses Tom's Obvious Minimal Language `.toml` files. For more information, see the [official file format documentation](https://toml.io/en/).
79+
80+
To use the `.toml` syntax, the configuration file's name must end with `.toml` to indicate the syntax type. The standard `pyproject.toml` may be used alongside configuration for other libraries, or you may use a more specific file like `newrelic.toml`.
81+
82+
The basic structure should look like the following:
83+
84+
```ini
85+
[tool.newrelic]
86+
license_key = <license key>
87+
app_name = Python Application
88+
```
89+
</Collapser>
5390

5491
<Callout variant="tip">
5592
A sample configuration file is included with the Python agent as `newrelic/newrelic.ini`. You can also generate one from the `newrelic-admin` script using the `generate-config` command, or download a copy from [our download repo](https://download.newrelic.com/python_agent/release/).
@@ -425,7 +462,7 @@ Here are detailed descriptions of each configuration method:
425462

426463
## Multiple environment configuration [#config-file-deployment-environments]
427464

428-
The agent reads its primary configuration from an agent config section called `newrelic`. You can provide overrides for specific deployment environments (for example, Development, Staging, Production) in additional sections. Preface these sections with `[newrelic:environment]`, where `environment` is replaced with the name of your environment.
465+
The agent reads its primary configuration from an agent config section called `newrelic`. You can provide overrides for specific deployment environments (for example, Development, Staging, Production) in additional sections. Preface these sections with `[newrelic:environment]` for `.ini` files, or `[tool.newrelic.env.environment]` for `.toml` files (where `environment` is replaced with the name of your environment).
429466

430467
To specify that the agent should use an environment-based configuration, use one of these methods:
431468

@@ -438,6 +475,12 @@ If no environment is specified, the agent will use the default settings as speci
438475

439476
The basic structure of the configuration file is:
440477

478+
479+
<Collapser
480+
className="freq-link"
481+
id="config-file-format-example-ini"
482+
title="`.ini` configuration file format"
483+
>
441484
```ini
442485
[newrelic]
443486
... default settings
@@ -451,6 +494,27 @@ The basic structure of the configuration file is:
451494
[newrelic:production]
452495
... override settings
453496
```
497+
</Collapser>
498+
499+
<Collapser
500+
className="freq-link"
501+
id="config-file-format-example-toml"
502+
title="`.toml` configuration file format"
503+
>
504+
```ini
505+
[tool.newrelic]
506+
... default settings
507+
508+
[tool.newrelic.env.development]
509+
... override settings
510+
511+
[tool.newrelic.env.staging]
512+
... override settings
513+
514+
[tool.newrelic.env.production]
515+
... override settings
516+
```
517+
</Collapser>
454518

455519
## General configuration settings [#general-settings]
456520

@@ -4166,6 +4230,164 @@ For some tips on configuring logs for the Python agent, see [Configure Python lo
41664230
</Callout>
41674231
</Collapser>
41684232

4233+
<Collapser
4234+
id="application_logging.forwarding.custom_attributes"
4235+
title="application_logging.forwarding.custom_attributes"
4236+
>
4237+
<table>
4238+
<tbody>
4239+
<tr>
4240+
<th>
4241+
Type
4242+
</th>
4243+
4244+
<td>
4245+
String
4246+
</td>
4247+
</tr>
4248+
4249+
<tr>
4250+
<th>
4251+
Default
4252+
</th>
4253+
4254+
<td>
4255+
(none)
4256+
</td>
4257+
</tr>
4258+
4259+
<tr>
4260+
<th>
4261+
[Set in](#options)
4262+
</th>
4263+
4264+
<td>
4265+
Config file, environment variable
4266+
</td>
4267+
</tr>
4268+
4269+
<tr>
4270+
<th>
4271+
[Environ variable](#environment-variables)
4272+
</th>
4273+
4274+
<td>
4275+
`NEW_RELIC_APPLICATION_LOGGING_FORWARDING_CUSTOM_ATTRIBUTES`
4276+
</td>
4277+
</tr>
4278+
</tbody>
4279+
</table>
4280+
4281+
A hash with key/value pairs to add as custom attributes to all log events forwarded to New Relic. The value must be formatted like: "key1:value1;key2:value2"
4282+
</Collapser>
4283+
4284+
<Collapser
4285+
id="application_logging.forwarding.labels.enabled"
4286+
title="application_logging.forwarding.labels.enabled"
4287+
>
4288+
<table>
4289+
<tbody>
4290+
<tr>
4291+
<th>
4292+
Type
4293+
</th>
4294+
4295+
<td>
4296+
Boolean
4297+
</td>
4298+
</tr>
4299+
4300+
<tr>
4301+
<th>
4302+
Default
4303+
</th>
4304+
4305+
<td>
4306+
`false`
4307+
</td>
4308+
</tr>
4309+
4310+
<tr>
4311+
<th>
4312+
[Set in](#options)
4313+
</th>
4314+
4315+
<td>
4316+
Config file, environment variable
4317+
</td>
4318+
</tr>
4319+
4320+
<tr>
4321+
<th>
4322+
[Environ variable](#environment-variables)
4323+
</th>
4324+
4325+
<td>
4326+
`NEW_RELIC_APPLICATION_LOGGING_FORWARDING_LABELS_ENABLED`
4327+
</td>
4328+
</tr>
4329+
</tbody>
4330+
</table>
4331+
4332+
Toggles whether the agent will add labels to log records for sending to New Relic.
4333+
</Collapser>
4334+
4335+
<Collapser
4336+
id="application_logging.forwarding.labels.exclude"
4337+
title="application_logging.forwarding.labels.exclude"
4338+
>
4339+
<table>
4340+
<tbody>
4341+
<tr>
4342+
<th>
4343+
Type
4344+
</th>
4345+
4346+
<td>
4347+
List of strings
4348+
</td>
4349+
</tr>
4350+
4351+
<tr>
4352+
<th>
4353+
Default
4354+
</th>
4355+
4356+
<td>
4357+
(none)
4358+
</td>
4359+
</tr>
4360+
4361+
<tr>
4362+
<th>
4363+
[Set in](#options)
4364+
</th>
4365+
4366+
<td>
4367+
Config file, environment variable
4368+
</td>
4369+
</tr>
4370+
4371+
<tr>
4372+
<th>
4373+
[Environ variable](#environment-variables)
4374+
</th>
4375+
4376+
<td>
4377+
`NEW_RELIC_APPLICATION_LOGGING_FORWARDING_LABELS_EXCLUDE`
4378+
</td>
4379+
</tr>
4380+
</tbody>
4381+
</table>
4382+
4383+
A case-insensitive list of label names to exclude when you enable including labels in logs. This attribute does not support wildcards or regex.
4384+
<Callout variant="important">
4385+
When adding labels as attributes, the agent prefixes the keys with `tags.`.
4386+
4387+
These prefixes are <b>NOT</b> included when matching against the exclude filtering rules.
4388+
</Callout>
4389+
</Collapser>
4390+
41694391
<Collapser
41704392
id="application_logging.forwarding.context_data.enabled"
41714393
title="application_logging.forwarding.context_data.enabled"

0 commit comments

Comments
 (0)