1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/pkg/splunk/data.go
ffeldmann d9e30418bc
feat: pipeline reporting, adds logging information to fatal hook and splunk hook (#3308)
* Removes unecessary fields from telemetry, restructuring splunk pkg

* Removes t.skip() and reactivates integration test

* Adjusts tests for fatalHook and helper functions, including log test

* Moves pipelinetelemetry to inner source, removes pipelineTelemetry from telemetry pkg, using generic map[string]interface for splunk

* Removes Read JSON from fatalHook -> moves to inner source

* Removed log output test

* go fmt

* log step telemetry data send to splunk

* Adjusts error logging

* Adds log information in case api information could not be retrieved

Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
2021-11-26 16:11:44 +01:00

53 lines
3.1 KiB
Go

package splunk
import "github.com/SAP/jenkins-library/pkg/log"
type Event struct {
Messages []log.Message `json:"messages,omitempty"` // messages
Telemetry MonitoringData `json:"telemetry,omitempty"` // telemetryData
}
type Details struct {
Host string `json:"host"` // hostname
Source string `json:"source,omitempty"` // optional description of the source of the event; typically the app's name
SourceType string `json:"sourcetype,omitempty"` // optional name of a Splunk parsing configuration; this is usually inferred by Splunk
Index string `json:"index,omitempty"` // optional name of the Splunk index to store the event in; not required if the token has a default index set in Splunk
Event Event `json:"event,omitempty"` // throw any useful key/val pairs here}
}
// MonitoringData definition for monitoring
type MonitoringData struct {
PipelineUrlHash string `json:"PipelineUrlHash,omitempty"`
BuildUrlHash string `json:"BuildUrlHash,omitempty"`
StageName string `json:"StageName,omitempty"`
StepName string `json:"StepName,omitempty"`
ExitCode string `json:"ExitCode,omitempty"`
Duration string `json:"Duration,omitempty"`
ErrorCode string `json:"ErrorCode,omitempty"`
ErrorCategory string `json:"ErrorCategory,omitempty"`
CorrelationID string `json:"CorrelationID,omitempty"`
CommitHash string `json:"CommitHash,omitempty"`
Branch string `json:"Branch,omitempty"`
GitOwner string `json:"GitOwner,omitempty"`
GitRepository string `json:"GitRepository,omitempty"`
}
type LogFileEvents struct {
Messages []string `json:"messages,omitempty"` // messages
Telemetry map[string]interface{} `json:"telemetry,omitempty"` // telemetryData
}
type DetailsLog struct {
Host string `json:"host"` // hostname
Source string `json:"source,omitempty"` // optional description of the source of the event; typically the app's name
SourceType string `json:"sourcetype,omitempty"` // optional name of a Splunk parsing configuration; this is usually inferred by Splunk
Index string `json:"index,omitempty"` // optional name of the Splunk index to store the event in; not required if the token has a default index set in Splunk
Event LogFileEvents `json:"event,omitempty"` // throw any useful key/val pairs here}
}
type DetailsTelemetry struct {
Host string `json:"host"` // hostname
Source string `json:"source,omitempty"` // optional description of the source of the event; typically the app's name
SourceType string `json:"sourcetype,omitempty"` // optional name of a Splunk parsing configuration; this is usually inferred by Splunk
Index string `json:"index,omitempty"` // optional name of the Splunk index to store the event in; not required if the token has a default index set in Splunk
Event map[string]interface{} `json:"event,omitempty"` // throw any useful key/val pairs here}
}