The chemical reactions and pathways involving glucocorticoids, hormonal C21 corticosteroids synthesized from cholesterol. Glucocorticoids act primarily on carbohydrate and protein metabolism, and have anti-inflammatory effects.