08-02-2023, 04:39 PM
**Spring Boot Actuator** provides several **endpoints** to **monitor** an **application** as:
/metrics
/beans
/health
...
Checking the endpoints with:
curl
results in:
{"counter.status.200.env":1,"counter.status.200.health":1,"counter.status.200.info":2,"counter.status.200.metrics":2,"gauge.response.env":5.0,"gauge.response.health":22.0,"gauge.response.info":1.0,"gauge.response.metrics":1.0,"mem":1030144,"mem.free":56118,"processors":8,"uptime":5108095,"instance.uptime":5102906,"heap.committed":1030144,"heap.init":262144,"heap.used":974031,"heap":3728384,"threads.peak":81,"threads.daemon":21,"threads":77,"classes":8854,"classes.loaded":8860,"classes.unloaded":6,"gc.ps_scavenge.count":119,"gc.ps_scavenge.time":7223,"gc.ps_marksweep.count":12,"gc.ps_marksweep.time":17573}
This is **fine for machine consumption** but **hard to read** by **humans**.
I'd like to **format** (i.e. pretty print) the **JSON** output of the **Spring Boot Actuator** endpoints to make them easier to read by operations personel.
Something like:
{
"counter.status.200.env":1,
"counter.status.200.health":1,
"counter.status.200.info":2,
"counter.status.200.metrics":2,
"gauge.response.env":5.0,
"gauge.response.health":22.0,
"gauge.response.info":1.0,
...
}
I tried setting
http.mappers.json-pretty-print=true
but this setting didn't affect the Actuator output.
Is there a **configuration** to **enable pretty print** of the **Spring Boot Actuator JSON** output?
**UPDATE:**
The [official sample][1] works for me.
It's important to follow the comments from @DaveSyer: the property to set is
http.mappers.jsonPrettyPrint=true
Investigation is still under way.
In the meantime I use the the json pretty print **command line** as **workaround**:
Install jsonpp (e.g. for OS X):
brew install jsonpp
Then pipe the curl output trough jsonpp which formats the json file on the fly:
curl
Results in:
{
"counter.status.200.env": 1,
"counter.status.200.health": 1,
"counter.status.200.info": 2,
"counter.status.200.metrics": 2,
...
}
[1]:
/metrics
/beans
/health
...
Checking the endpoints with:
curl
[To see links please register here]
results in:
{"counter.status.200.env":1,"counter.status.200.health":1,"counter.status.200.info":2,"counter.status.200.metrics":2,"gauge.response.env":5.0,"gauge.response.health":22.0,"gauge.response.info":1.0,"gauge.response.metrics":1.0,"mem":1030144,"mem.free":56118,"processors":8,"uptime":5108095,"instance.uptime":5102906,"heap.committed":1030144,"heap.init":262144,"heap.used":974031,"heap":3728384,"threads.peak":81,"threads.daemon":21,"threads":77,"classes":8854,"classes.loaded":8860,"classes.unloaded":6,"gc.ps_scavenge.count":119,"gc.ps_scavenge.time":7223,"gc.ps_marksweep.count":12,"gc.ps_marksweep.time":17573}
This is **fine for machine consumption** but **hard to read** by **humans**.
I'd like to **format** (i.e. pretty print) the **JSON** output of the **Spring Boot Actuator** endpoints to make them easier to read by operations personel.
Something like:
{
"counter.status.200.env":1,
"counter.status.200.health":1,
"counter.status.200.info":2,
"counter.status.200.metrics":2,
"gauge.response.env":5.0,
"gauge.response.health":22.0,
"gauge.response.info":1.0,
...
}
I tried setting
http.mappers.json-pretty-print=true
but this setting didn't affect the Actuator output.
Is there a **configuration** to **enable pretty print** of the **Spring Boot Actuator JSON** output?
**UPDATE:**
The [official sample][1] works for me.
It's important to follow the comments from @DaveSyer: the property to set is
http.mappers.jsonPrettyPrint=true
Investigation is still under way.
In the meantime I use the the json pretty print **command line** as **workaround**:
Install jsonpp (e.g. for OS X):
brew install jsonpp
Then pipe the curl output trough jsonpp which formats the json file on the fly:
curl
[To see links please register here]
| jsonppResults in:
{
"counter.status.200.env": 1,
"counter.status.200.health": 1,
"counter.status.200.info": 2,
"counter.status.200.metrics": 2,
...
}
[1]:
[To see links please register here]