[Jolokia module] Get value from inner path (substructure)

The Jolokia documentation (https://jolokia.org/reference/html/protocol.html#paths) shows that is possibile to retrieve value from "An inner path points to a certain substructure (plain value, array, hash) within a a complex JSON value".

With a GET the sintax to read that value is:
<base-url>/read/<mbean name>/<attribute name>/<inner path>

With a POST the sintax to read that value is:
<base-url> { "attribute": "<attribute name>", "mbean": "<mbean name>", "path": "<inner path>", "type": "read" }

In WebSphere AS I put this JVM custom property:
name: jvm.name
value: <jvm_name>

So if I call jolokia with :
curl "http://localhost:9999/jolokia/read/java.lang:type=Runtime/SystemProperties/jvm.name"
or:
curl -d '{"type":"read","mbean":"java.lang:type=Runtime","attribute":"SystemProperties","path":"jvm.name"}' -H "Content-Type: application/json" -X POST "http://localhost:9999/jolokia"
I obtain:
{"request":{"path":"jvm.name","mbean":"java.lang:type=Runtime","attribute":"SystemProperties","type":"read"},"value":"<jvm_name>","timestamp":<timestamp>,"status":200}

But if in jolokia.yml I write:
- module: jolokia
metricsets: ["jmx"]
enabled: true
hosts: ["localhost:9999/jolokia/"]
namespace: "metrics"
http_method: "POST"
jmx.mappings:
- mbean: 'java.lang:type=Runtime'
attributes:
- attr: SystemProperties
path: jvm.name
field: jvm.name

I obtain the error:
elasticsearch/client.go:535 Cannot index event publisher

And if in jolokia.yml I write:
[...]
- mbean: 'java.lang:type=Runtime'
attributes:
- attr: 'SystemProperties/jvm.name'
field: jvm.name

I obtain the error:
ERROR: No such attribute: SystemProperties/jvm.name (class javax.management.AttributeNotFoundException)

The same error appear if I write:
mbean: 'java.lang:type=Runtime/SystemProperties'
or:
- attr: 'SystemProperties:jvm.name'

Which is the correct way to get value from inner path?

Thanks a lot

I'm not very familiar with the jolokia module hmm just curious have you tried this config?

[...]
- mbean: 'java.lang:type=Runtime'
attributes:
  - attr: SystemProperties
    field: jvm.name

Hi @Kaiyan_Sheng,
the code you proposed does not just get the value of custom property jvm.name .
With it all the content of the SystemProperties is taken, namely:

[...]
"value": {
"FFDCLogDirectory": "/opt/IBM/WebSphere/AppServer/profiles/[...]",
"FFDCProcessLevel": "4",
"as400.suffissoMembro": "U1",
"awt.toolkit": "sun.awt.X11.XToolkit",
"client.encoding.override": "UTF-8",
"com.ibm.CORBA.ORBPropertyFilePath": "/opt/IBM/WebSphere/AppServer/properties",
"com.ibm.IPC.requestTimeout": "600",
"com.ibm.SOAP.requestTimeout": "600",
"com.ibm.as400.access.SecureAS400.useSslight": "true",
"com.ibm.cpu.endian": "little",
"com.ibm.ejs.jts.processType": "server",
"com.ibm.itp.location": "/opt/IBM/WebSphere/AppServer/bin",
"com.ibm.jcl.checkClassPath": "",
"com.ibm.jsse2.checkRevocation": "false",
[...]
"jvm.name": "<jvm_name>",
[...]

@jsoriano Do you know if we support the inner path for jolokia?

Hey, I think that we don't support it, there is an open issue about that: https://github.com/elastic/beats/issues/8964

As a possible workaround the whole object could be collected and unwanted fields could be dropped using processors.

Thank you!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.