Skip to content

Commit

Permalink
fix(sel-events): ignore parse time error
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandr Aleksandrov <[email protected]>
  • Loading branch information
Aleksandr Aleksandrov committed Jul 1, 2024
1 parent fe29db2 commit a0813e1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
7 changes: 5 additions & 2 deletions .gitlab/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
17 changes: 13 additions & 4 deletions collector_sel_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

const (
SELEventsCollectorName CollectorName = "sel-events"
SELDateTimeFormat string = "Jan-02-2006 15:04:05"
)

var (
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a0813e1

Please sign in to comment.