A general rule is that the rivet should have a diameter of at least three times the thickness of the thickest sheet that is being joined. According to the military standard, so the bucked counter head diameter of the rivet joint must be larger than 1.4 times the diameter of the shank. The height must extend to 0.3 times the diameter of the shank. With all mentioned parameters, you can calculate the desired length of the rivet. The allowance is normally about 1.5D.
For example, two pieces of 0.050 inch (1.27 mm) sheet are to be riveted together. The proper diameter rivet would be 3 x 0.050=0.150 inch (3 x 1.27=3.81 mm).
A 5/32” rivet (0.156 inch, 3.96 mm) would be used. The metal thickness is 0.050+0.050=0.10 inch (1.27+1.27=2.54 mm), and 1.5D is 0.234 inch (5.94 mm), so the total length would have to be 0.10 + 0.234=0.334 inch (1.27+5.94=7.21 mm) for the rivet.
See image below: