Hadoop Monitoring
General
HttpServer2
org.apache.hadoop.http
@InterfaceAudience.Private
@InterfaceStability.Evolving
public final class HttpServer2
extends Object
implements FilterContainer
Create a Jetty embedded server to answer http requests. The primary goal is to serve up status information for the server. There are three contexts:
* "/logs/" -> points to the log directory
* "/static/" -> points to common static files (src/webapps/static)
* "/" -> the jsp server code from (src/webapps/ )
This class is a fork of the old HttpServer. HttpServer exists for compatibility reasons. See HBASE-10336 for more details.
protected void addDefaultServlets() {
// set up default servlets
addServlet("stacks", "/stacks", StackServlet.class);
addServlet("logLevel", "/logLevel", LogLevel.Servlet.class);
addServlet("metrics", "/metrics", MetricsServlet.class);
addServlet("jmx", "/jmx", JMXJsonServlet.class);
addServlet("conf", "/conf", ConfServlet.class);
}
Metrics
JMX
JMXJsonServlet
org.apache.hadoop.jmx
public class JMXJsonServlet
extends HttpServlet
Provides Read only web access to JMX.
This servlet generally will be placed under the /jmx URL for each HttpServer. It provides read only access to JMX metrics. The optional qry parameter may be used to query only a subset of the JMX Beans. This query functionality is provided through the MBeanServer.queryNames(ObjectName, javax.management.QueryExp) method.
For example http://.../jmx?qry=Hadoop:* will return all hadoop metrics exposed through JMX.
The optional get parameter is used to query an specific attribute of a JMX bean. The format of the URL is http://.../jmx?get=MXBeanName::AttributeNameFor example http://../jmx?get=Hadoop:service=NameNode,name=NameNodeInfo::ClusterId will return the cluster id of the namenode mxbean.
If the qry or the get parameter is not formatted correctly then a 400 BAD REQUEST http response code will be returned.
If a resouce such as a mbean or attribute can not be found, a 404 SC_NOT_FOUND http response code will be returned.
The return format is JSON and in the form
{
"beans" : [
{
"name":"bean-name"
...
}
]
}
The servlet attempts to convert the the JMXBeans into JSON. Each bean's attributes will be converted to a JSON object member. If the attribute is a boolean, a number, a string, or an array it will be converted to the JSON equivalent. If the value is a CompositeData then it will be converted to a JSON object with the keys as the name of the JSON member and the value is converted following these same rules. If the value is a TabularData then it will be converted to an array of the CompositeData elements that it contains. All other objects will be converted to a string and output as such. The bean's name and modelerType will be returned for all beans. Optional paramater "callback" should be used to deliver JSONP response.