It’s a complex system of cellular receptors and substances that activate them, and the receptors can become upregulated and downregulated. Histamine is also a pro-inflammatory substance.
I do better with my insomnia and autoimmune disorders if I am… attentive towards carbohydrate intake. Less sugar is better, slower carbohydrates are better. (I can reliably induce an insomnia awakening at precisely 05:30 by eating dessert after dinner. I’m not yet sure why or how exactly, but the histamine connection makes sense. It also has to do with cortisol I believe.) However, I am also more alert and sharp if I get enough carbs – including sugar. At the right time of day.
Here’s my source for histamine being involved in glucose metabolism: Histamine metabolism in diabetes mellitus and vascular disease, dr. Dalvir Gill’s 1991 PhD thesis: https://discovery.ucl.ac.uk/id/eprint/10120875/
Regarding histamine as an alertness neurotransmitter, I point to early antihistamine medication being sedative. This is because early antihistamines were molecules small enough to cross the blood-brain barrier. Histamine receptors in the brain regulate alertness. As well as the hunger response, interestingly. Old allergy meds make you hungry and then you pass out.