Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Neo4j: Accessing JMX beans via HTTP

DZone's Guide to

Neo4j: Accessing JMX beans via HTTP

· Java Zone ·
Free Resource

Verify, standardize, and correct the Big 4 + more– name, email, phone and global addresses – try our Data Quality APIs now at Melissa Developer Portal!

One of the additional features that Neo4j enterprise provides is access to various JMX properties which describe various aspects of the database.

These would typically be accessed by using jConsole or similar but some monitoring tools aren’t able to use the JMX hook and a HTTP interface would work better.

Luckily Neo4j server does expose the JMX beans and we can get a list of URIs to query by hitting the following URI:

$ curl -H "Content-Type:application/json" http://localhost:7474/db/manage/server/jmx/
{
"resources" : {
"kernelquery" : "http://localhost:7474/db/manage/server/jmx/kernelquery",
"bean" : "http://localhost:7474/db/manage/server/jmx/domain/{domain}/{objectName}",
"query" : "http://localhost:7474/db/manage/server/jmx/query",
"domains" : "http://localhost:7474/db/manage/server/jmx/domain",
"domain" : "http://localhost:7474/db/manage/server/jmx/domain/{domain}"
}
}

If we want to get the output for all JMX beans we can hit the following URI:

$ curl -H "Content-Type:application/json" http://localhost:7474/db/manage/server/jmx/domain/*/*
// cut for verbosity
...
{
"description" : "Estimates of the numbers of different kinds of Neo4j primitives",
"name" : "org.neo4j:instance=kernel#0,name=Primitive count",
"attributes" : [ {
"description" : "An estimation of the number of nodes used in this Neo4j instance",
"name" : "NumberOfNodeIdsInUse",
"value" : 24117,
"isReadable" : "true",
"type" : "long",
"isWriteable" : "false ",
"isIs" : "false "
}, {
"description" : "An estimation of the number of relationships used in this Neo4j instance",
"name" : "NumberOfRelationshipIdsInUse",
"value" : 1,
"isReadable" : "true",
"type" : "long",
"isWriteable" : "false ",
"isIs" : "false "
}, {
"description" : "An estimation of the number of properties used in this Neo4j instance",
"name" : "NumberOfPropertyIdsInUse",
"value" : 19078,
"isReadable" : "true",
"type" : "long",
"isWriteable" : "false ",
"isIs" : "false "
}, {
"description" : "The number of relationship types used in this Neo4j instance",
"name" : "NumberOfRelationshipTypeIdsInUse",
"value" : 0,
"isReadable" : "true",
"type" : "long",
"isWriteable" : "false ",
"isIs" : "false "
} ],
"url" : "org.neo4j/instance%3Dkernel%230%2Cname%3DPrimitive+count"
}
...

If we only wanted to return the the numbers of different kinds of Neo4j primitives we could run the following query which uses the name returned by the previous query:

$ curl -H "Content-Type:application/json" -d '["org.neo4j:name=Primitive count,instance=*"]' http://localhost:7474/db/manage/server/jmx/query
[ {
"description" : "Estimates of the numbers of different kinds of Neo4j primitives",
"name" : "org.neo4j:instance=kernel#0,name=Primitive count",
"attributes" : [ {
"description" : "An estimation of the number of nodes used in this Neo4j instance",
"name" : "NumberOfNodeIdsInUse",
"value" : 24117,
"isReadable" : "true",
"type" : "long",
"isWriteable" : "false ",
"isIs" : "false "
}],
...
"url" : "org.neo4j/instance%3Dkernel%230%2Cname%3DPrimitive+count"
} ]

We could also use the following URI if we don’t want to/can’t send a POST body:

$ curl -H "Content-Type:application/json" http://localhost:7474/db/manage/server/jmx/domain/org.neo4j/instance%3Dkernel%230%2Cname%3DPrimitive+count
[ {
"description" : "Estimates of the numbers of different kinds of Neo4j primitives",
"name" : "org.neo4j:instance=kernel#0,name=Primitive count",
"attributes" : [ {
"description" : "An estimation of the number of nodes used in this Neo4j instance",
"name" : "NumberOfNodeIdsInUse",
"value" : 24117,
"isReadable" : "true",
"type" : "long",
"isWriteable" : "false ",
"isIs" : "false "
}],
...
"url" : "org.neo4j/instance%3Dkernel%230%2Cname%3DPrimitive+count"
} ]

Developers! Quickly and easily gain access to the tools and information you need! Explore, test and combine our data quality APIs at Melissa Developer Portal – home to tools that save time and boost revenue. Our APIs verify, standardize, and correct the Big 4 + more – name, email, phone and global addresses – to ensure accurate delivery, prevent blacklisting and identify risks in real-time.

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}