Git Product home page Git Product logo

client_java's People

Contributors

adessaigne avatar beorn7 avatar brian-brazil avatar checketts avatar davidkarlsen avatar dependabot[bot] avatar dhoard avatar diebauer avatar fscellos avatar fstab avatar fwbrasil avatar juliusv avatar kingster avatar matttproud avatar matttproud-soundcloud avatar mberndt123 avatar pjfanning avatar pkubowicz avatar prombot avatar pstibrany avatar rainerjung avatar rbarazzutti avatar shakuzen avatar snago avatar solomax avatar superq avatar theneva avatar tokuhirom avatar turbanoff avatar twz123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

client_java's Issues

Failed to download dependencies while deploying

Hi,

I've downloaded the latest release and I am trying to deploy it. When I run mvn clean deploy i get this download error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project parent: Failed to deploy artifacts: Could not transfer artifact io.prometheus:parent:pom:0.0.10 from/to ossrh (https://oss.sonatype.org/service/local/staging/deploy/maven2/): Failed to transfer file: https://oss.sonatype.org/service/local/staging/deploy/maven2/io/prometheus/parent/0.0.10/parent-0.0.10.pom. Return code is: 401, ReasonPhrase:Unauthorized. -> [Help 1]

What can I do here?

Thanks in advance!
Max

Global labels

Hi,

I want to add a label to all the metrics exposed. Just like prometheus appends instance label to all the metrics of a client, I want to add it at the client level.

For example I want to add env=test to all the metrics. Is it possible? If its not possible, would you a accept a PR?

Thanks,
Goutham.

Version 0.0.4 still resets summary counts

@grandbora and @fwbrasil reported that version 0.0.4 still resets summary counters, which was intended to be fixed following this discussion:

#29 (diff)

"I set up a counter and a histogram in the exact same places then executed the same count queries on them. While counter gave a stable count through out the time I observed, histogram lost its count data after a while and it showed that total number of requests went down. Which should not happen."

simpleclient_hotspot should not depend on simpleclient_servlet

It seems like the dependency is not necessary.
I use the simpleclient together with undertow core without servlets, so this is a mild inconvenience.

Right now I do something like this:

<dependency>
    <groupId>io.prometheus</groupId>
    <artifactId>simpleclient_hotspot</artifactId>
    <version>${prometheus.version}</version>
    <exclusions>
        <exclusion>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient_servlet</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Dropwizard metrics missing in Prometheus

Hello

I'm exporting Dropwizard metrics to Prometheus by using the following code, but I'm seeing some metrics are missing in Prometheus as below. Is it a known issue? Anyway to solve it?

Code:
CollectorRegistry collectorRegistry = new CollectorRegistry();
collectorRegistry.register(new DropwizardExports(environment.metrics()));
environment.admin()
.addServlet("prometheusMetrics", new MetricsServlet(collectorRegistry))
.addMapping("/metrics");

Dropwizard Metrics:
{
count: 0,
max: 0,
mean: 0,
min: 0,
p50: 0,
p75: 0,
p95: 0,
p98: 0,
p99: 0,
p999: 0,
stddev: 0,
m15_rate: 0,
m1_rate: 0,
m5_rate: 0,

mean_rate: 0,
duration_units: "seconds",
rate_units: "calls/second"
}

Prometheus Metrics:
{quantile="0.5",} 0.0
{quantile="0.75",} 0.0
{quantile="0.95",} 0.0
{quantile="0.98",} 0.0
{quantile="0.99",} 0.0
{quantile="0.999",} 0.0
count 0.0

Thanks

Release 0.0.7?

Hi, can we have a release 0.0.7 with the new JVM metircs and the tab fixes for process memory reading, soonish? :)

HashCode stored in ThreadLocal causes warnings during deploy

Hi

During redeploy of our application we got a lot of errors regarding memory leak. (Tomcat 8 with Leak Listener enabed).

Example log:

SEVERE: The web application [ROOT] created a ThreadLocal with key of type [io.prometheus.client.Striped64.ThreadHashCode] (value [io.prometheus.client.Striped64$ThreadHashCode@7b13ffe9]) and a value of type [io.prometheus.client.Striped64.HashCode] (value [io.prometheus.client.Striped64$HashCode@184dd3c2]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

Deprecate old client

At some point, we want to deprecate the old client and at the same time get rid of JSON (which is deprecated and only supported by the old client).

The new simpleclient is essentially missing two features:

  • protobuf support (needed for scenarios where a server scrapes many samples, 100k+/sec)
  • summary support

Both are not strictly mandatory, but in use right now. We have to vet if an implementation makes sense.

Is there any way to remove collector's children?

I need to remove collector's children periodically because they are accumulated in collectors and can cause OutOfMemory error. I attempted to remove children like this:
CollectorRegistry.defaultRegistry.collectors().each {collector -> if(collector instanceof io.prometheus.client.SimpleCollector) { (collector as io.prometheus.client.SimpleCollector).clear() } }
but the method CollectorRegistry.defaultRegistry.collectors() is privat. Is there any way to remove collector's children?

Source files without license headers

Hi
The following source files are without license headers:

./benchmark/src/main/java/io/prometheus/benchmark/CounterBenchmark.java
./benchmark/src/main/java/io/prometheus/benchmark/GaugeBenchmark.java
./benchmark/src/main/java/io/prometheus/benchmark/SummaryBenchmark.java

./simpleclient/src/main/java/io/prometheus/client/Collector.java
./simpleclient/src/main/java/io/prometheus/client/CollectorRegistry.java
./simpleclient/src/main/java/io/prometheus/client/Counter.java
./simpleclient/src/main/java/io/prometheus/client/Gauge.java
./simpleclient/src/main/java/io/prometheus/client/Histogram.java
./simpleclient/src/main/java/io/prometheus/client/SimpleCollector.java
./simpleclient/src/main/java/io/prometheus/client/Summary.java

./simpleclient/src/test/java/io/prometheus/client/CollectorRegistryTest.java
./simpleclient/src/test/java/io/prometheus/client/CounterTest.java
./simpleclient/src/test/java/io/prometheus/client/GaugeTest.java
./simpleclient/src/test/java/io/prometheus/client/HistogramTest.java
./simpleclient/src/test/java/io/prometheus/client/SimpleCollectorTest.java
./simpleclient/src/test/java/io/prometheus/client/SummaryTest.java

./simpleclient_common/src/main/java/io/prometheus/client/exporter/common/TextFormat.java
./simpleclient_common/src/test/java/io/prometheus/client/exporter/common/TextFormatTest.java

./simpleclient_dropwizard/src/main/java/io/prometheus/client/dropwizard/DropwizardExports.java
./simpleclient_dropwizard/src/test/java/io/prometheus/client/dropwizard/DropwizardExportsTest.java

./simpleclient_graphite_bridge/src/main/java/io/prometheus/client/bridge/Graphite.java
./simpleclient_graphite_bridge/src/test/java/io/prometheus/client/bridge/GraphiteTest.java

./simpleclient_hotspot/src/main/java/io/prometheus/client/hotspot/DefaultExports.java
./simpleclient_hotspot/src/main/java/io/prometheus/client/hotspot/GarbageCollectorExports.java
./simpleclient_hotspot/src/main/java/io/prometheus/client/hotspot/MemoryPoolsExports.java
./simpleclient_hotspot/src/main/java/io/prometheus/client/hotspot/StandardExports.java
./simpleclient_hotspot/src/main/java/io/prometheus/client/hotspot/ThreadExports.java

./simpleclient_hotspot/src/test/java/io/prometheus/client/hotspot/ExampleExporter.java
./simpleclient_hotspot/src/test/java/io/prometheus/client/hotspot/GarbageCollectorExportsTest.java
./simpleclient_hotspot/src/test/java/io/prometheus/client/hotspot/MemoryPoolsExportsTest.java
./simpleclient_hotspot/src/test/java/io/prometheus/client/hotspot/StandardExportsTest.java
./simpleclient_hotspot/src/test/java/io/prometheus/client/hotspot/ThreadExportsTest.java

./simpleclient_log4j/src/main/java/io/prometheus/client/log4j/InstrumentedAppender.java
./simpleclient_log4j/src/test/java/io/prometheus/client/log4j/InstrumentedAppenderTest.java

./simpleclient_logback/src/main/java/io/prometheus/client/logback/InstrumentedAppender.java
./simpleclient_logback/src/test/java/io/prometheus/client/logback/InstrumentedAppenderTest.java

./simpleclient_pushgateway/src/main/java/io/prometheus/client/exporter/PushGateway.java
./simpleclient_pushgateway/src/test/java/io/prometheus/client/exporter/ExamplePushGateway.java
./simpleclient_pushgateway/src/test/java/io/prometheus/client/exporter/PushGatewayTest.java

./simpleclient_servlet/src/main/java/io/prometheus/client/exporter/MetricsServlet.java
./simpleclient_servlet/src/test/java/io/prometheus/client/exporter/ExampleExporter.java

Please, confirm the licensing of code and/or content/s, and add license headers
https://fedoraproject.org/wiki/Packaging:LicensingGuidelines?rd=Packaging/LicensingGuidelines#License_Clarification

Thanks in advance
Regards

Dropwizard metrics integration

How should someone use dropwizard integration?

A small example in the README.md of the library would be very useful on how get started with simpleclient_dropwizard.

Simpleclient should support quantile

Hi, I find that in java client , Summary support quantile, It can use targetQuantile method.
but in simple client ,Summary do not have a targetQuantile method。

Two questions:
1.Will you support targetQuantil later or will not support in simple client?
2.Is there any substitute way to use quantile now in simpleclient

Thank you

Expose `SummaryTimer` logic so clients can use it when calling `observe`

The built in timer is very convenient for recording measurement when you know the label before hand. However when you don't, like if responseStatusCode is a label, and its value isn't known until the request is finishing up, then the user has to fall back to using observe

Too often I've seen users fall back to using millis or using Guava's stopwatch (which also returns longs, encouraging millis)

It would be great to expose the Timer as a standalone timer I can read elapsed time after the fact so I can get a double that has the right units (meaning seconds).

A simpler approach that would also go along way would be to expose the nanos to seconds conversion as a static method (https://github.com/prometheus/client_java/blob/master/simpleclient/src/main/java/io/prometheus/client/Summary.java#L159)

Then an observation could be as simple as:

long startNanos = System.nanoTime();
//Do work

double durationSeconds = Summary.Timer.durationSeconds(startNanos);
//Record observation

Implement text format version 0.0.4

The plan is to replace JSON as the human readable format by the new simple&flat text format (v 0.0.4, see https://docs.google.com/document/d/1ZjyKiKxZV83VI9ZKAXRGKaUKK2BIWCT7oiGBKDBpjEY/edit?usp=sharing ), so that JSON support can be completely removed.

All 'rich' client libraries should therefore support the text format (even if they also support the protobuf format, which is preferred for machine-machine interaction).

This issue tracks the implementation for the Java client.

@matttproud I hope you have some cycles left to do this. If not, please unassign, and I'll see what can be done at Soundcloud.

Make client as an OSGI Bundle to facilitate integration

Make client as an OSGI Bundle to facilitate integration

It will be really upfull to integrate this client in a oOSGI bundle

Depending artifcats should be OSGI bundle too.

I hope it will possible.

For the moment I m making my proper Client

Expose /prometheus as a Spring Boot Mgmt Endpoint

I missed a simpleclient submodule that creates a Spring Boot Management Endpoint to expose the prometheus metrics.
The existing simpleclient_servlet module requires additional glue-code to accomplish this task.

SimpleCollector.Builder register's type inference goes wrong way

This is a problem you can encounter mostly Scala. Because Scala does type inference for parameters, if you do:

val myCounter = Counter.build().name("foo").register()

it will have type Nothing

That's because the type inference introduced in
ed184d8
cause it to infer the type from the assignment parameter, not from the type of Builder.

I'll send in a patch once I find some time to fix it.

Getting started with spring-boot and prometheus

I am looking to expose metrics from a set of spring-boot services to prometheus but I guess I am missing some steps to bring the two together. I have the following in my pom:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <!-- The client -->
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient</artifactId>
            <version>0.0.18</version>
        </dependency>
        <!-- Hotspot JVM metrics-->
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient_hotspot</artifactId>
            <version>0.0.18</version>
        </dependency>
        <!-- Exposition servlet-->
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient_servlet</artifactId>
            <version>0.0.18</version>
        </dependency>
        <!-- Pushgateway exposition-->
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient_pushgateway</artifactId>
            <version>0.0.18</version>
        </dependency>
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient_spring_boot</artifactId>
            <version>0.0.18</version>
        </dependency>        

and have added the annotation from the javadocs to my main class:


    @EnablePrometheusEndpoint
    public class Application {

	public Application() {
	}

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}
    }

If I run the application and navigate to any of the actuator endpoints I see metrics being reported back. The /prometheus endpoint is returning a 200 but has no additional content. Is tere something else I need to do in order to bridge to the metrics from actuator or even to get the basic hotspot metrics out?

Thanks in advance, Andrew

Metrics Servlet has a potential resource leak

Hi,

I've found recently that Jboss server has run out of available file descriptors and all file descriptors were consumed by connections in CLOSE_WAIT state from JMX prometheus exporter to prometheus server.

I believe that only possible source of leaked descriptor in the following code: https://github.com/prometheus/client_java/blob/master/simpleclient_servlet/src/main/java/io/prometheus/client/exporter/MetricsServlet.java#L40

There print writer is not flushed / closed and left to GC / jetty if an exception happens.

Quantile estimator throws exception on empty sample set

@pcalcado reported this via mail:

I did find a very weird behaviour with the Prometheus Java client
where it only starts returning data after a while, for the very first
minutes of an app running it throws this exception:

java.lang.IllegalStateException: No samples present
26929147 2014-04-08_23:00:18.82132 at
com.matttproud.quantile.Estimator.query(Estimator.java:213)
~[quantile-0.0.1.jar:na]
26929147 2014-04-08_23:00:18.82133 at
io.prometheus.client.metrics.Summary$Child.query(Summary.java:383)
~[client-0.0.2.jar:na]
26929147 2014-04-08_23:00:18.82134 at
io.prometheus.client.metrics.Summary.annotateBuilder(Summary.java:166)
~[client-0.0.2.jar:na]
26929147 2014-04-08_23:00:18.82134 at
io.prometheus.client.metrics.Metric.dump(Metric.java:76)
~[client-0.0.2.jar:na]
26929147 2014-04-08_23:00:18.82135 at
io.prometheus.client.Prometheus.dumpProto(Prometheus.java:104)
~[client-0.0.2.jar:na]
26929147 2014-04-08_23:00:18.82137 at
io.prometheus.client.Prometheus.defaultDumpProto(Prometheus.java:182)
~[client-0.0.2.jar:na]

blocking behavior

This synchronized block introduces a blocking behavior when adding new observations:

synchronized public void observe(final Double v) {

It is the bottleneck for a load test that I'm working on. The Yourkit screenshot:

screen shot 2014-04-07 at 11 03 58 pm

Is this usage correct?

    private val cacheMetrics =
        Summary.newBuilder
            .namespace(Configuration.appName)
            .name("cache_metrics")
            .labelNames("type")
            .documentation("STM cache hit/miss metrics.")
            .purgeInterval(2, TimeUnit.MINUTES)
            .build()

    override def asyncCacheHit = {
        monitor("hit")
        super.asyncCacheHit
    }

    override def asyncCacheMiss = {
        monitor("miss")
        super.asyncCacheMiss
    }

    private def monitor(typ: String) =
        cacheMetrics
            .newPartial()
            .labelPair("type", typ)
            .apply().observe(1)

Thanks

Deprecate and/or rename push and pushAdd

Following #137 and #138, push and pushAll have been reversed.

We were using push in the way that was working, but not according to the documentation, obviously. After upgrade (we should have checked the changelog...), we spent some time figuring out why some metrics were nullified, and then changed it to pushAll.

However, any Prometheus java client user will have its Prometheus fail silently just by upgrading the library. It should be nice to rename and/or deprecate both methods instead in order to force developers to acknowledge this change. As it as been pointed out, those names are confusing.

Maybe only have one push method with a mandatory param overrideWholeGroup or fullGroup?

Duplicate metrics when exposing prometheus metrics via spring boot

I've got a number of duplicate prometheus metrics in my spring boot app (ex: normalized_servo_rest_totaltime:

# HELP gauge_servo_response_assetmgmt_star_star gauge_servo_response_assetmgmt_star_star
# TYPE gauge_servo_response_assetmgmt_star_star gauge
gauge_servo_response_assetmgmt_star_star 16.0
# HELP gauge_servo_response_star_star gauge_servo_response_star_star
# TYPE gauge_servo_response_star_star gauge
gauge_servo_response_star_star 13.0
# HELP normalized_servo_rest_totaltime normalized_servo_rest_totaltime
# TYPE normalized_servo_rest_totaltime gauge
normalized_servo_rest_totaltime 0.0
# HELP normalized_servo_rest_count normalized_servo_rest_count
# TYPE normalized_servo_rest_count gauge
normalized_servo_rest_count 0.0
# HELP gauge_servo_rest_min gauge_servo_rest_min
# TYPE gauge_servo_rest_min gauge
gauge_servo_rest_min 0.0
# HELP gauge_servo_rest_max gauge_servo_rest_max
# TYPE gauge_servo_rest_max gauge
gauge_servo_rest_max 0.0
# HELP gauge_servo_response_error gauge_servo_response_error
# TYPE gauge_servo_response_error gauge
gauge_servo_response_error 10098.0
# HELP gauge_servo_response_star_star_favicon_ico gauge_servo_response_star_star_favicon_ico
# TYPE gauge_servo_response_star_star_favicon_ico gauge
gauge_servo_response_star_star_favicon_ico 6.0
# HELP gauge_servo_response_prometheus gauge_servo_response_prometheus
# TYPE gauge_servo_response_prometheus gauge
gauge_servo_response_prometheus 0.0
# HELP gauge_servo_response_uaa_star_star gauge_servo_response_uaa_star_star
# TYPE gauge_servo_response_uaa_star_star gauge
gauge_servo_response_uaa_star_star 7.0
# HELP normalized_servo_rest_totaltime normalized_servo_rest_totaltime
# TYPE normalized_servo_rest_totaltime gauge
normalized_servo_rest_totaltime 0.0
# HELP normalized_servo_rest_count normalized_servo_rest_count
# TYPE normalized_servo_rest_count gauge
normalized_servo_rest_count 0.0
# HELP gauge_servo_rest_min gauge_servo_rest_min
# TYPE gauge_servo_rest_min gauge
gauge_servo_rest_min 0.0
# HELP gauge_servo_rest_max gauge_servo_rest_max
# TYPE gauge_servo_rest_max gauge
gauge_servo_rest_max 0.0

In my spring boot metrics I don't see any duplicates

"gauge.servo.response.assetmgmt.star-star": 16,
"gauge.servo.response.star-star": 13,
"normalized.servo.restclient.totaltime": 0,
"normalized.servo.restclient.count": 0,
"gauge.servo.restclient.min": 0,
"gauge.servo.restclient.max": 0,
"normalized.servo.rest.totaltime": 0,
"normalized.servo.rest.count": 0,
"gauge.servo.rest.min": 0,
"gauge.servo.rest.max": 0,
"gauge.servo.response.error": 10098,
"gauge.servo.response.star-star.favicon.ico": 6,
"gauge.servo.response.prometheus": 2,

client-java nullpointer exception

jdk 1.8.0_45-b14
when running lient_java/examples/jvmstat Main.java

Exception in thread "main" java.lang.NullPointerException
at org.reflections.Reflections.scan(Reflections.java:220)
at org.reflections.Reflections.scan(Reflections.java:166)
at org.reflections.Reflections.(Reflections.java:94)
at io.prometheus.client.Prometheus.collectAnnotatedFields(Prometheus.java:190)
at io.prometheus.client.Prometheus.initialize(Prometheus.java:201)
at io.prometheus.client.Prometheus.defaultInitialize(Prometheus.java:274)
at io.prometheus.client.examples.guice.Server.configure(Server.java:47)
at io.prometheus.client.examples.guice.Main.run(Main.java:61)
at io.prometheus.client.examples.jvmstat.Main.main(Main.java:45)

This also happens when I use Prometheus.defaultInitialize();

io.prometheus.client.utility
servlet
0.0.10

Improve error reporting upon inconsistent metrics

If a registry containing metrics with duplicate names is pushed, a 500 is returned:

CollectorRegistry pushRegistry = new CollectorRegistry();
Gauge g1 = (Gauge) Gauge.build().name("g1").help("blah1").register(pushRegistry);
Gauge g2 = (Gauge) Gauge.build().name("g1").help("blah2").register(pushRegistry);

PushGateway pg = new PushGateway(address)
pg.push(pushRegistry, "job", "instance");

The error is not meaningful and I actually would expect that an error is thrown already when registering gauge g2.

This is related to Issue 14 in the prometheus/pushgateway repo.

New release please?

Hi, thanks for all the great work on this. It's been a little while since we've had a release, any chance we could cut a new release that includes some of the new clients? Please? 😄

compiling java client servlet doesn't pass tests

I'm running java 7.045 and compiling 0.0.11-SNAPSHOT.
Also, If I skipTests, I deploy to jboss 7.1.1, but get no content back from the metrics servlet.

maven test output:

T E S T S

Running io.prometheus.client.exporter.PushGatewayTest
Tests run: 22, Failures: 0, Errors: 15, Skipped: 0, Time elapsed: 2.178 sec <<< FAILURE! - in io.prometheus.client.exporter.PushGatewayTest
testPush(io.prometheus.client.exporter.PushGatewayTest) Time elapsed: 0.058 sec <<< ERROR!
java.net.SocketException: Invalid argument
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:152)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:658)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1323)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
at io.prometheus.client.exporter.PushGateway.doRequest(PushGateway.java:271)
at io.prometheus.client.exporter.PushGateway.push(PushGateway.java:73)
at io.prometheus.client.exporter.PushGatewayTest.testPush(PushGatewayTest.java:46)

testOldPushCollector(io.prometheus.client.exporter.PushGatewayTest) Time elapsed: 0.059 sec <<< ERROR!
java.net.SocketException: Invalid argument
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:152)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:658)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1323)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
at io.prometheus.client.exporter.PushGateway.doRequest(PushGateway.java:271)
at io.prometheus.client.exporter.PushGateway.push(PushGateway.java:190)
at io.prometheus.client.exporter.PushGateway.push(PushGateway.java:204)
at io.prometheus.client.exporter.PushGatewayTest.testOldPushCollector(PushGatewayTest.java:220)

Spring Boot improvements

The Spring Boot support could be improved in the following ways:

  • Use AutoConfiguration, so just adding the jar to the classpath is enough to launch the actuator classes
  • Add a single @EnablePrometheus annotation, with parameters to enable/disable other configuration
  • Use @ConditionalXXX to override the auto-configuration classes, where users would need to customise things
  • Expose the common collector/exporters

I think there may be more opportunities, but if there's an interest in doing this I'll provide a PR for review.

How can I use this in my own project?

I know how to use maven and import prometheus components into my project.
But I don't know what's next and how to expose my metrics to prometheus?
Do you have a guide reference ?
Thanks.

Registering simpleclient Counter from Scala needs explicit type

This doesn't work in Scala:

val httpRequests = Counter.build().name("requests_failures_total").help("Request failures.").register()

It generates the following runtime error:

Exception in thread "main" java.lang.ClassCastException: io.prometheus.client.Counter cannot be cast to scala.runtime.Nothing$

But this works:

val httpRequests : io.prometheus.client.Counter = Counter.build().name("requests_failures_total").help("Request failures.").register()

Any idea why? I'm using simpleclient 0.0.8 from Maven.

Be compatible with IBM JDK in a lenient way

DefaultExports.initialize() will add register (among other) StandardExports.
StandardExports has two com.sun.management classes.
It will fail on a IBM JDK with:

[1/10/17 10:19:50:691 CET] 00000021 com.ibm.ws.webcontainer.webapp                               E SRVE0283E: Exception caught while initializing context: java.lang.ClassCastException: com.ibm.lang.management.UnixExtendedOperatingSystem incompatible with com.sun.management.OperatingSystemMXBean
        at io.prometheus.client.hotspot.StandardExports.<init>(StandardExports.java:43)
        at io.prometheus.client.hotspot.DefaultExports.initialize(DefaultExports.java:23)

I think it would be better to

  1. use java.lang.managment where possible, and where it does not provide the additional metrics we want:
  2. use some classload-test to see if the classes are available, and if not, skip registering.

Improve documentation/README and add examples.

I recently had the pleasure to instrument an old Java app and I found it hard to get started as the docs are missing examples.
The README has a large part on the maintenance of the library which isn't really helpful for most people that are just looking for a few simple copy-pastable snippets of code, the docs for the python library[1] is a lot better in this regard.

[1] https://github.com/prometheus/client_python

Async for Pushgateway

Hi,

Currently, I'm using push model to submit metric from App to Prometheus.

I have concern that now client using synchronous http model which has impact to application latency.

Is that possible for java client to connect to Pushgateway via http async model?

So, there is will be less impact to application.

Thanks,

Metric and label names should be checked for validity

Reporting this because users placed a dash into a metric name, which was then not queriable via Prometheus (the query language cannot tell a dash/minus apart).

The client library should check that metric and label names are valid ones that can be queried through the query language later (and we should add the same check upon ingestion in Prometheus):

Metric names have to adhere to this regex:

  • [a-zA-Z_:]([a-zA-Z0-9_:])*

Similarly, label names need need to adhere to this one (basically, no colons allowed):

  • [a-zA-Z_]([a-zA-Z0-9_])*

There are currently no restrictions on label values.

Distribution error

Hello! I have this error while bootstrapping of dependencies:

Retrieving io/prometheus/simpleclient/0.0.9/simpleclient-0.0.9.pom from central
Could not transfer artifact io.prometheus:simpleclient:pom:0.0.9 from/to central (https://repo1.maven.org/maven2/): Checksum validation failed, expected 6b5cd46506ce0d2f5d90b659d1134c4f8cca5bbd but is 6e5340c298b8dfc29b1c52c1c54deae77a46d69d

Pushgateway support

The Java library should support pushes to the Pushgateway.

I assume this to be a fairly easy change. (Corresponding change in the Go client library see prometheus/client_golang@c21d91c , relevant change is 30 LOC.) @matttproud @brian-brazil if you are working on client_java anyway, perhaps you can just sneak this change in somewhere? Otherwise, I'll look for somebody at Soundcloud to do it (possibly myself, but as said elsewhere, I have to come back to Java after 9 years absence - Maven was a hipster tool back then...).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.