-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
158 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package normalization | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
obs "github.com/openshift/cluster-logging-operator/api/observability/v1" | ||
"github.com/openshift/cluster-logging-operator/internal/utils" | ||
"github.com/openshift/cluster-logging-operator/test/framework/functional" | ||
"github.com/openshift/cluster-logging-operator/test/helpers/types" | ||
. "github.com/openshift/cluster-logging-operator/test/matchers" | ||
testruntime "github.com/openshift/cluster-logging-operator/test/runtime/observability" | ||
) | ||
|
||
var _ = Describe("[functional][normalization] ViaQ message format of journal logs", func() { | ||
var ( | ||
framework *functional.CollectorFunctionalFramework | ||
) | ||
|
||
BeforeEach(func() { | ||
framework = functional.NewCollectorFunctionalFramework() | ||
testruntime.NewClusterLogForwarderBuilder(framework.Forwarder). | ||
FromInput(obs.InputTypeInfrastructure). | ||
ToElasticSearchOutput() | ||
Expect(framework.Deploy()).To(BeNil()) | ||
}) | ||
AfterEach(func() { | ||
framework.Cleanup() | ||
}) | ||
|
||
It("should format ViaQ journal logs", func() { | ||
|
||
expLog := functional.NewJournalInfrastructureLogTemplate() | ||
|
||
// Write log line as input to collector | ||
logline := functional.NewJournalLog(2, "here is my message", "*") | ||
Expect(framework.WriteMessagesToInfraJournalLog(logline, 1)).To(BeNil()) | ||
|
||
// Read line from Log Forward output | ||
raw, err := framework.ReadInfrastructureLogsFrom(string(obs.OutputTypeElasticsearch)) | ||
Expect(err).To(BeNil(), "Expected no errors reading the logs") | ||
|
||
// Parse log line | ||
var logs []types.JournalLog | ||
err = types.StrictlyParseLogs(utils.ToJsonLogs(raw), &logs) | ||
Expect(err).To(BeNil(), "Expected no errors parsing the logs") | ||
|
||
// Compare to expected template | ||
outputTestLog := logs[0] | ||
Expect(outputTestLog.ViaQCommon).To(FitLogFormatTemplate(expLog.ViaQCommon)) | ||
Expect(outputTestLog.Systemd.T).NotTo(Equal(types.T{}), "Exp. to be populated with something") | ||
Expect(outputTestLog.Systemd.U).NotTo(Equal(types.U{}), "Exp. to be populated with something") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package types | ||
|
||
import "time" | ||
|
||
// JournalLog is linux journal logs | ||
type JournalLog struct { | ||
ViaQCommon `json:",inline,omitempty"` | ||
Tag string `json:"tag,omitempty"` | ||
Time time.Time `json:"time,omitempty"` | ||
STREAMID string `json:"_STREAM_ID,omitempty"` | ||
SYSTEMDINVOCATIONID string `json:"_SYSTEMD_INVOCATION_ID,omitempty"` | ||
Systemd Systemd `json:"systemd,omitempty"` | ||
} | ||
|
||
type K struct { | ||
KERNEL_DEVICE string `json:"KERNEL_DEVICE,omitempty"` | ||
KERNEL_SUBSYSTEM string `json:"KERNEL_SUBSYSTEM,omitempty"` | ||
UDEV_DEVLINK string `json:"UDEV_DEVLINK,omitempty"` | ||
UDEV_DEVNODE string `json:"UDEV_DEVNODE,omitempty"` | ||
UDEV_SYSNAME string `json:"UDEV_SYSNAME,omitempty"` | ||
} | ||
|
||
type T struct { | ||
AUDIT_LOGINUID string `json:"AUDIT_LOGINUID,omitempty"` | ||
AUDIT_SESSION string `json:"AUDIT_SESSION,omitempty"` | ||
BOOTID string `json:"BOOT_ID,omitempty"` | ||
CAPEFFECTIVE string `json:"CAP_EFFECTIVE,omitempty"` | ||
CMDLINE string `json:"CMDLINE,omitempty"` | ||
COMM string `json:"COMM,omitempty"` | ||
EXE string `json:"EXE,omitempty"` | ||
GID string `json:"GID,omitempty"` | ||
HOSTNAME string `json:"HOSTNAME,omitempty"` | ||
LINE_BREAK string `json:"LINE_BREAK,omitempty"` | ||
MACHINEID string `json:"MACHINE_ID,omitempty"` | ||
PID string `json:"PID,omitempty"` | ||
SELINUXCONTEXT string `json:"SELINUX_CONTEXT,omitempty"` | ||
STREAMID string `json:"STREAM_ID,omitempty"` | ||
SYSTEMDCGROUP string `json:"SYSTEMD_CGROUP,omitempty"` | ||
SYSTEMDINVOCATIONID string `json:"SYSTEMD_INVOCATION_ID,omitempty"` | ||
SYSTEMD_OWNER_UID string `json:"SYSTEMD_OWNER_UID,omitempty"` | ||
SYSTEMD_SESSION string `json:"SYSTEMD_SESSION,omitempty"` | ||
SYSTEMDSLICE string `json:"SYSTEMD_SLICE,omitempty"` | ||
SYSTEMDUNIT string `json:"SYSTEMD_UNIT,omitempty"` | ||
SYSTEMD_USER_UNIT string `json:"SYSTEMD_USER_UNIT,omitempty"` | ||
TRANSPORT string `json:"TRANSPORT,omitempty"` | ||
UID string `json:"UID,omitempty"` | ||
} | ||
|
||
type U struct { | ||
CODE_FILE string `json:"CODE_FILE,omitempty"` | ||
CODE_FUNCTION string `json:"CODE_FUNCTION,omitempty"` | ||
CODE_LINE string `json:"CODE_LINE,omitempty"` | ||
ERRNO string `json:"ERRNO,omitempty"` | ||
MESSAGE_ID string `json:"MESSAGE_ID,omitempty"` | ||
SYSLOG_FACILITY string `json:"SYSLOG_FACILITY,omitempty"` | ||
SYSLOGIDENTIFIER string `json:"SYSLOG_IDENTIFIER,omitempty"` | ||
SYSLOG_PID string `json:"SYSLOG_PID,omitempty"` | ||
RESULT string `json:"RESULT,omitempty"` | ||
UNIT string `json:"UNIT,omitempty"` | ||
} | ||
|
||
type Systemd struct { | ||
K K `json:"k,omitempty"` | ||
T T `json:"t,omitempty"` | ||
U U `json:"u,omitempty"` | ||
} |
Oops, something went wrong.