One adult fungus gnat can lay up to 300 eggs in one week, so every one you get rid of makes a huge dent in the future population.
Gnats, particularly fungus gnats, are attracted to sweet substances like sugar, and this can be used to create effective traps. Get some strong ass double strength vinegar place in container add some sugar to lure them to the vinegar, squirt of dish soap will form a layer on top as it settles, they can go in but wont get out.
While that's happening, you need to attack the soil where they lay eggs too, dry up your environment, and sprinkle a little cinnamon powder through the soil if they happen to be fungus gnats- strong natural fungicide.
Ground cloves are also effective.
A nuclear option, if needed, is Isopropyl alcohol with a high concentration (90%) typically evaporates very fast, leaving no trace it was there. Rubbing alcohol is very effective for soft-bodied pests, including mealybugs, scale, spider mites, and aphids. It's especially popular for pests with a waxy coating because that coating makes them difficult to kill with other pest treatments. Instakill.
Direct Spray: Mix half a cup of water, half a cup of isopropyl alcohol, and a teaspoon of dish liquid in a spray bottle, then spray the mixture directly on the gnats.
Soil Treatment: Dilute isopropyl alcohol with water (e.g., an 8:1 ratio of water to alcohol) and spray the soil where gnats are breeding, ensuring the top few inches of soil stay dry.
UV-B irradiation, particularly at night, can suppress powdery mildew, UV-B irradiance around 1 W/m2 for approximately 5-10 minutes per night has shown significant results. UV-B inhibits germination, infection, colony expansion, and sporulation of powdery mildew pathogens. Exposure during the night is more effective as it circumvents the counteracting effects of blue light and UV-A radiation. It's important to note that excessive UV-B exposure can be phytotoxic, so it's crucial to limit exposure time and intensity if you do decide to use it. long-term solution, PM no more.
Goodluck.