The Spring Boot Actuator /env endpoint lets you inspect the properties available to a running application. A GET request to /actuator/env returns active profiles and properties grouped by source, including values and their origins. section 15.2.2
Listing 15.1 The results from the /env endpoint
$ curl localhost:8080/actuator/env
{
"activeProfiles": [
"development"
],
"propertySources": [
...
{
"name": "systemEnvironment",
"properties": {
"PATH": {
"value": "/usr/bin:/bin:/usr/sbin:/sbin",
"origin": "System Environment Property \"PATH\""
},
...
"HOME": {
"value": "/Users/habuma",
"origin": "System Environment Property \"HOME\""
}
}
},
{
"name": "applicationConfig: [classpath:/application.yml]",
"properties": {
"spring.application.name": {
"value": "ingredient-service",
"origin": "class path resource [application.yml]:3:11"
},
"server.port": {
"value": 8080,
"origin": "class path resource [application.yml]:9:9"
},
...
}
},
...
]
}
A curl request shows the active development profile alongside properties from the system environment and application.yml. section 15.2.2
To investigate one setting, append its name to the path—for example, GET /actuator/env/server.port. The response identifies the selected value and shows where that property appears among the sources. In the example, an environment variable supplies 8080 while application.yml supplies 0. section 15.2.2
$ curl localhost:8080/actuator/env/server.port
{
"property": {
"source": "systemEnvironment", "value": "8080"
},
"activeProfiles": [ "development" ],
"propertySources": [
{ "name": "server.ports" },
{ "name": "mongo.ports" },
{ "name": "systemProperties" },
{ "name": "systemEnvironment",
"property": {
"value": "8080",
"origin": "System Environment Property \"SERVER_PORT\""
}
},
{ "name": "random" },
{ "name": "applicationConfig: [classpath:/application.yml]",
"property": {
"value": 0,
"origin": "class path resource [application.yml]:9:9"
}
},
{ "name": "springCloudClientHostInfo" },
{ "name": "refresh" },
{ "name": "defaultProperties" },
{ "name": "Management Server" }
]
}
Compare the selected server.port value with the values reported by individual property sources. section 15.2.2
The endpoint can also change configuration while the application runs. POST a JSON object containing name and value to /actuator/env to set or override a property; DELETE /actuator/env removes the override shown in the example. Expose Actuator web endpoints selectively with management.endpoints.web.exposure.include and management.endpoints.web.exposure.exclude, and secure them with Spring Security when appropriate. section 15.2.2 section 15.5
$ curl localhost:8080/actuator/env \
-d'{"name":"tacocloud.discount.code","value":"TACOS1234"}' \
-H "Content-type: application/json"
{"tacocloud.discount.code":"TACOS1234"}
The POST example sets tacocloud.discount.code to TACOS1234 and returns the new value. section 15.2.2
$ curl localhost:8080/actuator/env -X DELETE
{"tacocloud.discount.code":"TACOS1234"}
The DELETE example removes the value set by the preceding request. section 15.2.2
For a visual alternative, Spring Boot Admin’s Environment screen displays these properties, filters them by name or value, and provides a form for setting or overriding them. section 16.2.3
