Open aimtsou opened 5 years ago
:+1:
Related link for implementing https://jolokia.org/reference/html/protocol.html#exec
@aimtsou sorry this hasn't been implemented yet, are you still interested in this feature?
Hi @sspaink,
Thank you for coming back, yes I am still interested to have it if possible.
@aimtsou what is the format of the response? Is this something that follows a general layout or is this different for each individual operation?
Good afternoon,
Although I do not have access anymore to the apps since I have changed job for this feature I would say we follow a general layout.
@aimtsou thanks for reaching out! I'm not sure how that "general layout" looks like! For the current queries, the responses follow a known pattern and thus we can easily parse the response into a metric. Do the operations also follow the same pattern/structure in their response?
Hi @srebhan, I knew you would ask that :D
So my idea is to have something custom but well defined. For example, we will have a custom endpoint and the metric from the MBean it should have a format:
ie: http://localhost:10162/jolokia/exec/org.springframework.boot:type=Endpoint,name=Health/health/ | python -m json.tool For that custom MBean I would expect either:
Consequently, you will run the MBean over all the custom layouts, which should most probably be a boolean, one numeric we could output long and maybe one as a string, if someone wants to display something as a table. Extra would be all of them to have an extra description field.
If you have any examples of the pattern we can elaborate more.
Can you please provide one or two (redacted) examples of responses?
API docs: https://jolokia.org/reference/html/manual/protocol/exec.html
Response headers when using curl:
< HTTP/1.1 200 OK
< Pragma: no-cache
< Date: Mon, 17 Jun 2024 20:04:15 GMT
< Transfer-encoding: chunked
< Content-type: text/plain; charset=utf-8
< Expires: Mon, 17 Jun 2024 19:04:15 GMT
< Cache-control: no-cache
(JSON response but with "text/plain" Content-Type)
Empty (null) response:
{
"request": {
"mbean": "my.org.name:name=inbound",
"type": "exec",
"operation": "healthCheck"
},
"value": null,
"timestamp": 1718654655,
"status": 200
}
Simple response (http://localhost:8989/jolokia/exec/java.lang:type=Threading/getThreadCpuTime(long)/2
):
{
"request": {
"mbean": "java.lang:type=Threading",
"arguments": [
"2"
],
"type": "exec",
"operation": "getThreadCpuTime(long)"
},
"value": 88297297,
"timestamp": 1718655650,
"status": 200
}
Complex response (http://localhost:8989/jolokia/exec/java.lang:type=Threading/getThreadInfo(long)/2
):
{
"request": {
"mbean": "java.lang:type=Threading",
"arguments": [
"2"
],
"type": "exec",
"operation": "getThreadInfo(long)"
},
"value": {
"waitedCount": 0,
"lockOwnerId": -1,
"lockedMonitors": [],
"waitedTime": -1,
"blockedCount": 2,
"threadState": "RUNNABLE",
"inNative": false,
"priority": 10,
"suspended": false,
"threadName": "Reference Handler",
"daemon": true,
"lockInfo": null,
"threadId": 2,
"stackTrace": [],
"blockedTime": -1,
"lockName": null,
"lockOwnerName": null,
"lockedSynchronizers": []
},
"timestamp": 1718655489,
"status": 200
}
It can also return arrays, e.g. "value": [1,2,3]
.
Error (http://localhost:8989/jolokia/exec/java.lang:type=Threading/getThreadUserTime
), returned as "HTTP/1.1 200 OK":
{
"request": {
"mbean": "java.lang:type=Threading",
"type": "exec",
"operation": "getThreadUserTime"
},
"stacktrace": "java.lang.IllegalArgumentException: Operation getThreadUserTime on MBean java.lang:type=Threading is overloaded. Signatures found: ([J),(long). Use a signature when specifying the operation.\n\tat org.jolokia.handler.ExecHandler.extractOperationTypes(ExecHandler.java:139)\n\tat org.jolokia.handler.ExecHandler.doHandleRequest(ExecHandler.java:84)\n\tat org.jolokia.handler.ExecHandler.doHandleRequest(ExecHandler.java:40)\n\tat org.jolokia.handler.JsonRequestHandler.handleRequest(JsonRequestHandler.java:89)\n\tat org.jolokia.backend.MBeanServerExecutorLocal.handleRequest(MBeanServerExecutorLocal.java:109)\n\tat org.jolokia.backend.MBeanServerHandler.dispatchRequest(MBeanServerHandler.java:161)\n\tat org.jolokia.backend.LocalRequestDispatcher.dispatchRequest(LocalRequestDispatcher.java:99)\n\tat org.jolokia.backend.BackendManager.callRequestDispatcher(BackendManager.java:429)\n\tat org.jolokia.backend.BackendManager.handleRequest(BackendManager.java:158)\n\tat org.jolokia.http.HttpRequestHandler.executeRequest(HttpRequestHandler.java:197)\n\tat org.jolokia.http.HttpRequestHandler.handleGetRequest(HttpRequestHandler.java:86)\n\tat org.jolokia.jvmagent.handler.JolokiaHttpHandler.executeGetRequest(JolokiaHttpHandler.java:278)\n\tat org.jolokia.jvmagent.handler.JolokiaHttpHandler.doHandle(JolokiaHttpHandler.java:235)\n\tat org.jolokia.jvmagent.handler.JolokiaHttpHandler.handle(JolokiaHttpHandler.java:180)\n\tat jdk.httpserver/com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:77)\n\tat jdk.httpserver/sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:82)\n\tat jdk.httpserver/com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:80)\n\tat jdk.httpserver/sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:692)\n\tat jdk.httpserver/com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:77)\n\tat jdk.httpserver/sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:664)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base/java.lang.Thread.run(Thread.java:829)\n",
"error_type": "java.lang.IllegalArgumentException",
"error": "java.lang.IllegalArgumentException : Operation getThreadUserTime on MBean java.lang:type=Threading is overloaded. Signatures found: ([J),(long). Use a signature when specifying the operation.",
"status": 400
}
Feature Request
Besides reading attributes the jolokia2 agent should be able to invoke operations from custom Mbeans through the JMX.
Proposal:
We would like to see operations to be captured from invoked actions
Current behavior:
Current behaviour supports only read requests and attributes ie: curl http://localhost:10012/jolokia/read/java.lang:type=Memory | python -m json.tool
Desired behavior:
I would like to have also operations supported for custom Mbeans(for our applications) created in Spring.boot. An example is: http://localhost:10162/jolokia/exec/org.springframework.boot:type=Endpoint,name=Health/health/ | python -m json.tool While I can see the result in command line I cannot capture it with telegraf