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