For prognostics and health management (PHM) of mechanical systems, a core task is to predict machine remaining useful life (RUL). Currently, deep structures with automatic feature learning, such as long short-term memory (LSTM), have achieved great performances for RUL prediction. However, the conventional LSTM network only uses the learned features at last time step for regression or classification, which is not efficient. Besides, some handcrafted features with domain knowledge may convey additional information for the prediction of RUL. It is thus highly motivated to integrate both those handcrafted features and automatically learned features for RUL prediction. In this paper, we propose an attention based deep learning framework for machine RUL prediction. The LSTM network is employed to learn sequential features from raw sensory data. Meanwhile, the proposed attention mechanism is able to learn the importance of features and time steps, and assign larger weights to more important ones. Moreover, a feature fusion framework is developed to combine the handcrafted features with automatically learned features to boost the performance of RUL prediction. Extensive experiments have been conducted on two real datasets and experimental results demonstrate that our proposed approach outperforms the state-of-the-arts.