Mental Fog is normal
When transitioning into ketosis your body will lose its main source of fuel, carbohydrates(glucose). If you have never followed a low carb high fat diet(LCHF), this will be a totally new thing for your mind and body.
When your body is burning through the last glycogen stores it will then look for more, and won't initially know where to look for energy. In this phase it's common to have some brain fog, become easily irritated and possibly experience headaches.
The best thing to do is to stay as low carb as possible, forcing the body to use up all of the glycogen stores faster and then moving onto fat as a fuel.
Keto Flu, Headache
Not everyone will experience a headache when transitioning into ketosis, it depends on how easily your body is able to change from burning carbohydrates to burning fats.
For most people their body has been used to burning carbohydrates for fuel their whole life, so it can take a small adjustment period which unfortunately can include the Keto Flu usually accompanied by a headache.
But hang in there, this won't last for long, especially if taking exogenous ketones. And when your body is in ketosis and your mind and body are working better than ever you'll be grateful that you hung in there.
Remember, ketones are a high quality, efficient fuel source for the mind and body. So once you start converting your fats into ketones your brain function becomes optimised.