If the light comes on then goes off, then the problem was a single isolated incident that hasn't reoccurred within a certain number of drive cycles. If it stays, you have a hard failure. Also, if the code defines as "knock sensor signal high/low or O2 sensor signal high/low, etc.", that doesn't necessarily mean that particular sensor is bad. It just means that sensor reported to the PCM something outside of it's allowed/expected normal operating range. Either there is/was a fault and the sensor detected it as it was supposed to do or the sensor is faulty and erroneously reported a fault that didn't/doesn't actually exist.
The the whole OBD thing is not to police the sensors. It's to point you towards the area where you should focus your diagnostics attention. It's up to the person diagnosing it to use all the info available to determine what the problem is, whether it be a "lying" sensor or an actual problem within the system that sensor monitors. Ever heard of "Don't shoot the messenger"? The sensor is the messenger in this sense.
If the light is on and not flashing and the engine is running fine/normal (no sudden drop in power or MPG), then it's probably an emissions code and nothing detrimental to the engine. Plenty of places will scan codes for free, so there's no reason not to at least have this first step done. Just be aware that, especially if you go to Autozone to have the code(s) read, they're very quick to try to sell you whatever sensor(s) the code(s) relate to. Many buy whatever sensor(s), replace them, have the code(s) cleared, then the same code returns. This means either the new sensor is faulty or the problem is not with the sensor, but with the system that the sensor monitors.
Just get your codes read and report back here so hopefully we can help you not waste time and money.