iamseth/oracledb_exporter 是一个挺不错的 oracle prometheus exporter ,但是因为oracle golang 驱动的问题,不是很方便
(构建,使用),所以基于godror/godror 调整了一个版本(很简单,替换一个依赖包就可以了),以下是参考说明
修改的文件
go.mod
module github.com/iamseth/oracledb_exporter
go 1.14
require (
github.com/BurntSushi/toml v0.3.1
github.com/godror/godror v0.20.10
github.com/prometheus/client_golang v1.0.0
github.com/prometheus/common v0.6.0
gopkg.in/alecthomas/kingpin.v2 v2.2.6
)
main.go
package main
import (
"bytes"
"context"
"crypto/sha256"
"database/sql"
"errors"
"hash"
"io"
"net/http"
"os"
"strconv"
"strings"
"sync"
"time"
"github.com/BurntSushi/toml"
_ "github.com/godror/godror"
"fmt"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/log"
"gopkg.in/alecthomas/kingpin.v2"
//Required for debugging
//_ "net/http/pprof"
)
Docker 镜像(基于oraclelinux)
FROM golang:1.15 AS build
WORKDIR /go/src/oracledb_exporter
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn
COPY . .
RUN go build -v -ldflags "-X main.Version=${VERSION} -s -w"
FROM oraclelinux:7-slim
ARG release=19
ARG update=9
RUN yum -y install oracle-release-el7 &&
yum -y install oracle-instantclient${release}.${update}-basic &&
rm -rf /var/cache/yum &&
yum clean all
COPY --from=build /go/src/oracledb_exporter/oracledb_exporter /oracledb_exporter
ADD ./default-metrics.toml /default-metrics.toml
EXPOSE 9161
ENTRYPOINT ["/oracledb_exporter"]
说明
具体的使用方法没变,还是以前的方法,只是构建以及使用简单了
参考资料
https://github.com/iamseth/oracledb_exporter
https://github.com/rongfengliang/oracledb_exporter
https://www.cnblogs.com/rongfengliang/p/14109740.html
https://github.com/godror/godror