From a0813e14747261e9fcf72d61a3cc673e886f76b4 Mon Sep 17 00:00:00 2001 From: Aleksandr Aleksandrov Date: Mon, 1 Jul 2024 21:40:05 +0300 Subject: [PATCH] fix(sel-events): ignore parse time error Signed-off-by: Aleksandr Aleksandrov --- .gitlab/.gitlab-ci.yml | 7 +++++-- collector_sel_events.go | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.gitlab/.gitlab-ci.yml b/.gitlab/.gitlab-ci.yml index e47d2cc..5f54790 100644 --- a/.gitlab/.gitlab-ci.yml +++ b/.gitlab/.gitlab-ci.yml @@ -4,16 +4,19 @@ include: - pipelines/rpm-common-v2.yml variables: + VKCS_TESTENV_DOCKERFILE_PATH: notexist.Dockerfile VKCS_BUILD_RPM_ENABLED: "true" VKCS_RELEASE_FROM: "RELEASE_BRANCH,RELEASE_TAG" VKCS_RELEASE_BRANCH_REGEX: /^vkcs$/ - VKCS_OS_PROJECT: "" VKCS_DEPLOY_STAGE_TYPES: "yum" VKCS_DEPLOY_DEVINT_TYPES: "rpm" VKCS_DEPLOY_DEVINT_MODE: "manual" VKCS_DEPLOY_DEVINT_PLAYBOOK: "playbooks/ipmi_exporter.yml" +.deploy_rpm_ansible_values_devint: + variables: + BOX_EXTRA_ANSIBLE_ARGS: "-e serial=10" + .release_pipeline_variables: variables: - VKCS_RUN_SECURITYGATE_REF_REGEX: $VKCS_RELEASE_BRANCH_REGEX VKCS_DEPLOY_PROD_MODE: "auto" diff --git a/collector_sel_events.go b/collector_sel_events.go index 4b7c28d..28e977c 100644 --- a/collector_sel_events.go +++ b/collector_sel_events.go @@ -24,6 +24,7 @@ import ( const ( SELEventsCollectorName CollectorName = "sel-events" + SELDateTimeFormat string = "Jan-02-2006 15:04:05" ) var ( @@ -92,12 +93,20 @@ func (c SELEventsCollector) Collect(result freeipmi.Result, ch chan<- prometheus for _, metricConfig := range selEventConfigs { match := metricConfig.Regex.FindStringSubmatch(data.Event) if match != nil { - t, err := time.Parse("Jan-02-2006 15:04:05", data.Date+" "+data.Time) + var newTimestamp float64 = 0 + datetime := data.Date + " " + data.Time + t, err := time.Parse(SELDateTimeFormat, datetime) + // ignore errors with invalid date or time + // NOTE: in some cases ipmi-sel can return "PostInit" in Date and Time fields + // Example: + // $ ipmi-sel --comma-separated-output --output-event-state --interpret-oem-data --output-oem-event-strings + // ID,Date,Time,Name,Type,State,Event + // 3,PostInit,PostInit,Sensor #211,Memory,Warning,Correctable memory error ; Event Data3 = 34h if err != nil { - level.Error(logger).Log("msg", "Failed to collect SEL event metrics", "target", targetName(target.host), "error", err) - return 0, err + level.Debug(logger).Log("msg", "Failed to parse time", "target", targetName(target.host), "error", err) + } else { + newTimestamp = float64(t.Unix()) } - newTimestamp := float64(t.Unix()) // save latest timestamp by name metrics if newTimestamp > selEventByNameTimestamp[metricConfig.Name] { selEventByNameTimestamp[metricConfig.Name] = newTimestamp