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;








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.










share|improve this question






























    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.










    share|improve this question


























      0












      0








      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.










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 26 at 19:31









      KompiKompiKompiKompi

      10513 bronze badges




      10513 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          1














          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;





          share|improve this answer
























            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
            );



            );













            draft saved

            draft discarded


















            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









            1














            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;





            share|improve this answer





























              1














              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;





              share|improve this answer



























                1












                1








                1







                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;





                share|improve this answer













                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;






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Apr 22 at 14:44









                NolequenNolequen

                5441 gold badge9 silver badges22 bronze badges




                5441 gold badge9 silver badges22 bronze badges





















                    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.



















                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현