Precision luminosity measurements are an essential ingredient to cross section measurements at the LHC, needed to determine fundamental parameters of the standard model and to constrain or discover beyond-the-standard-model phenomena. The luminosity measurement of the CMS detector at the LHC, using proton-proton collisions at 13 TeV during the 2015-2018 data-taking period (“Run 2”), is reported. The absolute luminosity scale is obtained with beam-separation (“van der Meer”) scans, and several systematic uncertainty sources are studied. Additional contributions to the total uncertainty in the integrated luminosity originate from the linearity and stability of the detectors used in the luminosity measurement throughout the data-taking period. A novel method to improve the luminosity integration with the physics process Z → μ+μ- is explored.