sql server prometheus 監控


網上已經有了關於sql server prometheus 的exporter(同時也是官方推薦的)但是時間很長了,同時好多依賴沒有更新了
同時測試發現了一個bug,所以fork了一個版本的

代碼地址

https://github.com/rongfengliang/prometheus-mssql-exporter

幾個修改說明

  • 升級依賴
    prom-client&&tedious 基本應該算是當前最新的版本了,同時修改了以為升級prom-client造成的bug
    因為新版本的對於輸入的值嚴格進行了類型判斷,但是默認使用tedious 返回的為字符串,進行了類型轉換
    基本都為,如下的
 
const mssql_deadlocks = Number.parseFloat(rows[0][0].value);
  • sql 查詢問題
    原有一個sql 查詢,不兼容(刪除有問題的)
    bug 描述
 
 RequestError {message: "Invalid column name 'io_stall_queued_write_ms'.", code: "EREQUEST", number: 207, state: 1, class: 16, …}
  • docker file 修改
    升級版本,使用yarn 構建
 
FROM node:12.16.1-alpine
LABEL EMAIL="dalongrong"
RUN yarn config set registry https://registry.npm.taobao.org
# Create a directory where our app will be placed
RUN mkdir -p /usr/src/app
# Change directory so that our commands run inside this new directory
WORKDIR /usr/src/app
# Copy dependency definitions
COPY package.json *.js /usr/src/app/
# Install dependecies
RUN yarn  --production
# Expose the port the app runs in
EXPOSE 4000
# Serve the app
CMD ["node", "index.js"]
  • 添加ENCRYPT環境變量
    因為很多時候因為數據庫版本問題,造成無法支持高版本的tls,所以添加了ENCRYPT環境變量,方便鏈接
    使用參考:
 
docker run -e SERVER=192.168.56.101 -e ENCRYPT=false -e USERNAME=SA -e PASSWORD=qkD4x3yy -e DEBUG=app -p 4000:4000 --name prometheus-mssql-exporter dalongrong/prometheus-mssql-exporter

后續的規划

sql server 與myql ,pg, redis,相比暫時還沒有比較完備的metrics 說明,所以后期計划參考行業的一些最佳實踐,添加其他的一些metrics
同時也會參考who_is_active的提供的一些監控方案,將類似的metrics 暴露處理,同時pmm也是一個值得參考的業界成熟方案

參考資料

https://github.com/awaragi/prometheus-mssql-exporter
https://github.com/zhengwen09/database-profiler
https://github.com/tediousjs/tedious
https://github.com/siimon/prom-client
https://github.com/rongfengliang/prometheus-mssql-exporter


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM