%3CLINGO-SUB%20id%3D%22lingo-sub-1530562%22%20slang%3D%22en-US%22%3EIngest%20ProxySQL%20Metrics%20into%20the%20Azure%20Monitor%20Log%20Analytics%20Workspace%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1530562%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%20class%3D%22WordSection1%22%3E%0A%3CP%20class%3D%22MsoNormal%22%3EProxySQL%20have%20rich%20internal%20functioning%20metrics%20which%20could%20be%20accessed%20from%20its%20stats%20database%20through%20the%20Admin%20interface%2C%20and%20the%20stored%20metrics%20are%20the%20snapshot%20of%20a%20particular%20point%20of%20time%20when%20you%20select%20the%20metric%20table.%20When%20troubleshooting%20the%20problem%2C%20we%20need%20to%20review%20and%20accumulate%20the%20historical%20metrics%20data%20with%20powerful%20query%20functions%20like%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Flog-query%2Fquery-language%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Monitor%20Kusto%20Queries%3C%2FA%3E%20to%20help%20understand%20the%20overall%20status.%20In%20this%20blog%2C%20we%20will%20introduce%20how%20to%20post%20the%20metrics%20to%20Azure%20Monitor%20Log%20Analytics%20Workspace%20and%20leverage%20the%20powerful%20Kusto%20query%20language%20to%20monitor%20the%20ProxySQL%20statistics%20metrics.%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3E%3CSTRONG%3EAccess%20the%20ProxySQL%20Metrics%20for%20Monitoring%3C%2FSTRONG%3E%3A%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3E1.%20Connect%20the%20ProxySQL%20Admin%20interface%20through%20any%20client%20using%20MySQL%20protocol%20with%20the%20admin%20credential%20like%20below%3A%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3E%3CSPAN%3E%3CSPAN%20style%3D%22font-size%3A%2011.5pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Courier%20New'%3B%20color%3A%20%23e3e8ea%3B%20background%3A%20%23363232%3B%22%3Emysql%20-u%20admin%20-padmin%20-h%20127.0.0.1%20-P6032%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3E2.%20Access%20the%20statistics%20metrics%20by%20select%20query%20like%20below%20example%3A%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3E%3CSPAN%20class%3D%22crayon-e%22%3E%3CSPAN%20style%3D%22font-size%3A%2011.5pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Courier%20New'%3B%20color%3A%20white%3B%20background%3A%20%23363232%3B%22%3Eselect%20%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-size%3A%2011.5pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Courier%20New'%3B%20color%3A%20%23e3e8ea%3B%20background%3A%20%23363232%3B%22%3EClient_Connections_aborted%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-e%22%3E%3CSPAN%20style%3D%22font-size%3A%2011.5pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Courier%20New'%3B%20color%3A%20white%3B%20background%3A%20%23363232%3B%22%3Efrom%20%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-v%22%3E%3CSPAN%20style%3D%22font-size%3A%2011.5pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Courier%20New'%3B%20color%3A%20white%3B%20background%3A%20%23363232%3B%22%3Estats%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-sy%22%3E%3CSPAN%20style%3D%22font-size%3A%2011.5pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Courier%20New'%3B%20color%3A%20white%3B%20background%3A%20%23363232%3B%22%3E.%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-e%22%3E%3CSPAN%20style%3D%22font-size%3A%2011.5pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Courier%20New'%3B%20color%3A%20white%3B%20background%3A%20%23363232%3B%22%3Estats_mysql_global%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3E3.%20Please%20refer%20the%20metrics%20detail%20in%20%3CA%20href%3D%22https%3A%2F%2Fproxysql.com%2Fdocumentation%2Fstats-statistics%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fproxysql.com%2Fdocumentation%2Fstats-statistics%2F%3C%2FA%3E%2C%20there%20are%2018%20stats%20tables%20storing%20important%20monitoring%20data%20viz%20the%20front%20end%20and%20backend%20connections%2C%20query%20digest%2C%20GTID%2C%20prepared%20statements%20and%20etc.%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3E%3CSTRONG%3E%3CSPAN%20style%3D%22font-size%3A%209.0pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Segoe%20UI'%2Csans-serif%3B%22%3ENote%3A%20%3C%2FSPAN%3E%3C%2FSTRONG%3EProxySQL%20is%20an%20open%20source%20community%20tool.%20It%20is%20supported%20by%20Microsoft%20on%20a%20best%20effort%20basis.%20In%20order%20to%20get%20production%20support%20with%20authoritative%20guidance%2C%20you%20can%20evaluate%20and%20reach%20out%20to%20%5B%23%24dp14%5D%3CA%20href%3D%22https%3A%2F%2Fnam06.safelinks.protection.outlook.com%2F%3Furl%3Dhttps%3A%2F%2Fproxysql.com%2Fservices%2Fsupport%2F%26amp%3Bdata%3D02%7C01%7CAmol.Bhatnagar%40microsoft.com%7C648e1ab1ec23494dc5bd08d814d6de91%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637282260392282862%26amp%3Bsdata%3Dv7EoCThD9VAeoZOOwmxGqUlfDtu9W7FqCRN1ZhfSnEE%3D%26amp%3Breserved%3D0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EProxySQL%20Product%20support%3C%2FA%3E.%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3E%3CSTRONG%3EIngest%20the%20Metrics%20to%20external%20monitoring%20tool%20-%20Azure%20Monitor%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3E1.%20Assume%20you%20have%20installed%20ProxySQL%20on%20a%20Linux%20VM%20already%2C%20as%20the%20Admin%20interface%20is%20only%20allowed%20to%20access%20locally%2C%20we%20need%20to%20run%20the%20ingestion%20code%20side%20by%20side%20on%20the%20same%20VM.%20The%20ingestion%20sample%20code%20will%20query%20the%20ProxySQL%20stats%20metrics%20then%20post%20the%20data%20to%20the%20Logical%20Workspace%20in%20a%20regular%201-minute%20interval.%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3E2.%20Provision%20a%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Flearn%2Fquick-create-workspace%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ELog%20Analytics%20Workspace%3C%2FA%3E%20to%20store%20the%20posted%20metrics.%20The%20Ingestion%20sample%20code%20performs%20POST%20Azure%20Monitor%20custom%20log%20through%20HTTP%20REST%20API%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Fplatform%2Fdata-collector-api%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Fplatform%2Fdata-collector-api%3C%2FA%3E%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3E3.%20The%20ingestion%20sample%20code%20is%20developed%20with%20.NET%20Core%203.1%2C%20and%20you%20could%20check%20out%20from%20the%20GitHub%20repo%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fazure-mysql%2Ftree%2Fmaster%2FProxySQLMetricsIngest%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FAzure%2Fazure-mysql%2Ftree%2Fmaster%2FProxySQLMetricsIngest%3C%2FA%3E.%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3E%3CSTRONG%3EDetail%20usage%20instructions%20about%20the%20sample%20ingesting%20code%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3E1.%20Install%20.NET%20Core%20on%20the%20Linux%20VM%20where%20ProxySQL%20is%20located.%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3ERefer%26nbsp%3Bto%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fdotnet%2Fcore%2Finstall%2Flinux-package-manager-ubuntu-1804%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fdotnet%2Fcore%2Finstall%2Flinux-package-manager-ubuntu-1804%3C%2FA%3E%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%20style%3D%22margin-left%3A%20.5in%3B%22%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Courier%20New'%3B%22%3Ewget%26nbsp%3B-q%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fpackages.microsoft.com%2Fconfig%2Fubuntu%2F18.04%2Fpackages-microsoft-prod.deb%26nbsp%3B-O%26nbsp%3Bpackages-microsoft-prod.deb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fpackages.microsoft.com%2Fconfig%2Fubuntu%2F18.04%2Fpackages-microsoft-prod.deb%26nbsp%3B-O%26nbsp%3Bpackages-microsoft-prod.deb%3C%2FA%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%20style%3D%22margin-left%3A%20.5in%3B%22%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Courier%20New'%3B%22%3Esudo%26nbsp%3Bdpkg%26nbsp%3B-i%26nbsp%3Bpackages-microsoft-prod.deb%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%20style%3D%22margin-left%3A%20.5in%3B%22%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Courier%20New'%3B%22%3Esudo%26nbsp%3Badd-apt-repository%26nbsp%3Buniverse%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%20style%3D%22margin-left%3A%20.5in%3B%22%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Courier%20New'%3B%22%3Esudo%26nbsp%3Bapt-get%26nbsp%3Bupdate%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%20style%3D%22margin-left%3A%20.5in%3B%22%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Courier%20New'%3B%22%3Esudo%26nbsp%3Bapt-get%26nbsp%3Binstall%26nbsp%3Bapt-transport-https%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%20style%3D%22margin-left%3A%20.5in%3B%22%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Courier%20New'%3B%22%3Esudo%26nbsp%3Bapt-get%26nbsp%3Bupdate%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%20style%3D%22margin-left%3A%20.5in%3B%22%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Courier%20New'%3B%22%3Esudo%26nbsp%3Bapt-get%26nbsp%3Binstall%26nbsp%3Bdotnet-sdk-3.1%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3E2.%20Get%20the%20%3CSTRONG%3ECustom%20ID%3C%2FSTRONG%3E%20and%20%3CSTRONG%3EShared%20Key%3C%2FSTRONG%3E%20of%20the%20Log%20Analytics%20Workspace%3C%2FP%3E%0A%3CP%20class%3D%22MsoListParagraphCxSpFirst%22%20style%3D%22text-indent%3A%20-.25in%3B%22%3E1)%3CSPAN%20style%3D%22font%3A%207.0pt%20'Times%20New%20Roman'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3EIn%20the%20Azure%20portal%2C%20locate%20your%20%3CSTRONG%3ELog%20Analytics%20workspace%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%20class%3D%22MsoListParagraphCxSpMiddle%22%20style%3D%22text-indent%3A%20-.25in%3B%22%3E2)%3CSPAN%20style%3D%22font%3A%207.0pt%20'Times%20New%20Roman'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3ESelect%26nbsp%3B%3CSTRONG%3EAdvanced%20Settings%3C%2FSTRONG%3E%26nbsp%3Band%20then%26nbsp%3BConnected%20Sources.%3C%2FP%3E%0A%3CP%20class%3D%22MsoListParagraphCxSpMiddle%22%20style%3D%22text-indent%3A%20-.25in%3B%22%3E3)%3CSPAN%20style%3D%22font%3A%207.0pt%20'Times%20New%20Roman'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3ETo%20the%20right%20of%26nbsp%3B%3CSTRONG%3EWorkspace%20ID%3C%2FSTRONG%3E%2C%20select%20the%20copy%20icon%2C%20and%20then%20paste%20the%20ID%20as%20the%20value%20of%20the%26nbsp%3BCustomer%20ID%26nbsp%3Binput%20for%20the%20sample%20application%20input.%3C%2FP%3E%0A%3CP%20class%3D%22MsoListParagraphCxSpLast%22%20style%3D%22text-indent%3A%20-.25in%3B%22%3E4)%3CSPAN%20style%3D%22font%3A%207.0pt%20'Times%20New%20Roman'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3ETo%20the%20right%20of%26nbsp%3B%3CSTRONG%3EPrimary%20Key%3C%2FSTRONG%3E%2C%20select%20the%20copy%20icon%2C%20and%20then%20paste%20the%20ID%20as%20the%20value%20of%20the%26nbsp%3BShared%20Key%26nbsp%3Binput%20for%20the%20sample%20application%20input.%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3E3.%20Checkout%20the%20sample%20code%20and%20run%3A%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%20style%3D%22margin-left%3A%20.5in%3B%22%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Courier%20New'%3B%22%3Egit%20clone%20%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fazure-mysql%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FAzure%2Fazure-mysql%3C%2FA%3E%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%20style%3D%22margin-left%3A%20.5in%3B%22%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Courier%20New'%3B%22%3Ecd%20ProxySQLMetricsIngest%2F%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%20style%3D%22margin-left%3A%20.5in%3B%22%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Courier%20New'%3B%22%3Edotnet%20build%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%20style%3D%22margin-left%3A%20.5in%3B%22%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20line-height%3A%20107%25%3B%20font-family%3A%20'Courier%20New'%3B%22%3Esudo%20dotnet%20run%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%20style%3D%22text-indent%3A%20.25in%3B%22%3EHere%20are%20some%20details%20about%20the%20sample%3A%3C%2FP%3E%0A%3CP%20class%3D%22MsoListParagraphCxSpFirst%22%20style%3D%22text-indent%3A%20-.25in%3B%22%3E1)%3CSPAN%20style%3D%22font%3A%207.0pt%20'Times%20New%20Roman'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3EIt%20is%20a%20console%20application%20which%20will%20ask%20for%20the%20input%20of%20the%20connection%20string%20for%20ProxySQL%20Admin%20Interface%2C%20(Log%20Workspace)%20custom%20ID%20and%20Shared%20key.%3C%2FP%3E%0A%3CP%20class%3D%22MsoListParagraphCxSpMiddle%22%20style%3D%22text-indent%3A%20-.25in%3B%22%3E2)%3CSPAN%20style%3D%22font%3A%207.0pt%20'Times%20New%20Roman'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3EThe%20sample%20currently%20register%20a%201-minute%20timer%20to%20periodically%20access%20the%20ProxySQL%20stats%20tables%20through%20MySQL%20protocol%20and%20post%20data%20into%20the%20Log%20Analytics%20Workspace%3C%2FP%3E%0A%3CP%20class%3D%22MsoListParagraphCxSpMiddle%22%20style%3D%22text-indent%3A%20-.25in%3B%22%3E3)%3CSPAN%20style%3D%22font%3A%207.0pt%20'Times%20New%20Roman'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3EEach%20ProxySQL%20stats%20table%20name%20would%20be%20used%20as%20the%20Custom%20Log%20Type%20Name%2C%20and%20the%20Log%20Analytics%20will%20automatically%20add%20_CL%20suffix%20to%20generate%20the%20complete%20Custom%20Log%20Type%20Name.%20For%20example%2C%20the%20stats%20table%20%3CI%3Estats_memory_metrics%3C%2FI%3E%20will%20become%20%3CI%3Estats_memroy_metrics_CL%3C%2FI%3E%20in%20the%20Custom%20Logs%20list.%20Below%20is%20the%20example%20screenshot%20within%20the%20Log%20Analytics%20Workspace.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorEdwin_Song_2%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22blog_pic_1.png%22%20style%3D%22width%3A%20680px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F206200iA924F37B950D82D3%2Fimage-dimensions%2F680x261%3Fv%3D1.0%22%20width%3D%22680%22%20height%3D%22261%22%20title%3D%22blog_pic_1.png%22%20alt%3D%22blog_pic_1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22MsoListParagraphCxSpLast%22%20style%3D%22text-indent%3A%20-.25in%3B%22%3E4)%3CSPAN%20style%3D%22font%3A%207.0pt%20'Times%20New%20Roman'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3EThe%20sample%20code%20also%20post%20the%20error%20logs%20in%20%2Fvar%2Flib%2Fproxysql%2Fproxysql.log%20to%20the%20Log%20Analytics%20Workspace%20as%20Custom%20Log%20Type%3A%20PSLogs_CL%2C%20to%20get%20the%20file%20read%20permission%2C%20please%20execute%20%22sudo%20dotnet%20run%22.%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3E4.%20Use%20Kusto%20query%20in%20Log%20Analytics%20Workspace%20to%20operate%20the%20ProxySQL%20metrics%20data.%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3EPlease%20be%20noticed%20that%20all%20the%20ProxySQL%20stats%20table%20values%20are%20set%20to%20string%2C%20so%20need%20convert%20it%20to%20number%20in%20Kusto%20query.%20Below%20is%20the%20example%20to%20render%20a%20time%20chart%20of%20the%20memory%20usage%20about%20ProxySQL%20internal%20module%20SQLLite.%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22blog_pic_2.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F206201i6C29A84535CF2364%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22blog_pic_2.png%22%20alt%3D%22blog_pic_2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%20style%3D%22margin-bottom%3A%200in%3B%20line-height%3A%20normal%3B%20text-autospace%3A%20none%3B%22%3E%3CSTRONG%3EDisclaimer%3C%2FSTRONG%3E%3A%20This%20sample%20code%20is%20available%20AS%20IS%20with%20no%20warranties%20and%20support%20from%20Microsoft.%20Please%20raise%20an%20issue%20in%20Github%20if%20you%20encounter%20any%20issues%20and%20I%20will%20try%20our%20best%20to%20address%20it.%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%20style%3D%22margin-bottom%3A%200in%3B%20line-height%3A%20normal%3B%20text-autospace%3A%20none%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22MsoNormal%22%20style%3D%22margin-bottom%3A%200in%3B%20line-height%3A%20normal%3B%20text-autospace%3A%20none%3B%22%3EIf%20you%20have%20trouble%20setting%20up%20ProxySQL%20on%20Azure%20Database%20for%20MySQL%2C%20please%20contact%20the%20Azure%20Database%20for%20MySQL%20team%20at%20%3CA%20href%3D%22mailto%3AAskAzureDBforMySQL%40service.microsoft.com%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAskAzureDBforMySQL%40service.microsoft.com%3C%2FA%3E%3C%2FP%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1530562%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22blog_teaser.png%22%20style%3D%22width%3A%20671px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F206196i62604532A222A036%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22blog_teaser.png%22%20alt%3D%22ProxySQL%20Metrics%20to%20Azure%20Monitor%20Log%20Analytics%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EProxySQL%20Metrics%20to%20Azure%20Monitor%20Log%20Analytics%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EProxySQL%20have%20rich%20internal%20functioning%20metrics%20which%20could%20be%20accessed%20from%20its%20stats%20database%20through%20the%20Admin%20interface%2C%20and%20the%20stored%20metrics%20are%20the%20snapshot%20of%20a%20particular%20point%20of%20time%20when%20you%20select%20the%20metric%20table.%20When%20troubleshooting%20the%20problem%2C%20we%20need%20to%20review%20and%20accumulate%20the%20historical%20metrics%20data%20with%20powerful%20query%20functions%20like%20to%20help%20understand%20the%20overall%20status.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Microsoft

 

ProxySQL have rich internal functioning metrics which could be accessed from its stats database through the Admin interface, and the stored metrics are the snapshot of a particular point of time when you select the metric table. When troubleshooting the problem, we need to review and accumulate the historical metrics data with powerful query functions like Azure Monitor Kusto Queries to help understand the overall status. In this blog, we will introduce how to post the metrics to Azure Monitor Log Analytics Workspace and leverage the powerful Kusto query language to monitor the ProxySQL statistics metrics.

Access the ProxySQL Metrics for Monitoring:

1. Connect the ProxySQL Admin interface through any client using MySQL protocol with the admin credential like below:

mysql -u admin -padmin -h 127.0.0.1 -P6032

2. Access the statistics metrics by select query like below example:

select Client_Connections_aborted from stats.stats_mysql_global

3. Please refer the metrics detail in https://proxysql.com/documentation/stats-statistics/, there are 18 stats tables storing important monitoring data viz the front end and backend connections, query digest, GTID, prepared statements and etc.

Note: ProxySQL is an open source community tool. It is supported by Microsoft on a best effort basis. In order to get production support with authoritative guidance, you can evaluate and reach out to ProxySQL Product support.

Ingest the Metrics to external monitoring tool - Azure Monitor:

1. Assume you have installed ProxySQL on a Linux VM already, as the Admin interface is only allowed to access locally, we need to run the ingestion code side by side on the same VM. The ingestion sample code will query the ProxySQL stats metrics then post the data to the Logical Workspace in a regular 1-minute interval.

2. Provision a Log Analytics Workspace to store the posted metrics. The Ingestion sample code performs POST Azure Monitor custom log through HTTP REST API: https://docs.microsoft.com/en-us/azure/azure-monitor/platform/data-collector-api

3. The ingestion sample code is developed with .NET Core 3.1, and you could check out from the GitHub repo https://github.com/Azure/azure-mysql/tree/master/ProxySQLMetricsIngest.

Detail usage instructions about the sample ingesting code:

1. Install .NET Core on the Linux VM where ProxySQL is located.

Refer to https://docs.microsoft.com/dotnet/core/install/linux-package-manager-ubuntu-1804

 

wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft...

sudo dpkg -i packages-microsoft-prod.deb

sudo add-apt-repository universe

sudo apt-get update

sudo apt-get install apt-transport-https

sudo apt-get update

sudo apt-get install dotnet-sdk-3.1

2. Get the Custom ID and Shared Key of the Log Analytics Workspace

1)      In the Azure portal, locate your Log Analytics workspace.

2)      Select Advanced Settings and then Connected Sources.

3)      To the right of Workspace ID, select the copy icon, and then paste the ID as the value of the Customer ID input for the sample application input.

4)      To the right of Primary Key, select the copy icon, and then paste the ID as the value of the Shared Key input for the sample application input.

3. Checkout the sample code and run:

git clone https://github.com/Azure/azure-mysql

cd ProxySQLMetricsIngest/

dotnet build

sudo dotnet run

Here are some details about the sample:

1)      It is a console application which will ask for the input of the connection string for ProxySQL Admin Interface, (Log Workspace) custom ID and Shared key.

2)      The sample currently register a 1-minute timer to periodically access the ProxySQL stats tables through MySQL protocol and post data into the Log Analytics Workspace

3)      Each ProxySQL stats table name would be used as the Custom Log Type Name, and the Log Analytics will automatically add _CL suffix to generate the complete Custom Log Type Name. For example, the stats table stats_memory_metrics will become stats_memroy_metrics_CL in the Custom Logs list. Below is the example screenshot within the Log Analytics Workspace.

 

blog_pic_1.png

 

 

4)      The sample code also post the error logs in /var/lib/proxysql/proxysql.log to the Log Analytics Workspace as Custom Log Type: PSLogs_CL, to get the file read permission, please execute "sudo dotnet run". 

4. Use Kusto query in Log Analytics Workspace to operate the ProxySQL metrics data.

Please be noticed that all the ProxySQL stats table values are set to string, so need convert it to number in Kusto query. Below is the example to render a time chart of the memory usage about ProxySQL internal module SQLLite.

blog_pic_2.png

 

Disclaimer: This sample code is available AS IS with no warranties and support from Microsoft. Please raise an issue in Github if you encounter any issues and I will try our best to address it.

 

If you have trouble setting up ProxySQL on Azure Database for MySQL, please contact the Azure Database for MySQL team at AskAzureDBforMySQL@service.microsoft.com