The chemical reactions and pathways involving glycosaminoglycans, any one of a group of polysaccharides that contain amino sugars. Formerly known as mucopolysaccharides, they include hyaluronic acid and chondroitin, which provide lubrication in joint.