For all-around protection or if the plants are in full flower, you may apply diatomaceous earth evenly to soil that will not be disturbed for a few days, either in a thick ring around the base of plants or plant pots, or across soil beds. Additionally, be sure to reapply after irrigation sessions or rainstorms. Sprinkle a liberal but even layer of DE around infested areas and grow room/garden access routes, while protecting your mucous membranes from any airborne dust from the product. Diatomite is hydrophilic (attracted to water), so it could temporarily irritate your eyes, nose and mouth if precautions are not taken. It may be a day or two before any effect is noticeable, but infestations from pests like fungus gnats can be controlled with proper application and DE may be used as prophylactic pest control
this is a basic way to apply and it should work. Just dust an even layer across the bed and let that sit for a few days, like 4 or 5 days to be safe and it should rectify the small gnat infestation you have