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 joints and form part of the matrix of cartilage. The three-dimensional structure of these molecules enables them to trap water, which forms a gel and gives glycosaminoglycans their elastic properties.