use of io.prometheus.client.exporter.HTTPServer in project incubator-servicecomb-java-chassis by apache.
the class MetricsHttpPublisher method init.
private void init(String address) {
try {
InetSocketAddress socketAddress = getSocketAddress(address);
MetricsCollector metricsCollector = new MetricsCollector();
metricsCollector.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);
}
}
use of io.prometheus.client.exporter.HTTPServer in project bboxdb by jnidzwetzki.
the class PerformanceCounterService method init.
@Override
public void init() throws InterruptedException, BBoxDBException {
final BBoxDBConfiguration bboxDBConfiguration = BBoxDBConfigurationManager.getConfiguration();
final int port = bboxDBConfiguration.getPerformanceCounterPort();
// Service is disabled
if (port == -1) {
logger.info("Performance counter service is disabled");
return;
}
logger.info("Starting performance counter service on port: {}", port);
// Expose JVM stats
DefaultExports.initialize();
try {
server = new HTTPServer(port);
} catch (IOException e) {
logger.error("Got an exception during starting up performance counter HTTP sever", e);
}
}
use of io.prometheus.client.exporter.HTTPServer in project modules-extra by CubeEngine.
the class Stats method onPreInit.
@Listener
public void onPreInit(GamePreInitializationEvent event) {
final CollectorRegistry registry = monitoring.getRegistry();
final InetSocketAddress bindAddr = new InetSocketAddress(config.bindAddress, config.bindPort);
registerDefaults(registry);
players.register(registry);
tps.register(registry);
loadedChunks.register(registry);
playersOnline.register(registry);
entities.register(registry);
tileEntities.register(registry);
try {
this.exporter = new HTTPServer(bindAddr, registry, true);
this.scheduler.scheduleAtFixedRate(this::sampleServer, config.samplingInterval.toMillis(), config.samplingInterval.toMillis(), TimeUnit.MILLISECONDS);
} catch (IOException e) {
e.printStackTrace();
}
}
use of io.prometheus.client.exporter.HTTPServer in project jmx_exporter by prometheus.
the class WebServer method main.
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 JmxCollector(new File(args[1])).register();
new HTTPServer(socket, CollectorRegistry.defaultRegistry);
}
use of io.prometheus.client.exporter.HTTPServer in project jmx_exporter by prometheus.
the class JavaAgent method premain.
public static void premain(String agentArgument, Instrumentation instrumentation) throws Exception {
// Bind to all interfaces by default (this includes IPv6).
String host = "0.0.0.0";
// If we have IPv6 address in square brackets, extract it first and then
// remove it from arguments to prevent confusion from too namy colons.
Integer indexOfClosingSquareBracket = agentArgument.indexOf("]:");
if (indexOfClosingSquareBracket >= 0) {
host = agentArgument.substring(0, indexOfClosingSquareBracket + 1);
agentArgument = agentArgument.substring(indexOfClosingSquareBracket + 2);
}
String[] args = agentArgument.split(":");
if (args.length < 2 || args.length > 3) {
System.err.println("Usage: -javaagent:/path/to/JavaAgent.jar=[host:]<port>:<yaml configuration file>");
System.exit(1);
}
int port;
String file;
InetSocketAddress socket;
if (args.length == 3) {
port = Integer.parseInt(args[1]);
socket = new InetSocketAddress(args[0], port);
file = args[2];
} else {
port = Integer.parseInt(args[0]);
socket = new InetSocketAddress(host, port);
file = args[1];
}
new JmxCollector(new File(file)).register();
DefaultExports.initialize();
server = new HTTPServer(socket, CollectorRegistry.defaultRegistry, true);
}
Aggregations