What would be the alternative to expose metrics endpoint for Prometheus?How to change the endpoint of prometheus metricsspring boot monitoring in practiceChange prometheus endpoint using micrometer.ioMetrics don't show up on the /prometheus endpointExpose multiple metrics to Prometheusafter upgrade to Spring Boot 2, how to expose cache metrics to prometheus?Custom metrics using Micrometer is not available in Prometheus endpointHow to expose non-realtime metrics to PrometheusExpose Prometheus Metrics in DropwizardMetrics not appearing at prometheus endpoint when I'm using micrometer's PrometheusMeterRegistry
Why did House of Representatives need to condemn Trumps Tweets?
Wand of the War Mage spellcasting focus and bonus interaction with multiclassing
Going from a circuit to the quantum state output of the circuit
Why is it "on the inside" and not "in the inside"?
Is it okay for me to decline a project on ethical grounds?
How do I use JSON.generator to generate an unnamed array?
Can I change the license of a forked project to the MIT if the license of the parent project has changed from the GPL to the MIT?
Name These Animals
Prove a result by assuming it's true and showing no contradiction
Why isn't there any 9.5 digit multimeter or higher?
What is "aligned sequences" and "consensus sequence" in the context of sequence logo? How to compute these?
How can I kill my goat?
Should I accept an invitation to give a talk from someone who might review my proposal?
What container to use to store developer concentrate?
Exploiting the delay when a festival ticket is scanned
How likely is fragmentation on a table with 40000 products likely to affect performance
Why do they sell Cat 5 Ethernet splitters if you can’t split the signal?
Summoning A Technology Based Demon
Filter search results by multiple filters in one operation
Is it error of law to judge on less relevant case law when there is much more relevant one?
How do you pronounce "Hain"?
Why is the Apollo LEM ladder so far from the ground?
Does Wolfram Mathworld make a mistake describing a discrete probability distribution with a probability density function?
Move the outer key inward in an association
What would be the alternative to expose metrics endpoint for Prometheus?
How to change the endpoint of prometheus metricsspring boot monitoring in practiceChange prometheus endpoint using micrometer.ioMetrics don't show up on the /prometheus endpointExpose multiple metrics to Prometheusafter upgrade to Spring Boot 2, how to expose cache metrics to prometheus?Custom metrics using Micrometer is not available in Prometheus endpointHow to expose non-realtime metrics to PrometheusExpose Prometheus Metrics in DropwizardMetrics not appearing at prometheus endpoint when I'm using micrometer's PrometheusMeterRegistry
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I would like to expose Prometheus metrics to an endpoint.
I don't have spring-boot so I need to expose metrics on my own.
I took example code from:
https://micrometer.io/docs/registry/prometheus#_configuring
PrometheusMeterRegistry prometheusRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
try
HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);
server.createContext("/prometheus", httpExchange ->
String response = prometheusRegistry.scrape(); (1)
httpExchange.sendResponseHeaders(200, response.getBytes().length);
try (OutputStream os = httpExchange.getResponseBody())
os.write(response.getBytes());
);
new Thread(server::start).start();
catch (IOException e)
throw new RuntimeException(e);
While it works, I would like to avoid using sun package. Is there a way to do this as short and elegant with netty, okhttp or apache for example?
Thank you.
java http prometheus micrometer
add a comment |
I would like to expose Prometheus metrics to an endpoint.
I don't have spring-boot so I need to expose metrics on my own.
I took example code from:
https://micrometer.io/docs/registry/prometheus#_configuring
PrometheusMeterRegistry prometheusRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
try
HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);
server.createContext("/prometheus", httpExchange ->
String response = prometheusRegistry.scrape(); (1)
httpExchange.sendResponseHeaders(200, response.getBytes().length);
try (OutputStream os = httpExchange.getResponseBody())
os.write(response.getBytes());
);
new Thread(server::start).start();
catch (IOException e)
throw new RuntimeException(e);
While it works, I would like to avoid using sun package. Is there a way to do this as short and elegant with netty, okhttp or apache for example?
Thank you.
java http prometheus micrometer
add a comment |
I would like to expose Prometheus metrics to an endpoint.
I don't have spring-boot so I need to expose metrics on my own.
I took example code from:
https://micrometer.io/docs/registry/prometheus#_configuring
PrometheusMeterRegistry prometheusRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
try
HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);
server.createContext("/prometheus", httpExchange ->
String response = prometheusRegistry.scrape(); (1)
httpExchange.sendResponseHeaders(200, response.getBytes().length);
try (OutputStream os = httpExchange.getResponseBody())
os.write(response.getBytes());
);
new Thread(server::start).start();
catch (IOException e)
throw new RuntimeException(e);
While it works, I would like to avoid using sun package. Is there a way to do this as short and elegant with netty, okhttp or apache for example?
Thank you.
java http prometheus micrometer
I would like to expose Prometheus metrics to an endpoint.
I don't have spring-boot so I need to expose metrics on my own.
I took example code from:
https://micrometer.io/docs/registry/prometheus#_configuring
PrometheusMeterRegistry prometheusRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
try
HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);
server.createContext("/prometheus", httpExchange ->
String response = prometheusRegistry.scrape(); (1)
httpExchange.sendResponseHeaders(200, response.getBytes().length);
try (OutputStream os = httpExchange.getResponseBody())
os.write(response.getBytes());
);
new Thread(server::start).start();
catch (IOException e)
throw new RuntimeException(e);
While it works, I would like to avoid using sun package. Is there a way to do this as short and elegant with netty, okhttp or apache for example?
Thank you.
java http prometheus micrometer
java http prometheus micrometer
asked Mar 26 at 19:31
KompiKompiKompiKompi
10513 bronze badges
10513 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You may use this piece of code:
Server server = new Server(8080);
ServletContextHandler context = new ServletContextHandler();
context.setContextPath("/");
server.setHandler(context);
context.addServlet(new ServletHolder(new MetricsServlet()), "/prometheus");
There are no sun packages in imports, only Jetty and Prometheus Java client:
import io.prometheus.client.exporter.MetricsServlet;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55364964%2fwhat-would-be-the-alternative-to-expose-metrics-endpoint-for-prometheus%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You may use this piece of code:
Server server = new Server(8080);
ServletContextHandler context = new ServletContextHandler();
context.setContextPath("/");
server.setHandler(context);
context.addServlet(new ServletHolder(new MetricsServlet()), "/prometheus");
There are no sun packages in imports, only Jetty and Prometheus Java client:
import io.prometheus.client.exporter.MetricsServlet;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
add a comment |
You may use this piece of code:
Server server = new Server(8080);
ServletContextHandler context = new ServletContextHandler();
context.setContextPath("/");
server.setHandler(context);
context.addServlet(new ServletHolder(new MetricsServlet()), "/prometheus");
There are no sun packages in imports, only Jetty and Prometheus Java client:
import io.prometheus.client.exporter.MetricsServlet;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
add a comment |
You may use this piece of code:
Server server = new Server(8080);
ServletContextHandler context = new ServletContextHandler();
context.setContextPath("/");
server.setHandler(context);
context.addServlet(new ServletHolder(new MetricsServlet()), "/prometheus");
There are no sun packages in imports, only Jetty and Prometheus Java client:
import io.prometheus.client.exporter.MetricsServlet;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
You may use this piece of code:
Server server = new Server(8080);
ServletContextHandler context = new ServletContextHandler();
context.setContextPath("/");
server.setHandler(context);
context.addServlet(new ServletHolder(new MetricsServlet()), "/prometheus");
There are no sun packages in imports, only Jetty and Prometheus Java client:
import io.prometheus.client.exporter.MetricsServlet;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
answered Apr 22 at 14:44
NolequenNolequen
5441 gold badge9 silver badges22 bronze badges
5441 gold badge9 silver badges22 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55364964%2fwhat-would-be-the-alternative-to-expose-metrics-endpoint-for-prometheus%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown