Graphite Server does not display new data sent from Java

I am trying to send text data to a graphite server with the following code:

      try (
            Socket socket = new Socket("companyHost", 2003);
            Writer writer = new OutputStreamWriter(socket.getOutputStream());) {

        Long timestamp = System.currentTimeMillis() / 1000;
        System.out.println(timestamp);

        String sentMessage = "graphite.carbon.local.test.showone 1 " + timestamp;
        System.out.println(sentMessage);
        writer.write(sentMessage);
        writer.flush();

    } catch (IOException e) {

        e.printStackTrace();
    }

      

But when I check the carbon server under companyHost: port in my web browser, my data is gone, there is nothing under the graphite. carbon.local. Did I miss something?

My console output looks fine (no errors / exceptions):

1409233165
graphite.carbon.local.test.showone 1 1409233165

      

I will try to provide additional information if necessary.

+3


source to share


2 answers


Yes, I solved it in August.

If I remember correctly, all I had to do was add a new line char "\ n" at the end of the message.



As stated in the graphical documentation, the message format is as follows:

metric_path value timestamp\n

      

+5


source


One of the examples found on the web - https://www.hostedgraphite.com/docs/languageguide/lg_java.html has a typo.

Timestamp must be provided in addition to metricpath and value as -



dos.writeBytes("YOUR-API-KEY.foo 1.2 <timestamp>\n");

      

0


source







All Articles