It often follows some basic rule, which we call the discernment of the Spirit, meaning there can be different types of spirit – the Holy Spirit, the human spirit and the Evil Spirit. Thus you have to make sure or at least confident and reasonable enough it is not the latter two. In other word, you have to rule out them out first.
By this rule, the Evil Spirit is dangerous and destructive to your spiritual life, our human spirit is not that destructive but usually does not have real effect on your growth. It is the Holy Spirit that can really edify and make you grow in the Lord.
Discernment should always call for another person or a group of mature Christians to help you to figure that it is really the Holy Spirit. Some basic rule, like being said, is whether it is in line with the Church’s teaching and the Bible. These may not necessary be from the Holy Spirit for you but at least they are not wrong or against the Church.
After that it should be tested, in the short and the long run. The latter means, does it bear good fruit or not?
The Holy Spirit brings good fruit, and unlike the Evil One, it will bring you peace in yourself.