Most of the time I am grateful is because of a joy. I cannot be grateful for my pain and suffering.
But I can be grateful for the opportunity it gives me.
Practicing gratitude in times of joy, will condition me to practice gratitude in difficult times.