I think ultimately it comes from giving thanks as we are directed in the Bible. Philippians 4:4 tells us to "Rejoice in the Lord alway: [and] again I say, Rejoice." It doesn't say "when we feel like it" or "when we are having a good day." It says "alway", we are to always rejoice regardless of what is going on.
Honestly, I can't say I'm always happy with everything that happens in my life. There are times when my job, my family, my car or my dog make me unhappy. Do I stop and say "Wow, I'm glad that just happened"? No, but I try not to dwell on the bad and find the good in the situation. I can always say, "I'm glad I have God in this situation." Then it is my responsibility to rejoice. To actually say, "Thank you God." and even to ask God to "Please allow me to grow from this experience and be able to help others because of the experience."
Just like these pictures. One is Black & White, and looks like a cold dreary morning. It is not a cheerful shot. The other one is colorful and makes me think of the promise of day. The sun about to break over the horizon and warm my face. In reality they are the same shot. One is devoid of color the other is full of color. The difference is in the choice of how they are viewed.
Stop dwelling on the negative and choose to be happy. Let it go and look for the good.
Well, it's time for bed so I'll get off my soapbox and wish you all a good night.
Choose to be happy!