Use java-application as a remote_write server

478 views
Skip to first unread message

aistl...@gmail.com

unread,
Aug 9, 2017, 12:06:06 PM8/9/17
to Prometheus Users


Hello!
We're trying to use java-application as a "remote_write" server.

So we use this piece of config
remote_write:

We find remote.proto file in prometheus sources and just copied it to our java application.
Then we generated java classes using maven plugin. (e.g. like here https://github.com/harryalto/sample-microservices-protobuf)
So we have Remote.WriteRequest entity in our project. 

We wrote rest service:

    @RequestMapping(value = "/test", 
            consumes = "application/x-protobuf",
            method = RequestMethod.POST)
    public void getMetric(@RequestBody Remote.WriteRequest metric) 


But unfortunately we have errors in prometheus logs:

WARN[0246] Error sending 2 samples to remote storage: server returned HTTP status 400 : {"timestamp":1502294355482,"status":400,"error":"Bad Request","exception":"org.springframework.http.converter.HttpMessageNotReadableException","message":"Could not read Protobuf message: Protocol message tag had invalid wire type.; nested exception is com.  source="queue_manager.go:500"


or

WARN[0270] Error sending 1 samples to remote storage: server returned HTTP status 400 : {"timestamp":1502294379548,"status":400,"error":"Bad Request","exception":"org.springframework.http.converter.HttpMessageNotReadableException","message":"Could not read Protobuf message: Protocol message end-group tag did not match expected tag.; nested ex  source="queue_manager.go:500"

If we change @RequestBody to String we can see encoded string in our logs like on the screenshot:



But we just don't know what to do with that string. How to decode it into a pojo class?
I would be very grateful for any help and suggestions!

aistl...@gmail.com

unread,
Aug 9, 2017, 12:21:08 PM8/9/17
to Prometheus Users
Also if we use simple java util Object as RequestBody those errors also occur. So only String RequestBody works but we don't know what to do with that encoded string..

Tom Wilkie

unread,
Aug 9, 2017, 4:43:34 PM8/9/17
to aistl...@gmail.com, Prometheus Users
What Prometheus version? There was a bug in the snappy encoding that made java interop not work, but it was fixed a while ago.

Tom
On Wed, 9 Aug 2017 at 11:21, <aistl...@gmail.com> wrote:
Also if we use simple java util Object as RequestBody those errors also occur. So only String RequestBody works but we don't know what to do with that encoded string..

--
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 prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/62171a3e-01dc-45a2-9511-01d77a74baad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

aistl...@gmail.com

unread,
Aug 9, 2017, 5:27:54 PM8/9/17
to Prometheus Users
Prometheus 1.7.
I've figured it out.. Rest service works if I use byte[] as a Request Body and then use
Remote.WriteRequest request = Remote.WriteRequest.parseFrom(Snappy.uncompress(byteArray));

Probably not the most elegant solution, but it works.

Tom Wilkie

unread,
Aug 9, 2017, 7:46:34 PM8/9/17
to aistl...@gmail.com, Prometheus Users
Yeah that looks like snappy framing problems - framing is not part of the standard, so any 'streaming' snappy is language specific.

Thanks

Tom
--
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 prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.

jingq...@gmail.com

unread,
Nov 9, 2018, 6:39:07 PM11/9/18
to Prometheus Users
Hi,

I am struggling to generate java classes from remote.proto. I also followed the maven plugin like the sample project. But it failed with
"gogo.proto: File not found". I would be very grateful for any help and suggestions!

thanks, 

Tom Wilkie

unread,
Nov 10, 2018, 7:07:14 AM11/10/18
to jingq...@gmail.com, Prometheus Users
Gogo.proto is go specific. I’d take a copy of the proto and remove any reference to gogo.

Thanks

Tom
--
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 prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.

jingq...@gmail.com

unread,
Nov 11, 2018, 7:13:35 PM11/11/18
to Prometheus Users
Thanks Tom! Having a copy of the gogo Proto solved my problem.
Reply all
Reply to author
Forward
0 new messages