You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/apm/agents/python-agent/configuration/python-agent-configuration.mdx
+224-2
Original file line number
Diff line number
Diff line change
@@ -49,7 +49,44 @@ Here are detailed descriptions of each configuration method:
49
49
OR
50
50
* 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.
51
51
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
+
<Calloutvariant="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>
53
90
54
91
<Calloutvariant="tip">
55
92
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:
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).
429
466
430
467
To specify that the agent should use an environment-based configuration, use one of these methods:
431
468
@@ -438,6 +475,12 @@ If no environment is specified, the agent will use the default settings as speci
438
475
439
476
The basic structure of the configuration file is:
440
477
478
+
479
+
<Collapser
480
+
className="freq-link"
481
+
id="config-file-format-example-ini"
482
+
title="`.ini` configuration file format"
483
+
>
441
484
```ini
442
485
[newrelic]
443
486
... default settings
@@ -451,6 +494,27 @@ The basic structure of the configuration file is:
451
494
[newrelic:production]
452
495
... override settings
453
496
```
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>
454
518
455
519
## General configuration settings [#general-settings]
456
520
@@ -4166,6 +4230,164 @@ For some tips on configuring logs for the Python agent, see [Configure Python lo
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"
0 commit comments