public void processJsonResponse(String json) throws Exception {
  JSONParser parser=new JSONParser();
  JSONObject obj=(JSONObject)parser.parse(json);
  String service=(String)obj.get("service");
  if (service.isEmpty()) {
    Logger.error("Missing required key 'service' in json response: " + json);
    return;
  }
  Long uptime=(Long)obj.get("uptime");
  if (uptime == null) {
    Logger.error("Missing required key 'uptime' in json response: " + json);
    uptime=0L;
  }
  processCounterMetric(service + "__uptime",uptime);
  String[] fields={"latency_max","latency_999th","latency_99th","latency_95th","latency_mean","payload_size_max","payload_size_999th","payload_size_99th","payload_size_95th","payload_size_mean","alloc_msgs","free_msgs","average_cross_region_rtt","payload_size_mean","alloc_msgs","free_msgs","average_cross_region_rtt","99_cross_region_rtt","average_cross_zone_latency","99_cross_zone_latency","average_server_latency","99_server_latency","average_cross_region_queue_wait","99_cross_region_queue_wait","average_cross_zone_queue_wait","99_cross_zone_queue_wait","average_server_queue_wait","99_server_queue_wait","client_out_queue_99","server_in_queue_99","server_out_queue_99","dnode_client_out_queue_99","peer_in_queue_99","peer_out_queue_99","remote_peer_in_queue_99","remote_peer_out_queue_99","alloc_mbufs","free_mbufs"};
  for (int i=0; i < fields.length; i++) {
    Long val=(Long)obj.get(fields[i]);
    if (val == null) {
      val=0L;
    }
    processGaugeMetric(service + "__" + fields[i],val);
  }
  JSONObject stats=(JSONObject)obj.get("dyn_o_mite");
  if (stats == null) {
    Logger.error("Missing key 'dyn_o_mite' in json response: " + json);
    return;
  }
  parseObjectMetrics(service,stats);
}

public void processJsonResponse ( String json ) throws Exception { JSONParser parser = new JSONParser ( ) ; JSONObject obj = ( JSONObject ) parser . parse ( json ) ; String service = ( String ) obj . get ( "service" ) ; if ( service . isEmpty ( ) ) { Logger . error ( "Missing required key 'service' in json response: " + json ) ; return ; } Long uptime = ( Long ) obj . get ( "uptime" ) ; if ( uptime == null ) { Logger . error ( "Missing required key 'uptime' in json response: " + json ) ; uptime = 0L ; } processCounterMetric ( service + "__uptime" , uptime ) ; String [ ] fields = { "latency_max" , "latency_999th" , "latency_99th" , "latency_95th" , "latency_mean" , "payload_size_max" , "payload_size_999th" , "payload_size_99th" , "payload_size_95th" , "payload_size_mean" , "alloc_msgs" , "free_msgs" , "average_cross_region_rtt" , "payload_size_mean" , "alloc_msgs" , "free_msgs" , "average_cross_region_rtt" , "99_cross_region_rtt" , "average_cross_zone_latency" , "99_cross_zone_latency" , "average_server_latency" , "99_server_latency" , "average_cross_region_queue_wait" , "99_cross_region_queue_wait" , "average_cross_zone_queue_wait" , "99_cross_zone_queue_wait" , "average_server_queue_wait" , "99_server_queue_wait" , "client_out_queue_99" , "server_in_queue_99" , "server_out_queue_99" , "dnode_client_out_queue_99" , "peer_in_queue_99" , "peer_out_queue_99" , "remote_peer_in_queue_99" , "remote_peer_out_queue_99" , "alloc_mbufs" , "free_mbufs" } ; for ( int i = 0 ; i < fields . length ; i ++ ) { Long val = ( Long ) obj . get ( fields [ i ] ) ; if ( val == null ) { val = 0L ; } processGaugeMetric ( service + "__" + fields [ i ] , val ) ; } JSONObject stats = ( JSONObject ) obj . get ( "dyn_o_mite" ) ; if ( stats == null ) { Logger . error ( "Missing key 'dyn_o_mite' in json response: " + json ) ; return ; } parseObjectMetrics ( service , stats ) ; }
parse the json payload and convert them to metrics . example json payload { " service " : " dynomite " , " source " : " dynomitemanager - i - 16ca1846 " , " version " : " 0 . 3 . 1 " , " uptime " : 40439 , " timestamp " : 1399064677 , " datacenter " : " dc1 " , " dyn_o_mite " : { " client_eof " : 0 , " client_err " : 0 , " client_connections " : 0 , " server_ejects " : 0 , " forward_error " : 0 , " fragments " : 0 , " stats_count " : 0 , " guage " : { } " 127 . 0 . 0 . 1 " : { " server_eof " : 0 , " server_err " : 0 , " server_timedout " : 0 , " server_connections " : 0 , " server_ejected_at " : 0 , " requests " : 0 , " request_bytes " : 0 , " responses " : 0 , " response_bytes " : 0 , " in_queue " : 0 , " in_queue_bytes " : 0 , " out_queue " : 0 , " out_queue_bytes " : 0 } } }
