code: func (n *NetworkServerAPI) GetGatewayStats(ctx context.Context, req *ns.GetGatewayStatsRequest) (*ns.GetGatewayStatsResponse, error) {
  	gatewayID := helpers.GetGatewayID(req)
  
  	start, err := ptypes.Timestamp(req.StartTimestamp)
  	if err != nil {
  		return nil, grpc.Errorf(codes.InvalidArgument, err.Error())
  	}
  
  	end, err := ptypes.Timestamp(req.EndTimestamp)
  	if err != nil {
  		return nil, grpc.Errorf(codes.InvalidArgument, err.Error())
  	}
  
  	metrics, err := storage.GetMetrics(storage.RedisPool(), storage.AggregationInterval(req.Interval.String()), "gw:"+gatewayID.String(), start, end)
  	if err != nil {
  		return nil, errToRPCError(err)
  	}
  
  	var resp ns.GetGatewayStatsResponse
  
  	for _, m := range metrics {
  		row := ns.GatewayStats{
  			RxPacketsReceived:   int32(m.Metrics["rx_count"]),
  			RxPacketsReceivedOk: int32(m.Metrics["rx_ok_count"]),
  			TxPacketsReceived:   int32(m.Metrics["tx_count"]),
  			TxPacketsEmitted:    int32(m.Metrics["tx_ok_count"]),
  		}
  
  		row.Timestamp, err = ptypes.TimestampProto(m.Time)
  		if err != nil {
  			return nil, errToRPCError(err)
  		}
  
  		resp.Result = append(resp.Result, &row)
  	}
  
  	return &resp, nil
  }
docs: // GetGatewayStats returns stats of an existing gateway.