Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement JMX input #48

Closed
otisg opened this issue Dec 8, 2016 · 6 comments
Closed

Implement JMX input #48

otisg opened this issue Dec 8, 2016 · 6 comments

Comments

@otisg
Copy link
Member

otisg commented Dec 8, 2016

Maybe via https://www.npmjs.com/package/jmx (but didn't look into options deeply), though I see this depends on some node-java package and that node-java README mentions Python...

@megastef
Copy link
Contributor

Evaluated and worked so far. Java installation and integration with node-java was a bit of trouble on Mac-OS-X joeferner/node-java#90 (comment).
A handy tool to discover JMX beans and property names is https://github.com/sematext/jmxc :)

@megastef
Copy link
Contributor

megastef commented Feb 10, 2017

This should be a separate npm module/plugin, to avoid dependencies on "java".

@megastef
Copy link
Contributor

megastef commented Sep 20, 2017

An alternative to get JMX stats into Logagent could be jmxtrans combined with Logagent command plugin: https://github.com/jmxtrans/jmxtrans/wiki/StdoutWriter

@fbalicchia
Copy link
Contributor

Make some experiments with the last version of node-jmx and haven't trouble in installation on MacOs.
Developing ingestion for Cassandra metrics I found that node-jmx seems to store every event emitted. I need to investigate a little more to figure out if is a my implementation problem or something else.

@fbalicchia
Copy link
Contributor

Hi, I' dig a little in node-jmx but during experiments I went against some problems, infact using it in batch mode there was trouble in memory usage or too much event listener was added. I've forked library and remove client and node-jmx layers and use only a mbeanServerConnection with a minor refactoring.
At the moment APIs are a little rougth but works, as soon as is possible they will come more fluent.
now code look like

'use strict'
const mBeanconnection = require('./lib/adapters/mbeanServerConnectionNew')
const jmxServiceUrlBuilder = require("./lib/adapters/helpers/jmxServiceUrlBuilder"),
checkError = require("./lib/helpers/error").checkError


setInterval(readDatAll.bind(this), 1000)

var serviceOrHost = 'localhost'
var port = 7199
var protocol
var urlPath

var keyValuecqlMetrics = [
["org.apache.cassandra.metrics:type=CQL,name=PreparedStatementsEvicted","Count"],
["org.apache.cassandra.metrics:type=CQL,name=PreparedStatementsCount","Value"],
["org.apache.cassandra.metrics:type=CQL,name=PreparedStatementsExecuted","Count"],
["org.apache.cassandra.metrics:type=CQL,name=PreparedStatementsRatio","Value"],
["org.apache.cassandra.metrics:type=CQL,name=RegularStatementsExecuted","Count"]]

this.cqlMetrics = new Map(keyValuecqlMetrics)


this.url = jmxServiceUrlBuilder(serviceOrHost, port, protocol, urlPath);


function readDatAll(){
    var self = this
    self.cqlMetrics.forEach(function(value, key){
        connectBean(self.url, key,value);
    })
}


function connectBean(url,bean,measure)
{
    var self = this
    var mBean = new mBeanconnection()
    mBean.myconnect(url,function(){
        var self = this;
        mBean.queryMBeans(null, bean, function(instance) {
          instance.getObjectName(function(err, objectName) {
            if (checkError(err, self)) return;
            mBean.getAttribute(objectName,measure, function(data){
                console.log(bean + ' value ' + data)
            });
            mBean.close
            mBean = null
          });
        });
    });
}

At the moment it works for me but any suggestion are welcome ;-) Asap I'll send a Cassandra input metrics plugin

@otisg
Copy link
Member Author

otisg commented Oct 22, 2018

I think we can close this. https://github.com/sematext/sematext-agent-java has JMX support.

@otisg otisg closed this as completed Oct 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants