Add detailed scanner metrics (#15161)

This commit is contained in:
Klaus Post
2022-07-05 14:45:49 -07:00
committed by GitHub
parent df42914da6
commit ac055b09e9
55 changed files with 1735 additions and 1753 deletions
+3 -2
View File
@@ -27,6 +27,7 @@ import (
"time"
"github.com/klauspost/compress/gzhttp"
"github.com/minio/madmin-go"
xhttp "github.com/minio/minio/internal/http"
"github.com/minio/minio/internal/logger/message/audit"
)
@@ -234,8 +235,8 @@ func AuditLog(ctx context.Context, w http.ResponseWriter, r *http.Request, reqCl
// Send audit logs only to http targets.
for _, t := range auditTgts {
if err := t.Send(entry, string(All)); err != nil {
LogAlwaysIf(context.Background(), fmt.Errorf("event(%v) was not sent to Audit target (%v): %v", entry, t, err), All)
if err := t.Send(entry); err != nil {
LogAlwaysIf(context.Background(), fmt.Errorf("event(%v) was not sent to Audit target (%v): %v", entry, t, err), madmin.LogKindAll)
}
}
}
+15 -23
View File
@@ -31,6 +31,7 @@ import (
"time"
"github.com/minio/highwayhash"
"github.com/minio/madmin-go"
"github.com/minio/minio-go/v7/pkg/set"
xhttp "github.com/minio/minio/internal/http"
"github.com/minio/minio/internal/logger/message/log"
@@ -50,6 +51,10 @@ const (
InformationLvl Level = iota + 1
ErrorLvl
FatalLvl
Application = madmin.LogKindApplication
Minio = madmin.LogKindMinio
All = madmin.LogKindAll
)
var trimStrings []string
@@ -65,16 +70,15 @@ var matchingFuncNames = [...]string{
}
func (level Level) String() string {
var lvlStr string
switch level {
case InformationLvl:
lvlStr = "INFO"
return "INFO"
case ErrorLvl:
lvlStr = "ERROR"
return "ERROR"
case FatalLvl:
lvlStr = "FATAL"
return "FATAL"
}
return lvlStr
return ""
}
// quietFlag: Hide startup messages if enabled
@@ -237,18 +241,6 @@ func hashString(input string) string {
return hex.EncodeToString(hh.Sum(nil))
}
// Kind specifies the kind of error log
type Kind string
const (
// Minio errors
Minio Kind = "MINIO"
// Application errors
Application Kind = "APPLICATION"
// All errors
All Kind = "ALL"
)
// LogAlwaysIf prints a detailed error message during
// the execution of the server.
func LogAlwaysIf(ctx context.Context, err error, errKind ...interface{}) {
@@ -279,10 +271,10 @@ func LogIf(ctx context.Context, err error, errKind ...interface{}) {
}
func errToEntry(ctx context.Context, err error, errKind ...interface{}) log.Entry {
logKind := string(Minio)
logKind := madmin.LogKindAll
if len(errKind) > 0 {
if ek, ok := errKind[0].(Kind); ok {
logKind = string(ek)
if ek, ok := errKind[0].(madmin.LogKind); ok {
logKind = ek
}
}
req := GetReqInfo(ctx)
@@ -366,7 +358,7 @@ func consoleLogIf(ctx context.Context, err error, errKind ...interface{}) {
if consoleTgt != nil {
entry := errToEntry(ctx, err, errKind...)
consoleTgt.Send(entry, entry.LogKind)
consoleTgt.Send(entry)
}
}
@@ -385,10 +377,10 @@ func logIf(ctx context.Context, err error, errKind ...interface{}) {
entry := errToEntry(ctx, err, errKind...)
// Iterate over all logger targets to send the log entry
for _, t := range systemTgts {
if err := t.Send(entry, entry.LogKind); err != nil {
if err := t.Send(entry); err != nil {
if consoleTgt != nil {
entry.Trace.Message = fmt.Sprintf("event(%#v) was not sent to Logger target (%#v): %#v", entry, t, err)
consoleTgt.Send(entry, entry.LogKind)
consoleTgt.Send(entry)
}
}
}
+24 -16
View File
@@ -20,6 +20,8 @@ package log
import (
"strings"
"time"
"github.com/minio/madmin-go"
)
// ObjectVersion object version key/versionId
@@ -52,17 +54,17 @@ type API struct {
// Entry - defines fields and values of each log entry.
type Entry struct {
DeploymentID string `json:"deploymentid,omitempty"`
Level string `json:"level"`
LogKind string `json:"errKind"`
Time time.Time `json:"time"`
API *API `json:"api,omitempty"`
RemoteHost string `json:"remotehost,omitempty"`
Host string `json:"host,omitempty"`
RequestID string `json:"requestID,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
Message string `json:"message,omitempty"`
Trace *Trace `json:"error,omitempty"`
DeploymentID string `json:"deploymentid,omitempty"`
Level string `json:"level"`
LogKind madmin.LogKind `json:"errKind"`
Time time.Time `json:"time"`
API *API `json:"api,omitempty"`
RemoteHost string `json:"remotehost,omitempty"`
Host string `json:"host,omitempty"`
RequestID string `json:"requestID,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
Message string `json:"message,omitempty"`
Trace *Trace `json:"error,omitempty"`
}
// Info holds console log messages
@@ -73,9 +75,15 @@ type Info struct {
Err error `json:"-"`
}
// SendLog returns true if log pertains to node specified in args.
func (l Info) SendLog(node, logKind string) bool {
nodeFltr := (node == "" || strings.EqualFold(node, l.NodeName))
typeFltr := strings.EqualFold(logKind, "all") || strings.EqualFold(l.LogKind, logKind)
return nodeFltr && typeFltr
// Mask returns the mask based on the error level.
func (l Info) Mask() uint64 {
return l.LogKind.LogMask().Mask()
}
// SendLog returns true if log pertains to node specified in args.
func (l Info) SendLog(node string, logKind madmin.LogMask) bool {
if logKind.Contains(l.LogKind.LogMask()) {
return node == "" || strings.EqualFold(node, l.NodeName)
}
return false
}
+1 -1
View File
@@ -203,7 +203,7 @@ func New(config Config) *Target {
}
// Send log message 'e' to http target.
func (h *Target) Send(entry interface{}, errKind string) error {
func (h *Target) Send(entry interface{}) error {
select {
case <-h.doneCh:
return nil
+1 -1
View File
@@ -48,7 +48,7 @@ type Target struct {
}
// Send log message 'e' to kafka target.
func (h *Target) Send(entry interface{}, errKind string) error {
func (h *Target) Send(entry interface{}) error {
select {
case <-h.doneCh:
return nil
+1 -1
View File
@@ -33,7 +33,7 @@ type Target interface {
Endpoint() string
Init() error
Cancel()
Send(entry interface{}, errKind string) error
Send(entry interface{}) error
Type() types.TargetType
}