[英]Graphite: How to send graphite metrics at random intervals?
我正在使用套接字向Graphite發送指標:
String prefix = prefix
+ "." + metric + " " + value + " " + (System.currentTimeMillis() / 1000);
socket = new Socket(host, port);
out = new PrintWriter(socket.getOutputStream(), true);
out.println(prefix);
這會每毫秒左右發送一次指標。 如何確保每1或5分鍾或隨機發送一次?
放入while循環並添加睡眠
while (true){
String prefix = prefix
+ "." + metric + " " + value + " " + (System.currentTimeMillis() / 1000);
socket = new Socket(host, port);
out = new PrintWriter(socket.getOutputStream(), true);
out.println(prefix);
Thread.sleep(60);
}
為什么要隨機間隔進行? 石墨期望精確的間隔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.