本文整理了Java中io.prometheus.client.exporter.HTTPServer.<init>()
方法的一些代码示例,展示了HTTPServer.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HTTPServer.<init>()
方法的具体详情如下:
包路径:io.prometheus.client.exporter.HTTPServer
类名称:HTTPServer
方法名:<init>
[英]Start a HTTP server serving the default Prometheus registry using non-daemon threads.
[中]使用非守护进程线程启动为默认Prometheus注册表提供服务的HTTP服务器。
代码示例来源:origin: alibaba/canal
@Override
public void initialize() {
try {
logger.info("Start prometheus HTTPServer on port {}.", port);
//TODO 2.Https?
server = new HTTPServer(port);
} catch (IOException e) {
logger.warn("Unable to start prometheus HTTPServer.", e);
return;
}
try {
// JVM exports
DefaultExports.initialize();
instanceExports.initialize();
if (!clientProfiler.isStart()) {
clientProfiler.start();
}
profiler().setInstanceProfiler(clientProfiler);
} catch (Throwable t) {
logger.warn("Unable to initialize server exports.", t);
}
running = true;
}
代码示例来源:origin: qunarcorp/qmq
public PrometheusQmqMetricRegistry() {
DynamicConfig config = DynamicConfigLoader.load("qmq.prometheus.properties", false);
String type = config.getString("monitor.type", "prometheus");
if ("prometheus".equals(type)) {
String action = config.getString("monitor.action", "pull");
if ("pull".equals(action)) {
try {
HTTPServer server = new HTTPServer(config.getInt("monitor.port", 3333));
} catch (IOException e) {
e.printStackTrace();
}
}
} else if ("graphite".equals(type)) {
String host = config.getString("graphite.host");
int port = config.getInt("graphite.port");
Graphite graphite = new Graphite(host, port);
graphite.start(CollectorRegistry.defaultRegistry, 60);
}
}
代码示例来源:origin: prometheus/jmx_exporter
public static void main(String[] args) throws Exception {
if (args.length < 2) {
System.err.println("Usage: WebServer <[hostname:]port> <yaml configuration file>");
System.exit(1);
}
String[] hostnamePort = args[0].split(":");
int port;
InetSocketAddress socket;
if (hostnamePort.length == 2) {
port = Integer.parseInt(hostnamePort[1]);
socket = new InetSocketAddress(hostnamePort[0], port);
} else {
port = Integer.parseInt(hostnamePort[0]);
socket = new InetSocketAddress(port);
}
new BuildInfoCollector().register();
new JmxCollector(new File(args[1])).register();
new HTTPServer(socket, CollectorRegistry.defaultRegistry);
}
}
代码示例来源:origin: apache/servicecomb-java-chassis
@Override
public void init(GlobalRegistry globalRegistry, EventBus eventBus, MetricsBootstrapConfig config) {
this.globalRegistry = globalRegistry;
//prometheus default port allocation is here : https://github.com/prometheus/prometheus/wiki/Default-port-allocations
String address =
DynamicPropertyFactory.getInstance().getStringProperty(METRICS_PROMETHEUS_ADDRESS, "0.0.0.0:9696").get();
try {
InetSocketAddress socketAddress = getSocketAddress(address);
register();
this.httpServer = new HTTPServer(socketAddress, CollectorRegistry.defaultRegistry, true);
LOGGER.info("Prometheus httpServer listened : {}.", address);
} catch (Exception e) {
throw new ServiceCombException("create http publish server failed,may bad address : " + address, e);
}
}
代码示例来源:origin: org.eclipse.che.core/che-core-metrics-core
@PostConstruct
public void startServer() throws IOException {
this.server = new HTTPServer(new InetSocketAddress(metricsPort), collectorRegistry, true);
LOG.info("Metrics server started at port {} successfully ", metricsPort);
}
代码示例来源:origin: smartcat-labs/cassandra-diagnostics
/**
* Constructor.
*
* @param configuration Reporter configuration
* @param globalConfiguration Global configuration
* @throws IOException if HTTPServer cannot be initialized
*/
public PrometheusReporter(ReporterConfiguration configuration, GlobalConfiguration globalConfiguration)
throws IOException {
super(configuration, globalConfiguration);
logger.debug("Initializing prometheus client with config: {}", configuration.toString());
final String httpServerHost = configuration.getOption(HTTP_SERVER_HOST_KEY);
final int httpServerPort = configuration.getDefaultOption(HTTP_SERVER_PORT_KEY, DEFAULT_HTTP_SERVER_PORT);
server = new HTTPServer(httpServerHost, httpServerPort);
logger.info("Initialized prometheus reporter on host and port: {}", httpServerHost + ":" + httpServerPort);
}
代码示例来源:origin: hellobike/tunnel
@Override
public void startup() {
PrometheusStatsCollector.createAndRegister();
DefaultExports.initialize();
try {
this.server = new HTTPServer(this.exporterConfig.getExportPort());
} catch (Exception e) {
//
}
}
代码示例来源:origin: FlareBot/FlareBot
public Metrics() {
DefaultExports.initialize();
new BotCollector(new BotMetrics()).register();
try {
server = new HTTPServer(9191);
logger.info("Setup HTTPServer for Metrics");
} catch (IOException e) {
throw new IllegalStateException("Failed to set up HTTPServer for Metrics", e);
}
}
代码示例来源:origin: com.alibaba.otter/canal.prometheus
@Override
public void initialize() {
try {
logger.info("Start prometheus HTTPServer on port {}.", port);
//TODO 2.Https?
server = new HTTPServer(port);
} catch (IOException e) {
logger.warn("Unable to start prometheus HTTPServer.", e);
return;
}
try {
// JVM exports
DefaultExports.initialize();
instanceExports.initialize();
if (!clientProfiler.isStart()) {
clientProfiler.start();
}
profiler().setInstanceProfiler(clientProfiler);
} catch (Throwable t) {
logger.warn("Unable to initialize server exports.", t);
}
running = true;
}
代码示例来源:origin: criteo/cassandra_exporter
public static void main(String[] args) throws Exception {
Logger logger = LoggerFactory.getLogger(Main.class);
String configPath = args.length > 0 ? args[0] : Config.DEFAULT_PATH;
Optional<Config> cfgO = Config.fromFile(configPath);
if (!cfgO.isPresent()) {
logger.error("Cannot parse config file present at {}", configPath);
return;
}
Config cfg = cfgO.get();
boolean isOneShot = Arrays.asList(args).contains("--oneshot");
HTTPServer server = new HTTPServer(cfg.getListenAddress(), cfg.getListenPort());
JmxScraper scrapper = new JmxScraper(String.format("service:jmx:rmi:///jndi/rmi://%s/jmxrmi", cfg.getHost()), cfg.getUser(), cfg.getPassword(), cfg.getSSL(), cfg.getBlacklist(), cfg.getMaxScrapFrequencyInSec());
if (isOneShot) {
scrapper.run(false);
System.exit(0);
}
for (; ; ) {
try {
scrapper.run(true);
} catch (Exception e) {
logger.error("Scrapper stopped due to uncaught exception", e);
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
System.exit(0);
}
}
}
代码示例来源:origin: dabbotorg/java-music-bot
try {
DefaultExports.initialize();
HTTPServer server = new HTTPServer(port);
} catch (IOException e) {
logger.error("initializing prometheus failed", e);
内容来源于网络,如有侵权,请联系作者删除!