Skip to main content

Logging and Monitoring

 Application Logging and Monitoring

Application တစ်ခုက server ဒါမှမဟုတ် cloud မှာ run ရုံပဲဆိုရင်တော့ လွယ်ပါလိမ့်မယ်။ personal အမြင် အရဆိုရင်တော့ proper monotorings and alerts တွေ မရှိရင် application ကိုရပ်ထားတာ အကောင်းဆုံးပါပဲ။ ဘာလို့လဲဆိုတော့ ကိုယ့် application/service က ဘာတွေဖြစ်နေတယ်၊ ဘာ error တက်နေတယ်၊ users တွေက တကယ်ရောသုံးလို့ရရဲ့လား အစရှိတာတွေ သိဖို့လိုပါတယ်။ Application မှာ error တစ်ခုခု တက်တာနဲ့ ကိုယ်က သိဖို့လိုပါတယ်၊ user ကပြောမှသိတာမျိုးဆိုရင်တော့ အတော်ကိုအဆင်မပြေပါဘူး။ Bad VOC(Voice of Customers) တွေပဲရပြီး ဘယ်သူမှသုံးချင်တော့မှာမဟုတ်ပါဘူး။
ဒါတွေထဲက တစ်စိတ်တစ်ပိုင်းဖြေရှင်းဖို့အတွက် Logging and Alerts tools တွေအများကြီးရှိပါတယ်။
  1. Splunk
  2. ELK
  3. Graylog
  4. Etc...
ဒီထဲကမှ Splunk အကြောင်းကိုနည်းနည်း ပြောချင်ပါတယ်။
Splunk က log management and centralized logging tool တစ်ခုဖြစ်တယ်။
ဘာလို့ ဒီ log management ကိုသုံးရလဲ ဆိုတော့ ကိုယ့် Application/Service က very high performance နဲ့ very high QPS တွေနဲ့ run တယ်ဆိုရင် log တွေကို အလွယ်တကူကြည့်ဖို့ ရှာဖို့ဆိုတာ မလွယ််ပါဘူး။ Instances တွေအများကြီး သုံးထားရင်ပိုလိို့တောင်ဆိုးပါသေးတယ် request ကို ဘယ် instance က handle လုပ်သွားလဲတောင် သိဖို့မလွယ်ပါဘူး။ ဒီထဲကကမှ containerized architecture နဲ့ ဆိုရင် ပိုဆိုးသွားပါပြီ၊ ပုံမှန်ဆိုရင် logs တွေက container destory ဖြစ်တာနဲ့ အကုန်ပျောက်သွားမှာပါ။ အဲ့ဒါတွေကြောင့် centralized log management tools တွေသုံးဖို့လိုပါတယ်။

Splunk ဘယ်လို အလုပ်လုပ်လဲ/ ဘာတွေလိုအပ်လဲ

  1. Log server
  2. Log forwarder
အဲ့ဒါတွေလိုပါတယ်။ တစ်ခုရှိတာက Splunk က free မရပါဘူး ဝယ်သုံးရပါတယ်

1. Log Server

အခြေခံအားဖြင့်ဆိုရင်တော့ log server မှာ logs တွေသိမ်းမယ်၊ အဲ့မှာပဲ ရှာတာတွေ၊ alerts တွေ နဲ့ monitoring တွက် graph တွေ ကို logs ပေါ်အခြေခံပြီးတော့ setup လုပ်လို့ရပါတယ်။

2. Log forwarder

Log forwarder ကတော့ရှင်းပါတယ်။ သူ့နာမည် အတိုင်းပဲ logs တွေကို သတ်မှတ်ထားတဲ့ server ကို realtime forward လုပ်ပေးပါတယ်။ Applications ဒါမှမဟုတ် containers run တဲ့ server မှာပဲ forward လုပ်ရမယ့် log files ကို configure လုပ်ပေးရပါတယ်။

Log တွေကို ဘယ်လိုရှာကြမလဲ

ကြည့်ချင်တဲ့ application ရဲ့ sourcetype ပေါ်မူတည်ပြီး ကြည့်လို့လို့ရပါတယ်။ ကြည့်ချင်တဲ့အချိန်အပိုင်းအခြားနဲ့ ရှာချင်တဲ့ keyword လေးရိုက်ပြီးလဲ ရှာလို့ရပါတယ်။ ဥပမာ user တစ်ယောက်ရဲ့ action ကို ကြည့်ချင်တယ်ဆိုရင် logs ရိုက်ထားတဲ့ user id နဲ့ကြည့်ချင်တဲ့ အချိန်အပိုင်းခြားရွေးလိုက်ရင် အကုန်ကြည့်လို့ရပါပြီ။ Application မှာတော့ logs တွေကို စနစ်တကျ ရိုက်ထားဖို့လိုတာပေါ့ အဲ့ဒါကြောင့် အရင်တစ်ခါရေးခဲ့တဲ့ post လိုပဲ DevOps knowledge ရှိနေရင်တော့ပိုကောင်းပါတယ်။

Alerts တွေဘယ်လို အလုပ်လုပ်လဲ

Alerts တွေကိုလဲ logs တွေ ပေါ်အခြေခံပြီး လုပ်ပါမယ်။ ဥပမာ ကိုယ့် Application ရဲ့ log မှာ ERROR ဒါမှမဟုတ် Exception ဆိုတဲ့ text ကို 5မိနစ်တစ်ခါ Splunk ကိုရှာစေပြီး တွေ့တာနဲ့ alert email ကို trigger လုပ်ထားလို့ရပါတယ်။

Monitoring and Dashboard

Monitoring နဲ့ Dashboard တွေကိုလဲ ထုံးစံအတိုင်း log ပေါ် အခြေခံပြီး လိုအပ်သလို setup လုပ်ထားလို့ရပါတယ်။
ဥပမာ - ကိုယ်က alerts လဲ မလုပ်ထားချင်ဘူး စောင့်လဲစောင့်ကြည့်ချင်တဲ့ အနေအထားပေါ့၊ ဆိုကြပါစို့ Unauthorized/ Forbidden လိုဟာမျိုးဆိုရင် သာမာန် users တွေလဲ password မှားရိုက်တာတွေ၊ permission မရှိတဲ့ function တွေကို သွားကြည့်မိတာတွေဆိုရင်ဖြစ်တတ်တယ်။ Error လဲမဟုတ်ဘူး၊ ဒါပေမယ့် Unauthorized/ Forbidden တွေအရမ်းများရင်လဲ attack လုပ်ခံရတာဖြစ်နိုင်ပါတယ်။ ဒီလို အခြေနေမျိုးမှာလဲသုံးလို့ရပါတယ်။ ဒါကို Alerts အနေနဲ့လဲ occurrences က 5 minutes မှာ အခါ ၁၀၀ ထက်ပိုရင် Alert email trigger လုပ်ဆိုပြီးတော့လဲ setup လုပ်ထားလို့ရပါတယ်။
နောက်ထပ်ဥပမာ တစ်ခု အနေနဲ့ - ဘယ်functions တွေကို user access ဘယ်လောက်ရှိတယ် ဆိုတာမျိုးတွေ ကို analysis အနေနဲ့လဲ dashboard တွေ setup လုပ်ထားလို့ရပါတယ်။

Popular posts from this blog

Pigeon Myanmar's free Wireguard VPN

Pigeon Myanmar's free Wireguard VPN  Pigeon Myanmar ရဲ့ Free VPN service ကိုအသုံးပြုရန်အတွက် အောက်ပါ Telegram Chatbot ကို message ပို့ပြီး Config file ဒါမှမဟုတ် QR Code ကိုရယူနိုင်ပါတယ်။ အသုံးမပြုလိုသူများ၊ newvpn request မလုပ်ဖို့မတ္တာရပ်ခံအပ်ပါတယ်၊ client က limit ရှိတာကြောင့် လိုအပ်တဲ့သူတွေမရမှာစိုးလို့ပါ။ Telegram Chat Bot Telegram Chat Bot:  https://t.me/pigeonmyanmarbot Chat Bot မှာ /start ကိုလို့ပို့ပြီး သက်ဆိုင်ရာ Operation ကိုရေးပြီး VPN အသုံးပြုရန်အတွက် QR Code ဒါမှမဟုတ် Config file ရယူနိုင်ပါတယ်။ Telegram Account တစ်ခုကို client တစ်ခုသတ်မှတ်ထားဒါကြောင့် နောက်အကြိမ်တွေ ထပ်မှတ်ရယူပါကလည်း client အဟောင်းကိုသာ ရရှိတော့မှဖြစ်ပါတယ်။ QR Code/Config File ကို ပျောက်ပျက်သွားတဲ့အခါမှာလည်း ထပ်မံတောင်းခံ ကြည့်ရှူနိုင်ပါတယ်။   /newvpnqr - VPN QR Code ရယူရန်။ /newvpn - VPN Config File ရယူရန်။ VPN Installation and Setup သက်ဆိုင်ရာ Application ကိုအောက်ပါ link များမှ install လုပ်ပါ။  Application မှာ  + / Add a tunnel ခလုတ်နှိပ်ပါ။  Create from file or archive ...

How to use GIT? GIT ကိုဘယ်လို အသုံးပြုကြမလဲ (Cheat sheet)...

How to use GIT?  Git အသုံးပြုပုံကို နားလည်ကျွမ်းကျင်ဖို့ GIT ဘယ်လိုအလုပ်လုပ်လဲ ဆိုတာ နည်းနည်းတော့ သိထားဖို့လိုလိမ့်မယ်။  File ရဲ့ statuses တွေနဲ့ file transitions တွေကို သေချာ နားလည်ထားဖို့လိုတယ်။ File status မှာဆိုရင် file တစ်ခုကို git ကဘယ်အချိန်မှာ track စလုပ်လဲ၊ ဘယ်အချိန်မှာ modified, unmodified, staged statuses တွေဖြစ်သွားလဲဆိုတာတွေ နဲ့ File transitions မှာဆိုရင် file တစ်ခုက ဘယ် command run ရင် local repository မှာရှိတယ်။ ဘယ် command run ရင်တော့ remote repository (server) ကိုရောက်သွားလဲ ဆိုတာတွေကို အနည်းငယ်နားလည်ထားဖို့တော့လိုမယ်။ Git File Statuses Git မှာ file တွေကို track လုပ်နေတဲ့ statuses တွေရှိတယ်။ အဲ့ဒါတွေကတော့ အောက်ပါအတိုင်းဖြစ်တယ်။ Untracked Unmodified Modified Staged Untracked Status Untracked ဆိုတာက file တစ်ခုက ပထမဆုံး create လုပ်ပြီးတဲအချိန်မှာ git က အဲ့ file ကိုလုံးဝ track မလုပ်ရသေးတဲ့ file တွေက git မှာ untracked အနေနဲ့ရှိနေတယ်။ အဲ့ဒါကို git ကို စပြီး track လုပ်စေချင်တယ်ဆိုင်တော့ git add <file> command နဲ့ git ကို စ track လုပ်ခိုင်းလို့ရတယ်။ အဲ့လို git ad...

Understanding Git Flow - Branching Models

Understanding Git Flow - Branching Models Branching Model Software Development Team တစ်ခုမှာ ဆိုရင် latest released code တွေ၊ latest stable development code တွေ နဲ့  development in progress ဖြစ်နေတဲ့ code တွေ နဲ့ ဘယ် release version မှာ ဘယ် code တွေကို  release လုပ်ခဲ့တယ်ဆိုတာတွေကို စနစ်တကျ manage လုပ်ရပါတယ်။ အဲ့လို Team Collaboration လုပ်ရတဲ့အချိန်မှာဆို သင့်တော်ရာ Branching Models တစ်ခုခုကို ရွေးရပါတယ်။ မဟုတ်ရင်တော့ code conflict တွေနဲ့ unstable၊​ uncompleted  feature တွေကို ထိန်းသိမ်းရခက်ပါတယ်။ Popular of branching models Branching Models တွေထဲမှာမှ လူသုံးများပြီး ပေါ်ပြူလာ အဖြစ်ဆုံး Branching Model နှစ်ခုကတော့ အောက်ပါအတိုင်းနှစ်မျိုးရှိပါတယ်။ Git Flow Trunk Based Git Flow Main Branches Git Flow မှာ main branches အနေနဲ့ master နဲ့ develop ဆိုပြီးနှစ်ခုရှိပါတယ်။  Master(main)   Branch   Master branch ကတော့ latest features တွေထားပါတယ်။ master branch ဟာ နောက်ဆုံး release လုပ်ထားတဲ့ production မှာရှိနေတဲ့ code တွေနဲ့ ထပ်တူကျရပါမယ်။ Production မှာ အကြောင်းအမျ...