JMXQuery Python Module
Provides a Python module to easily run queries and collect metrics from a Java Virtual Machine via JMX.
In order to use this module, provide a list of queries, and the module will return all of the values it finds matching the query. Please note that the interfact to the JMX uses a small jar file contained in this module, so you will need to have java installed on the machine you're running this module on.
Usage
This example query for a Kafka server will get all cluster partition metrics:
jmxConnection = JMXConnection("service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi")
jmxQuery = [JMXQuery("kafka.cluster:type=*,name=*,topic=*,partition=*",
metric_name="kafka_cluster_{type}_{name}",
metric_labels={"topic" : "{topic}", "partition" : "{partition}"})]
metrics = jmxConnection.query(jmxQuery)
for metric in metrics:
print(f"{metric.metric_name}<{metric.metric_labels}> == {metric.value}")
This will return the following:
kafka_cluster_Partition_UnderReplicated<{'partition': '0', 'topic': 'test'}> == 0
kafka_cluster_Partition_UnderMinIsr<{'partition': '0', 'topic': 'test'}> == 0
kafka_cluster_Partition_InSyncReplicasCount<{'partition': '0', 'topic': 'test'}> == 1
kafka_cluster_Partition_ReplicasCount<{'partition': '0', 'topic': 'test'}> == 1
kafka_cluster_Partition_LastStableOffsetLag<{'partition': '0', 'topic': 'test'}> == 0
As you will notice you can optionally send a metric_name and metric_labels with {} tokens in them. These tokens are replaced at runtime by the jar so you can easily build metric names with associated labels using the MBean properties of the values your query pulls back.
You can also use the module to pull back a list of all the MBean values available in the JVM too:
jmxConnection = JMXConnection("service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi")
jmxQuery = [JMXQuery("*:*")]
metrics = jmxConnection.query(jmxQuery)
for metric in metrics:
print(f"{metric.to_query_string()} ({metric.value_type}) = {metric.value}")
Installation
Just use pip to install the module in your Python environment:
pip install jmxquery
Metadata
Release files for jmxquery 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jmxquery-0.6.0.tar.gz | 20.5 kB | Without provenance | Details for jmxquery-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jmxquery-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for jmxquery-0.6.0-py3-none-any.whl |
Total release size: 40.9 kB
Release files / jmxquery-0.6.0.tar.gz
| Download URL | jmxquery-0.6.0.tar.gz |
|---|---|
| Size | 20.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f0bdb002591eec6eea0e16546baa35448f8b66acaf6dd72ed049c3a666afc06b
|
|
BLAKE2b-256 checksum How to use checksums |
77e06b1648bb44eb2bdd778149a6f6100620db92161d3d55659ac1f51e95c69f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.6
|
Release files / jmxquery-0.6.0-py3-none-any.whl
| Download URL | jmxquery-0.6.0-py3-none-any.whl |
|---|---|
| Size | 20.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8fb4644026bb2de7c1dbedc52f6cb8e3d56820859b7b03cb971c9c633c870a77
|
|
BLAKE2b-256 checksum How to use checksums |
58a91f9fa3a6082d597b056b23098870856da6f2ba0dee943cfe2f9b572922f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.6
|
Security for jmxquery 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.