de.m3y.prometheus.exporter.knox.HomePageServlet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of knox-exporter Show documentation
Show all versions of knox-exporter Show documentation
The Prometheus blackbox exporter samples Apache Knox WebHdfs/HBase/Hive endpoints collecting error and duration metrics.
package de.m3y.prometheus.exporter.knox;
import java.io.IOException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Displays a welcome page containing build info and link to metrics.
*/
public class HomePageServlet extends HttpServlet {
private final Config config;
private final BuildInfoExporter buildInfoExporter;
private final String knoxGatewayUrl;
HomePageServlet(String knoxGatewayUrl, Config config, BuildInfoExporter buildInfoExporter) {
this.knoxGatewayUrl = knoxGatewayUrl;
this.config = config;
this.buildInfoExporter = buildInfoExporter;
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
StringBuilder buf = new StringBuilder().append("\n"
+ "Apache Knox Exporter \n"
+ "\n"
+ "Apache Knox Exporter
\n"
+ "\n"
+ "Build info
"
+ ""
+ "- App version: ").append(buildInfoExporter.getAppVersion()).append("
"
+ "- Build time : ").append(buildInfoExporter.getBuildTimeStamp()).append("
"
+ "- SCM branch : ").append(buildInfoExporter.getBuildScmBranch()).append("
"
+ "- SCM version : ").append(buildInfoExporter.getBuildScmVersion()).append("
"
+ "
"
+ "Configuration
"
+ "- Knox gateway URL : ").append(knoxGatewayUrl).append("
"
+ "- username : ").append(config.getUsername()).append("
"
+ "- webHdfStatusPath : ").append(config.getWebHdfStatusPath()).append("
"
+ "- hiveJdbcUrl : ").append(config.getHiveJdbcUrl()).append("
"
+ "- hiveQuery : ").append(config.getHiveQuery()).append("
"
+ "
\n"
+ "");
resp.setContentType("text/html");
resp.getWriter().print(buf);
}
}