How to make my thoughts non influencial on my happiness and presence? I feel like I am ruled by my mind and it's illogical behaviour what to do. Thanks
There are several Sutta that deal with this namely;


Dvedhavitakka Sutta: Two Sorts of Thinking
Vitakkasanthana Sutta: The Relaxation of Thoughts


They are very self explanatory

There is another Sutta that will be helpful -- this one in particular will help understanding the cause of the particular thoughts you are having:


Tanha Sutta: Craving


If you want to take it to the next level yet study "the 18 mental explorations" and "the 36 states of attachment", mentioned in this sutta:


Salayatana-vibhanga Sutta: An Analysis of the Six Sense-media


These are to be studied and remembered, they are quite easy to understand and i recommend just writing them down. This will be very useful in shedding light on how the mind works in general.

If you are having obsessive thoughts that are making you restless you might also consider these things ;


Settling your quarrels


  
  Avoiding restless people &amp; seeking out calm people
  




  "Monks, when the mind is agitated,[3] that is the wrong time to cultivate the enlightenment-factors of investigation-of-states, of energy, of rapture. Why? An agitated mind is hard to calm through these factors.
  "When the mind is agitated, that is the right time to cultivate the enlightenment-factors of tranquillity, concentration, equanimity. Why? Because an agitated mind is easy to calm[4] through these factors.
  
  There is quietude of mind; frequently giving wise attention to it — that is the denourishing of the arising of restlessness and remorse that have not yet arisen, and of the increase and strengthening of restlessness and remorse that have already arisen. — SN 46:51
  
  Six things are conducive to the abandonment of restlessness and remorse:
  1. Knowledge and pondering of the Dhamma;
  2. Asking questions about the Dhamma;
  3. Familiarity with the Vinaya (the Code of Monastic Discipline, and for lay followers, with the principles of moral conduct);
  4. Association with those mature in age and experience, who possess dignity, restraint and calm
  5. Noble friendship;
  6. Suitable conversation.
  (List from commy to satipatthana sutta)



Practice not getting involved in conflicts and restraint of speech leading to much discussion



  Moggallana, should you train yourself: 'I will speak no confrontational speech.' That is how you should train yourself. When there is confrontational speech, a lot of discussion can be expected. When there is a lot of discussion, there is restlessness. One who is restless becomes unrestrained. Unrestrained, his mind is far from concentration. (Nodding sutta)



Lower your expectation in regards to being liked or being attended
to properly by others


  "Furthermore, Moggallana, should you train yourself: 'I will not visit families with my pride[3] lifted high.' That is how you should train yourself. Among families there are many jobs that have to be done, so that people don't pay attention to a visiting monk. If a monk visits them with his trunk lifted high, the thought will occur to him, 'Now who, I wonder, has caused a split between me and this family? The people seem to have no liking for me.' Getting nothing, he becomes abashed. Abashed, he becomes restless. Restless, he becomes unrestrained. Unrestrained, his mind is far from concentration.



Training supportive mediations such as ie Metta, even if done very briefly will snowball and be of great benefit.

Mindfulness is always useful. Choose wisely which thoughts and themes you let stay in charge and where effort is directed.

Gl