mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-08 15:41:15 +02:00
Export REST file_{read,write}_failures metrics on volume servers (#9215)
* Export gRPC `file_{read,write}_failures` metrics on volume servers.
Allows to track overall R/W errors in real time through Prometheus.
Will follow up with a PR for Seaweed's REST API.
* Export REST `file_{read,write}_failures` metrics on volume servers.
This commit is contained in:
@@ -35,11 +35,13 @@ import (
|
|||||||
const reqIsProxied = "proxied"
|
const reqIsProxied = "proxied"
|
||||||
|
|
||||||
func NotFound(w http.ResponseWriter) {
|
func NotFound(w http.ResponseWriter) {
|
||||||
|
stats.VolumeServerFileReadFailures.Inc()
|
||||||
stats.VolumeServerHandlerCounter.WithLabelValues(stats.ErrorGetNotFound).Inc()
|
stats.VolumeServerHandlerCounter.WithLabelValues(stats.ErrorGetNotFound).Inc()
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
func InternalError(w http.ResponseWriter) {
|
func InternalError(w http.ResponseWriter) {
|
||||||
|
stats.VolumeServerFileReadFailures.Inc()
|
||||||
stats.VolumeServerHandlerCounter.WithLabelValues(stats.ErrorGetInternal).Inc()
|
stats.VolumeServerHandlerCounter.WithLabelValues(stats.ErrorGetInternal).Inc()
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/operation"
|
"github.com/seaweedfs/seaweedfs/weed/operation"
|
||||||
|
"github.com/seaweedfs/seaweedfs/weed/stats"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
|
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/topology"
|
"github.com/seaweedfs/seaweedfs/weed/topology"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/util/buffer_pool"
|
"github.com/seaweedfs/seaweedfs/weed/util/buffer_pool"
|
||||||
@@ -28,6 +29,7 @@ func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
volumeId, ve := needle.NewVolumeId(vid)
|
volumeId, ve := needle.NewVolumeId(vid)
|
||||||
if ve != nil {
|
if ve != nil {
|
||||||
glog.V(0).InfolnCtx(ctx, "NewVolumeId error:", ve)
|
glog.V(0).InfolnCtx(ctx, "NewVolumeId error:", ve)
|
||||||
|
stats.VolumeServerFileWriteFailures.Inc()
|
||||||
writeJsonError(w, r, http.StatusBadRequest, ve)
|
writeJsonError(w, r, http.StatusBadRequest, ve)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -42,6 +44,7 @@ func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
reqNeedle, originalSize, contentMd5, ne := needle.CreateNeedleFromRequest(r, vs.FixJpgOrientation, vs.fileSizeLimitBytes, bytesBuffer)
|
reqNeedle, originalSize, contentMd5, ne := needle.CreateNeedleFromRequest(r, vs.FixJpgOrientation, vs.fileSizeLimitBytes, bytesBuffer)
|
||||||
if ne != nil {
|
if ne != nil {
|
||||||
|
stats.VolumeServerFileWriteFailures.Inc()
|
||||||
writeJsonError(w, r, http.StatusBadRequest, ne)
|
writeJsonError(w, r, http.StatusBadRequest, ne)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -50,6 +53,7 @@ func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
// use context.WithoutCancel to avoid context cancellation when the client connection is closed
|
// use context.WithoutCancel to avoid context cancellation when the client connection is closed
|
||||||
isUnchanged, writeError := topology.ReplicatedWrite(context.WithoutCancel(ctx), vs.GetMaster, vs.grpcDialOption, vs.store, volumeId, reqNeedle, r, contentMd5)
|
isUnchanged, writeError := topology.ReplicatedWrite(context.WithoutCancel(ctx), vs.GetMaster, vs.grpcDialOption, vs.store, volumeId, reqNeedle, r, contentMd5)
|
||||||
if writeError != nil {
|
if writeError != nil {
|
||||||
|
stats.VolumeServerFileWriteFailures.Inc()
|
||||||
writeJsonError(w, r, http.StatusInternalServerError, writeError)
|
writeJsonError(w, r, http.StatusInternalServerError, writeError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -117,11 +121,13 @@ func (vs *VolumeServer) DeleteHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
if n.IsChunkedManifest() {
|
if n.IsChunkedManifest() {
|
||||||
chunkManifest, e := operation.LoadChunkManifest(n.Data, n.IsCompressed())
|
chunkManifest, e := operation.LoadChunkManifest(n.Data, n.IsCompressed())
|
||||||
if e != nil {
|
if e != nil {
|
||||||
|
stats.VolumeServerFileWriteFailures.Inc()
|
||||||
writeJsonError(w, r, http.StatusInternalServerError, fmt.Errorf("Load chunks manifest error: %v", e))
|
writeJsonError(w, r, http.StatusInternalServerError, fmt.Errorf("Load chunks manifest error: %v", e))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// make sure all chunks had deleted before delete manifest
|
// make sure all chunks had deleted before delete manifest
|
||||||
if e := chunkManifest.DeleteChunks(vs.GetMaster, false, vs.grpcDialOption); e != nil {
|
if e := chunkManifest.DeleteChunks(vs.GetMaster, false, vs.grpcDialOption); e != nil {
|
||||||
|
stats.VolumeServerFileWriteFailures.Inc()
|
||||||
writeJsonError(w, r, http.StatusInternalServerError, fmt.Errorf("Delete chunks error: %v", e))
|
writeJsonError(w, r, http.StatusInternalServerError, fmt.Errorf("Delete chunks error: %v", e))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -148,6 +154,7 @@ func writeDeleteResult(err error, count int64, w http.ResponseWriter, r *http.Re
|
|||||||
m["size"] = count
|
m["size"] = count
|
||||||
writeJsonQuiet(w, r, http.StatusAccepted, m)
|
writeJsonQuiet(w, r, http.StatusAccepted, m)
|
||||||
} else {
|
} else {
|
||||||
|
stats.VolumeServerFileWriteFailures.Inc()
|
||||||
writeJsonError(w, r, http.StatusInternalServerError, fmt.Errorf("Deletion Failed: %w", err))
|
writeJsonError(w, r, http.StatusInternalServerError, fmt.Errorf("Deletion Failed: %w", err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user