Mid-infrared absorbers based on metamaterials are investigated intensively for gas detection applications, owing to its ability to achieve excellent light absorption by manipulating electromagnetic waves. Herein, we present a metamaterial absorber for the ultra-compact optical gas sensor. This absorber has 99.9% absorption at 6.2 μm. The full width at half-maximum of the peak was 720 nm. As a sensor, the absorber had an average linear spectral sensitivity of 876 nm/RIU and a detection limit of 1.141×10-5 RIU, when the RI of the gas medium varied between 1 and 1.05. The designed absorber would have great potential application in guiding the design of optical gas sensors.