I'm trying to monitor the JDBC pools of some Java apps using Jolokia. I can get the full list of all attributes for the JDBC pools using:
# curl -k http://127.0.0.1:50147/jolokia/read/'Catalina:type=DataSource,class=javax.sql.DataSource,connectionpool=connections,context=*,host=*,name=*' | python -m json.tool
{
"request": {
"mbean": "Catalina:class=javax.sql.DataSource,connectionpool=connections,context=*,host=*,name=*,type=DataSource",
"type": "read"
},
"status": 200,
"timestamp": 1696324668,
"value": {
"Catalina:class=javax.sql.DataSource,connectionpool=connections,context=/XXXXXX,host=localhost,name=\"jdbc/ZZZZZZ\",type=DataSource": {
"AbandonedConfig": false,
"BlockWhenExhausted": true,
"BorrowedCount": 739850,
"Closed": false,
"CreatedCount": 36,
·
·
·
But now I want to get only the maxIdle attribute (for instance) of just one JDBC pool and only get an HTTP 400 error code:
# curl -k http://127.0.0.1:50147/jolokia/read/'Catalina:class=javax.sql.DataSource,connectionpool=connections,context=/XXXXXX,host=localhost,name=\"jdbc/ZZZZZZ\",type=DataSource"/maxIdle' -v
* About to connect() to 127.0.0.1 port 50147 (#0)
* Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 50147 (#0)
> GET /jolokia/read/Catalina:class=javax.sql.DataSource,connectionpool=connections,context=/XXXXXX,host=localhost,name=\"jdbc/ZZZZZZ\",type=DataSource"/maxIdle HTTP/1.1
> User-Agent: curl/7.29.0
> Host: 127.0.0.1:50147
> Accept: */*
>
< HTTP/1.1 400
< Transfer-Encoding: chunked
< Date: Tue, 03 Oct 2023 09:20:59 GMT
< Connection: close
<
* Closing connection 0
I tried variations -- rearranging keywords, removing quotes and backslash... but only get 400.
Other values are successfully retrieved:
# curl -k http://127.0.0.1:50147/jolokia/read/'java.lang:type=Runtime/SystemProperties/java.version'
{"request":{"path":"java.version","mbean":"java.lang:type=Runtime","attribute":"SystemProperties","type":"read"},"value":"1.8.0_131","timestamp":1696325283,"status":200}
What am I doing wrong?
Best regards
i had a similar problem and looks like you're not using the right escaping:
Take a look at this doc page:
https://jolokia.org/reference/html/protocol.html#escape-rules
escaping / with ! helped me to get the metric i needed.