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
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 to share