Hi,
I am trying to send some custom metrics to Prometheus using the java
client. Below is my code. However, when I run the sample I get the
following error:
java.net.BindException: Can't assign requested address at
sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Net.java:433) at
sun.nio.ch.Net.bind(Net.java:425) at
sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) at
sun.net.httpserver.ServerImpl.<init>(ServerImpl.java:100) at
sun.net.httpserver.HttpServerImpl.<init>(HttpServerImpl.java:50) at
sun.net.httpserver.DefaultHttpServerProvider.createHttpServer(DefaultHttpServerProvider.java:35)
at com.sun.net.httpserver.HttpServer.create(HttpServer.java:130) at
io.prometheus.client.exporter.HTTPServer.<init>(HTTPServer.java:176) at
io.prometheus.client.exporter.HTTPServer.<init>(HTTPServer.java:211) at
com.test.promtheus.App.main(App.java:38)
When i try the URL on the browser it loads the dashboard correctly.
public class App {
public static void main( String[] args ) {
System.out.println( "Hello World!" );
final Counter counter =
Counter.build().namespace("java").name("my_counter").help("This is my
counter").register();
Thread bgThread = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {
counter.inc();
Thread.sleep(1000);
} catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
});
bgThread.start();
try
{
HTTPServer server = new HTTPServer("test.xyz.com",30000);
} catch (IOException e)
{
e.printStackTrace();
}
}
}
Am i missing something?
--
You received this message because you are subscribed to the Google Groups
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-users/615a1e1b-7132-4a6a-a3eb-fb3017109ddan%40googlegroups.com.