The Prophet ﷺ said: There is jealousy which Allah loves and jealousy which Allah hates. That which Allah loves is jealousy regarding a matter of doubt, and that which Allah hates is jealousy regarding something which is not doubtful. There is pride which Allah hates and pride which Allah loves. That which Allah loves is a man's pride when fighting and when giving sadaqah and that which Allah hates is pride shown by oppression. The narrator Musa said: "by boasting." (Using translation from Abū Dāʾūd 2659)
أَنَّ النَّبِيَّ ﷺ كَانَ يَقُولُ «مِنَ الْغَيْرَةِ مَا يُحِبُّ اللهُ وَمِنَ الْغَيْرَةِ مَا يُبْغِضُ اللهُ فَأَمَّا الْغَيْرَةُ الَّتِي يُحِبُّهَا اللهُ فَالْغَيْرَةُ فِي الرِّيبَةِ وَأَمَّا الْغَيْرَةُ الَّتِي يُبْغِضُهَا اللهُ فَالْغَيْرَةُ فِي غَيْرِ رِيبَةٍ وَإِنَّ مِنَ الْخُيَلَاءِ مَا يُحِبُّ اللهُ وَمِنْهَا مَا يُبْغِضُ اللهُ فَأَمَّا الْخُيَلَاءُ الَّتِي يُحِبُّ اللهُ فَاخْتِيَالُ الرَّجُلِ نَفْسَهُ عِنْدَ الصَّدَقَةِ وَالْقِتَالِ وَأَمَّا الْخُيَلَاءُ الَّتِي يُبْغِضُ اللهُ فَاخْتِيَالُهُ فِي الْبَغْيِ وَالْفُجُورِ»