JMX: Elasticsearch Linux machine
Got a chance to work with the JMX metrics for the elasticsearch. It just takes a couple of steps to connect to elasticsearch JMX metrics via JConsole.
The assumptions are you have already installed elasticsearch and logstash in your machine.
1. Go to the elsaticsearch bin folder and the following configuration.
Eg: {EL_HOME}/bin/elasticsearch.in.sh
# ensures JMX accessible from outside world
Got a chance to work with the JMX metrics for the elasticsearch. It just takes a couple of steps to connect to elasticsearch JMX metrics via JConsole.
The assumptions are you have already installed elasticsearch and logstash in your machine.
1. Go to the elsaticsearch bin folder and the following configuration.
Eg: {EL_HOME}/bin/elasticsearch.in.sh
# ensures JMX accessible from outside world
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=9499"
JAVA_OPTS="$JAVA_OPTS -Djava.rmi.server.hostname=<ipaddress>"
2. Go to /etc/init.d/elasticsearch and enable the JAVA_OPTS.
ES_JAVA_OPTS="-Dcom.sun.management.jmxremote.ssl=false - Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=9499"
3. Restart the elasticsearch service.
4. Open the JConsole and connect using the following URL:
service:jmx:rmi:///jndi/rmi://<ipaddress>:9499/jmxrmi
Now connect through the logstash:
1. Create the logstash input plugin in your conf file: /etc/logstash/conf.d/logstash_jmx.conf
input {
jmx{
path => "/etc/logstash/conf.d/jmx"
polling_frequency => 15
type => "jmx"
nb_thread => 4
}
}
output {
elasticsearch {
hosts => ["<ipaddress>"]
index => "minionkafkamsgs-%{+YYYY.MM.dd}"
}
}
2. Create a jmx entry for the /etc/logstash/conf.d/jmx/jmx.conf
{
"host" : "localhost",
"port" : 9499,
"username" : "admin",
"password": "admin",
"alias" : "test.homeserver.elasticsearch",
"queries" : [
{
"object_name" : "java.lang:type=Memory",
"object_alias" : "Memory"
}, {
"object_name" : "java.lang:type=Runtime",
"attributes" : [ "Uptime", "StartTime" ],
"object_alias" : "Runtime"
}, {
"object_name" : "java.lang:type=GarbageCollector,name=*",
"attributes" : [ "CollectionCount", "CollectionTime" ],
"object_alias" : "${type}.${name}"
}, {
"object_name" : "java.nio:type=BufferPool,name=*",
"object_alias" : "${type}.${name}"
} ]
}
Then access these data from kibana dashboard.
Cheers!!!