|
| 1 | +--- |
| 2 | +id: version-2.0.0-configuration-sources |
| 3 | +title: Configuration Sources |
| 4 | +original_id: configuration-sources |
| 5 | +--- |
| 6 | + |
| 7 | +inspectIT Ocelot tries to implement the zero-configuration approach but lets you externalize the configuration and influence every bit of its configuration if this is required. |
| 8 | +Internally it uses the Spring-based `PropertySource` order to allow overriding of configuration values. |
| 9 | +Configuration properties are considered in inspectIT Ocelot in the following order: |
| 10 | + |
| 11 | +1. [Java Agent Arguments](#java-agent-arguments) |
| 12 | +1. [Java System Properties](#java-system-properties) |
| 13 | +1. [OS environment Variables](#os-environment-variables) |
| 14 | +1. External Configuration Sources: |
| 15 | + * [File-based Configuration](configuration/external-configuration-sources.md#file-based-configuration) |
| 16 | +1. inspectIT Ocelot Defaults |
| 17 | + |
| 18 | +When an invalid configuration is given to inspectIT on startup, the agent will use a fallback configuration. |
| 19 | +In this fallback configuration, the agent is inactive with the exception of listening for configuration updates. |
| 20 | + |
| 21 | +When giving an invalid configuration through a runtime update to the agent, the agent will simply retain the previous configuration. |
| 22 | + |
| 23 | +## Available Configuration Sources |
| 24 | + |
| 25 | +### Java Agent Arguments |
| 26 | + |
| 27 | +You can pass a JSON object as string to the agent via its command line arguments. |
| 28 | +For example, to override the service name used to identify your application reporting the performance data, |
| 29 | +you can change the `inspectit.service-name` property as follows: |
| 30 | + |
| 31 | +```bash |
| 32 | +$ java -javaagent:/path/to/inspectit-ocelot-agent-2.0.0.jar="{ \"inspectit\": { \"service-name\": \"My Custom Service\" }}" -jar my-java-program.jar |
| 33 | +``` |
| 34 | + |
| 35 | +Note that you have to escape the quotes within your JSON string. On linux you can just use the more readable single quotes notation: |
| 36 | + |
| 37 | +```bash |
| 38 | +$ java -javaagent:/path/to/inspectit-ocelot-agent-2.0.0.jar='{ "inspectit": { "service-name": "My Custom Service" }}' -jar my-java-program.jar |
| 39 | +``` |
| 40 | + |
| 41 | +### Java System Properties |
| 42 | + |
| 43 | +You can pass any configuration property as the Java System property to the Java command that you use to start your Java application. |
| 44 | +Using this approach you can change the `inspectit.service-name` property as follows: |
| 45 | + |
| 46 | +```bash |
| 47 | +$ java -Dinspectit.service-name="My Custom Service" -javaagent:/path/to/inspectit-ocelot-agent-2.0.0.jar -jar my-java-program.jar |
| 48 | +``` |
| 49 | + |
| 50 | +### OS Environment Variables |
| 51 | + |
| 52 | +Similar to the Java System properties, inspectIT Ocelot will also consider all the available operating system environment variables. |
| 53 | +Due to the relaxed bindings, you can use upper case format, which is recommended when using system environment variables. |
| 54 | + |
| 55 | +```bash |
| 56 | +$ INSPECTIT_SERVICE_NAME="My Custom Service" java -javaagent:/path/to/inspectit-ocelot-agent-2.0.0.jar -jar my-java-program.jar |
| 57 | +``` |
| 58 | + |
| 59 | +## Relaxed Bindings |
| 60 | + |
| 61 | +Note that due to the Spring-powered configuration approach, the inspectIT Ocelot agent uses Spring support for relaxed bindings. |
| 62 | +This means that a property can be specified in different formats depending on the property source. |
| 63 | +As suggested by Spring, the allowed formats are: |
| 64 | + |
| 65 | +| Property | Note | |
| 66 | +| --- | --- | |
| 67 | +| `inspectit.service-name` | Kebab-case, which is recommended for use in `.properties` and `.yml` files. | |
| 68 | +| `inspectit.serviceName` | Standard camelCase syntax. | |
| 69 | +| `inspectit.service_name` | Underscore notation (snake_case), which is an alternative format for use in `.properties` and `.yml` files. | |
| 70 | +| `INSPECTIT_SERVICE_NAME` | UPPER_CASE format, which is recommended when using system environment variables. | |
| 71 | + |
| 72 | +The formats should be used in the following way, based on the type of property source: |
| 73 | + |
| 74 | +| Property Source | Format | |
| 75 | +| --- | --- | |
| 76 | +| System properties | Camel case, kebab case, or underscore notation. | |
| 77 | +| Environment Variables | Upper case format with the underscore as the delimiter. | |
| 78 | +| Property files (`.properties`) | Camel case, kebab case, or underscore notation. | |
| 79 | +| YAML files (`.yaml`, `.yml`) | Camel case, kebab case, or underscore notation. | |
| 80 | + |
| 81 | +## Environment Information |
| 82 | + |
| 83 | +Each agent stores the following information about its runtime environment: |
| 84 | + |
| 85 | +| Property | Note | |
| 86 | +| --- | --- | |
| 87 | +| `inspectit.env.agent-dir` | Resolves to the path where the agent-jar is stored. | |
| 88 | +| `inspectit.env.hostname` | The hostname where the agent is running. | |
| 89 | +| `inspectit.env.pid` | The process id of the JVM process. | |
| 90 | + |
| 91 | +They are used to define the default behavior when writing the configuration persistence file and will be sent |
| 92 | +as attributes to the configuration server when fetching the configuration. |
| 93 | + |
| 94 | +You can reference these properties within the configuration using e.g. `${inspectit.env.agent-dir}` |
| 95 | +as shown in the default configuration for |
| 96 | +[HTTP-based configuration](configuration/external-configuration-sources.md#http-based-configuration). |
| 97 | +Referencing every other property follows the same schema. |
0 commit comments