diff --git a/Dockerfile b/Dockerfile index 1c98cb0..a54bcce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,7 +32,6 @@ ARG GOARCH=amd64 # Keep Go's build cache between builds. # https://github.com/golang/go/issues/27719#issuecomment-514747274 # --tags "${TAGS}" -RUN echo "${VERSION}" RUN --mount=type=cache,sharing=locked,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ --mount=type=secret,id=git_creds,dst=/root/.netrc \ diff --git a/app/bff-gomono/cmd/cmd.go b/app/bff-gomono/cmd/cmd.go index 429884a..c214ac9 100644 --- a/app/bff-gomono/cmd/cmd.go +++ b/app/bff-gomono/cmd/cmd.go @@ -75,7 +75,7 @@ func newApp(register *conf.Register, logger klog.Logger, regstr registry.Registr hs, ), kratos.Registrar(regstr), - kratos.Endpoint(&url.URL{Scheme: "http", Host: register.Endpoints[0]}), // 指定服务地址,该地址会提交给注册中心,如果不指定,那么将注册容器内部地址,导致外部无法访问 + kratos.Endpoint(&url.URL{Scheme: "http", Host: register.Endpoints[0]}), // 指定服务地址,该地址会提交给注册中心,如果不指定,那么将注册容器内部地址,导致外部无法访问本服务 ) } diff --git a/app/biz-trainer/cmd/svc-trainer.go b/app/biz-trainer/cmd/svc-trainer.go index 08922c3..8a085d0 100644 --- a/app/biz-trainer/cmd/svc-trainer.go +++ b/app/biz-trainer/cmd/svc-trainer.go @@ -28,7 +28,7 @@ func newApp(register *conf.Register, logger klog.Logger, regstr registry.Registr gs, ), kratos.Registrar(regstr), - kratos.Endpoint(&url.URL{Scheme: "http", Host: register.Endpoints[0]}), // 指定服务地址,该地址会提交给注册中心,如果不指定,那么将注册容器内部地址,导致外部无法访问 + kratos.Endpoint(&url.URL{Scheme: "http", Host: register.Endpoints[0]}), // 指定服务地址,该地址会提交给注册中心,如果不指定,那么将注册容器内部地址,导致外部无法访问本服务 ) } diff --git a/app/biz-training/cmd/svc-training.go b/app/biz-training/cmd/svc-training.go index 7b0536f..b5cb170 100644 --- a/app/biz-training/cmd/svc-training.go +++ b/app/biz-training/cmd/svc-training.go @@ -28,7 +28,7 @@ func newApp(register *conf.Register, logger klog.Logger, regstr registry.Registr gs, ), kratos.Registrar(regstr), - kratos.Endpoint(&url.URL{Scheme: "http", Host: register.Endpoints[0]}), // 指定服务地址,该地址会提交给注册中心,如果不指定,那么将注册容器内部地址,导致外部无法访问 + kratos.Endpoint(&url.URL{Scheme: "http", Host: register.Endpoints[0]}), // 指定服务地址,该地址会提交给注册中心,如果不指定,那么将注册容器内部地址,导致外部无法访问本服务 ) } diff --git a/app/common/client/metrics.go b/app/common/client/metrics.go index 7850d66..363b325 100644 --- a/app/common/client/metrics.go +++ b/app/common/client/metrics.go @@ -3,6 +3,7 @@ package client import "github.com/prometheus/client_golang/prometheus" var ( + // 设置 metrics 中间件统计请求耗时的 Observer 直方图 MetricsSeconds = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Namespace: "server", Subsystem: "requests", @@ -10,13 +11,14 @@ var ( Help: "server requests duration(sec).", Buckets: []float64{0.005, 0.01, 0.025, 0.05, 0.1, 0.250, 0.5, 1}, }, []string{"kind", "operation"}) - + // 设置 metrics 中间件统计请求计数的 Counter 计数器 MetricsRequests = prometheus.NewCounterVec(prometheus.CounterOpts{ Namespace: "client", Subsystem: "requests", Name: "code_total", Help: "The total number of processed requests", }, []string{"kind", "operation", "code", "reason"}) + // 统计系统资源 MetricsLoads = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Namespace: "server", Subsystem: "system", diff --git a/app/gateway-gomono/main.go b/app/gateway-gomono/main.go index 0bab889..dacc067 100644 --- a/app/gateway-gomono/main.go +++ b/app/gateway-gomono/main.go @@ -134,7 +134,6 @@ func main() { ), kratos.Metadata(map[string]string{}), kratos.Logger(logger), - // kratos.Endpoint(&url.URL{Scheme: "http", Host: pubCfg.GatewayRegister.Endpoints[0]}), // 指定服务地址,该地址会提交给注册中心,如果不指定,那么将注册容器内部地址,导致外部无法访问 ) if err := app.Run(); err != nil { l.Errorf("failed to run servers: %v", err) diff --git a/deploy/docker/tmpl/prometheus.yml b/deploy/docker/tmpl/prometheus.yml index a688dfb..d3ede93 100644 --- a/deploy/docker/tmpl/prometheus.yml +++ b/deploy/docker/tmpl/prometheus.yml @@ -26,7 +26,7 @@ scrape_configs: # scheme defaults to 'http'. static_configs: - - targets: ['localhost:{{prometheus_srv_port}}'] + - targets: ['{{bff_host}}:{{bff_port}}'] - job_name: 'nacos' metrics_path: '/nacos/actuator/prometheus'