aboutsummaryrefslogtreecommitdiffstats
path: root/dashboard
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2022-06-13 18:43:15 +0200
committerGitHub <noreply@github.com>2022-06-13 18:43:15 +0200
commit0f08704067fce8a2a7ef7c508247aad6d48ed1f3 (patch)
treed9b70f95a029299a365db2eefecad44189c72a96 /dashboard
parent0d5abf15b74358009a02efb629f7bc7c84841a1f (diff)
dashboard/app: monitor all logs, not the request_log only
Diffstat (limited to 'dashboard')
-rw-r--r--dashboard/app/main.go58
1 files changed, 33 insertions, 25 deletions
diff --git a/dashboard/app/main.go b/dashboard/app/main.go
index 0af54d0ed..c8dbdd911 100644
--- a/dashboard/app/main.go
+++ b/dashboard/app/main.go
@@ -1279,16 +1279,26 @@ func makeUIJob(job *Job, jobKey *db.Key, bug *Bug, crash *Crash, build *Build) *
return ui
}
+func formatLogLine(line string) string {
+ const maxLineLen = 1000
+
+ line = strings.Replace(line, "\n", " ", -1)
+ line = strings.Replace(line, "\r", "", -1)
+ if len(line) > maxLineLen {
+ line = line[:maxLineLen]
+ line += "..."
+ }
+ return line + "\n"
+}
+
func fetchErrorLogs(c context.Context) ([]byte, error) {
if !appengine.IsAppEngine() {
return nil, nil
}
const (
- maxLines = 100
- maxLineLen = 1000
+ maxLines = 100
)
-
projID := os.Getenv("GOOGLE_CLOUD_PROJECT")
adminClient, err := logadmin.NewClient(c, projID)
@@ -1297,13 +1307,12 @@ func fetchErrorLogs(c context.Context) ([]byte, error) {
}
defer adminClient.Close()
- const name = "appengine.googleapis.com%2Frequest_log"
-
lastWeek := time.Now().Add(-1 * 7 * 24 * time.Hour).Format(time.RFC3339)
iter := adminClient.Entries(c,
logadmin.Filter(
- fmt.Sprintf(`logName = "projects/%s/logs/%s" AND timestamp > "%s" AND severity>="ERROR"`,
- projID, name, lastWeek)),
+ // We filter our instances.delete errors as false positives. Delete event happens every second.
+ fmt.Sprintf(`(NOT protoPayload.methodName:v1.compute.instances.delete) AND timestamp > "%s" AND severity>="ERROR"`,
+ lastWeek)),
logadmin.NewestFirst(),
)
@@ -1321,26 +1330,25 @@ func fetchErrorLogs(c context.Context) ([]byte, error) {
var lines []string
for _, entry := range entries {
- requestLog := entry.Payload.(*proto.RequestLog)
- for _, logLine := range requestLog.Line {
- if logLine.GetSeverity() < ltype.LogSeverity_ERROR {
- continue
+ requestLog, isRequestLog := entry.Payload.(*proto.RequestLog)
+ if isRequestLog {
+ for _, logLine := range requestLog.Line {
+ if logLine.GetSeverity() < ltype.LogSeverity_ERROR {
+ continue
+ }
+ line := fmt.Sprintf("%v: %v %v %v \"%v\"",
+ entry.Timestamp.Format(time.Stamp),
+ requestLog.GetStatus(),
+ requestLog.GetMethod(),
+ requestLog.GetResource(),
+ logLine.GetLogMessage())
+ lines = append(lines, formatLogLine(line))
}
- line := fmt.Sprintf("%v: %v %v %v \"%v\"",
+ } else {
+ line := fmt.Sprintf("%v: %v",
entry.Timestamp.Format(time.Stamp),
- requestLog.GetStatus(),
- requestLog.GetMethod(),
- requestLog.GetResource(),
- logLine.GetLogMessage())
-
- line = strings.Replace(line, "\n", " ", -1)
- line = strings.Replace(line, "\r", "", -1)
- if len(line) > maxLineLen {
- line = line[:maxLineLen]
- }
-
- line = line + "\n"
- lines = append(lines, line)
+ entry.Payload)
+ lines = append(lines, formatLogLine(line))
}
}