Joy - the second fruit of the spirit in Galatians 5:22. John 15:11 Jesus says "I have told you these things so that you will be filled with my joy. Yes, your joy will overflow."
If you are thankful for something, it will bring you joy even when things aren't going well. We need to rejoice, even in our trials, which I'm sure is easier said than done at times, but if we try hard enough - even in times of troubles - we can find something to be grateful for which will bring us joy.
One of my favorite readings is Romans 5:3-5. I go there whenever I'm stressed or there is something going on that I need to give to God.
"We can rejoice, too, when we run into problems and trials, for we know that they help us develop endurance. And endurance develops strength of character, and character strengthens our confident hope of salvation. And this hope will not lead to disappointment. For we know how dearly God loves us, because he has given us the Holy Spirit to fill our hearts with his love."