Documentation ¶
Overview ¶
Package report defines Report object definitions. Report is under development and not yet available for use.
Index ¶
- Constants
- Variables
- func GetMinDate() time.Time
- func RowGroupByNames() []string
- func RowGroupByValidation() govy.Rule[RowGroupBy]
- func SnapshotPointNames() []string
- func SnapshotPointValidation() govy.Rule[SnapshotPoint]
- type CalendarTimeFrame
- type ColumnSpec
- type CustomPeriod
- type ErrorBudgetStatusConfig
- type Filters
- type LabelKey
- type LabelValue
- type Labels
- type Metadata
- type Repeat
- type Report
- func (r Report) GetKind() manifest.Kind
- func (r Report) GetManifestSource() string
- func (r Report) GetName() string
- func (r Report) GetOrganization() string
- func (r Report) GetValidator() govy.Validator[Report]
- func (r Report) GetVersion() manifest.Version
- func (r Report) SetManifestSource(src string) manifest.Object
- func (r Report) SetOrganization(org string) manifest.Object
- func (r Report) Validate() error
- type RollingTimeFrame
- type RowGroupBy
- type SLO
- type SLOHistoryConfig
- type SLOHistoryTimeFrame
- type SLOs
- type Service
- type Services
- type SnapshotPoint
- type SnapshotTimeFrame
- type Spec
- type SystemHealthReviewConfig
- type SystemHealthReviewTimeFrame
- type Thresholds
Examples ¶
Constants ¶
const ( // IsoDateOnlyLayout is date only (without time zone) of iso layout IsoDateOnlyLayout string = "2006-01-02" )
Variables ¶
var ErrInvalidRowGroupBy = fmt.Errorf("not a valid RowGroupBy, try [%s]", strings.Join(_RowGroupByNames, ", "))
var ErrInvalidSnapshotPoint = fmt.Errorf("not a valid SnapshotPoint, try [%s]", strings.Join(_SnapshotPointNames, ", "))
Functions ¶
func GetMinDate ¶ added in v0.89.0
func RowGroupByNames ¶
func RowGroupByNames() []string
RowGroupByNames returns a list of possible string values of RowGroupBy.
func RowGroupByValidation ¶
func RowGroupByValidation() govy.Rule[RowGroupBy]
func SnapshotPointNames ¶
func SnapshotPointNames() []string
SnapshotPointNames returns a list of possible string values of SnapshotPoint.
func SnapshotPointValidation ¶
func SnapshotPointValidation() govy.Rule[SnapshotPoint]
Types ¶
type CalendarTimeFrame ¶
type ColumnSpec ¶
type CustomPeriod ¶
type ErrorBudgetStatusConfig ¶
type ErrorBudgetStatusConfig struct{}
type LabelValue ¶
type LabelValue = string
type Labels ¶
type Labels map[LabelKey][]LabelValue
type Report ¶
type Report struct { APIVersion manifest.Version `json:"apiVersion"` Kind manifest.Kind `json:"kind"` Metadata Metadata `json:"metadata"` Spec Spec `json:"spec"` Organization string `json:"organization,omitempty"` ManifestSource string `json:"manifestSrc,omitempty"` }
Example (ErrorBudgetStatus) ¶
package main import ( "context" "log" "github.com/nobl9/nobl9-go/internal/examples" "github.com/nobl9/nobl9-go/manifest" "github.com/nobl9/nobl9-go/manifest/v1alpha/report" ) func main() { // Create the object: myReport := report.New( report.Metadata{ Name: "report", DisplayName: "My report", }, report.Spec{ Shared: true, Filters: &report.Filters{ Projects: []string{"project"}, Services: []report.Service{ { Name: "service", Project: "project", }, }, SLOs: []report.SLO{ { Name: "slo1", Project: "project", }, }, Labels: map[string][]string{ "key1": { "value1", "value2", }, "key2": { "value1", "value2", }, }, }, ErrorBudgetStatus: &report.ErrorBudgetStatusConfig{}, }, ) // Verify the object: if err := myReport.Validate(); err != nil { log.Fatalf("report validation failed, err: %v", err) } // Apply the object: client := examples.GetOfflineEchoClient() if err := client.Objects().V1().Apply(context.Background(), []manifest.Object{myReport}); err != nil { log.Fatalf("failed to apply report, err: %v", err) } }
Output: apiVersion: n9/v1alpha kind: Report metadata: name: report displayName: My report spec: shared: true filters: projects: - project services: - name: service project: project slos: - name: slo1 project: project labels: key1: - value1 - value2 key2: - value1 - value2 errorBudgetStatus: {}
Example (SloHistory) ¶
package main import ( "context" "log" "github.com/nobl9/nobl9-go/internal/examples" "github.com/nobl9/nobl9-go/manifest" "github.com/nobl9/nobl9-go/manifest/v1alpha/report" ) func main() { // Create the object: myReport := report.New( report.Metadata{ Name: "report", DisplayName: "My report", }, report.Spec{ Shared: true, Filters: &report.Filters{ Projects: []string{"project"}, Services: []report.Service{ { Name: "service", Project: "project", }, }, SLOs: []report.SLO{ { Name: "slo1", Project: "project", }, }, Labels: map[string][]string{ "key1": { "value1", "value2", }, "key2": { "value1", "value2", }, }, }, SLOHistory: &report.SLOHistoryConfig{ TimeFrame: report.SLOHistoryTimeFrame{ Rolling: &report.RollingTimeFrame{ Repeat: report.Repeat{ Unit: ptr("Week"), Count: ptr(2), }, }, TimeZone: "America/New_York", }, }, }, ) // Verify the object: if err := myReport.Validate(); err != nil { log.Fatalf("report validation failed, err: %v", err) } // Apply the object: client := examples.GetOfflineEchoClient() if err := client.Objects().V1().Apply(context.Background(), []manifest.Object{myReport}); err != nil { log.Fatalf("failed to apply report, err: %v", err) } } func ptr[T any](v T) *T { return &v }
Output: apiVersion: n9/v1alpha kind: Report metadata: name: report displayName: My report spec: shared: true filters: projects: - project services: - name: service project: project slos: - name: slo1 project: project labels: key1: - value1 - value2 key2: - value1 - value2 sloHistory: timeFrame: rolling: unit: Week count: 2 timeZone: America/New_York
Example (SystemHealthReview) ¶
package main import ( "context" "log" "time" "github.com/nobl9/nobl9-go/internal/examples" "github.com/nobl9/nobl9-go/manifest" "github.com/nobl9/nobl9-go/manifest/v1alpha/report" ) func main() { // Create the object: myReport := report.New( report.Metadata{ Name: "report", DisplayName: "My report", }, report.Spec{ Shared: true, Filters: &report.Filters{ Projects: []string{"project"}, Services: []report.Service{ { Name: "service", Project: "project", }, }, SLOs: []report.SLO{ { Name: "slo1", Project: "project", }, }, Labels: map[string][]string{ "key1": { "value1", "value2", }, "key2": { "value1", "value2", }, }, }, SystemHealthReview: &report.SystemHealthReviewConfig{ TimeFrame: report.SystemHealthReviewTimeFrame{ Snapshot: report.SnapshotTimeFrame{ Point: report.SnapshotPointPast, DateTime: ptr( time.Date(2022, 1, 1, 0, 0, 0, 0, time.UTC), ), Rrule: "FREQ=WEEKLY", }, TimeZone: "America/New_York", }, RowGroupBy: report.RowGroupByProject, Columns: []report.ColumnSpec{ { DisplayName: "Column 1", Labels: map[string][]string{ "key1": { "value1", }, "key2": { "value1", "value2", }, }, }, { DisplayName: "Column 2", Labels: map[string][]string{ "key3": { "value1", }, }, }, }, Thresholds: report.Thresholds{ RedLessThanOrEqual: ptr(0.8), GreenGreaterThan: ptr(0.95), ShowNoData: false, }, }, }, ) // Verify the object: if err := myReport.Validate(); err != nil { log.Fatalf("report validation failed, err: %v", err) } // Apply the object: client := examples.GetOfflineEchoClient() if err := client.Objects().V1().Apply(context.Background(), []manifest.Object{myReport}); err != nil { log.Fatalf("failed to apply report, err: %v", err) } } func ptr[T any](v T) *T { return &v }
Output: apiVersion: n9/v1alpha kind: Report metadata: name: report displayName: My report spec: shared: true filters: projects: - project services: - name: service project: project slos: - name: slo1 project: project labels: key1: - value1 - value2 key2: - value1 - value2 systemHealthReview: timeFrame: snapshot: point: past dateTime: 2022-01-01T00:00:00Z rrule: FREQ=WEEKLY timeZone: America/New_York rowGroupBy: project columns: - displayName: Column 1 labels: key1: - value1 key2: - value1 - value2 - displayName: Column 2 labels: key3: - value1 thresholds: redLte: 0.8 greenGt: 0.95 showNoData: false
func (Report) GetManifestSource ¶
func (Report) GetOrganization ¶
func (Report) GetVersion ¶
type RollingTimeFrame ¶
type RollingTimeFrame struct {
Repeat `json:",inline"`
}
type RowGroupBy ¶
type RowGroupBy int
RowGroupBy /* ENUM(project = 1, service)*/
const ( // RowGroupByProject is a RowGroupBy of type Project. RowGroupByProject RowGroupBy = iota + 1 // RowGroupByService is a RowGroupBy of type Service. RowGroupByService )
func ParseRowGroupBy ¶
func ParseRowGroupBy(name string) (RowGroupBy, error)
ParseRowGroupBy attempts to convert a string to a RowGroupBy.
func RowGroupByValues ¶
func RowGroupByValues() []RowGroupBy
RowGroupByValues returns a list of the values for RowGroupBy
func (RowGroupBy) IsValid ¶
func (x RowGroupBy) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (RowGroupBy) MarshalText ¶
func (r RowGroupBy) MarshalText() ([]byte, error)
func (RowGroupBy) String ¶
func (x RowGroupBy) String() string
String implements the Stringer interface.
func (*RowGroupBy) UnmarshalText ¶
func (x *RowGroupBy) UnmarshalText(text []byte) error
type SLOHistoryConfig ¶
type SLOHistoryConfig struct {
TimeFrame SLOHistoryTimeFrame `json:"timeFrame" validate:"required"`
}
type SLOHistoryTimeFrame ¶
type SLOHistoryTimeFrame struct { Rolling *RollingTimeFrame `json:"rolling,omitempty"` Calendar *CalendarTimeFrame `json:"calendar,omitempty"` TimeZone string `json:"timeZone" validate:"required,timeZone" example:"America/New_York"` }
type SnapshotPoint ¶
type SnapshotPoint int
SnapshotPoint /* ENUM(past = 1, latest)*/
const ( // SnapshotPointPast is a SnapshotPoint of type Past. SnapshotPointPast SnapshotPoint = iota + 1 // SnapshotPointLatest is a SnapshotPoint of type Latest. SnapshotPointLatest )
func ParseSnapshotPoint ¶
func ParseSnapshotPoint(name string) (SnapshotPoint, error)
ParseSnapshotPoint attempts to convert a string to a SnapshotPoint.
func SnapshotPointValues ¶
func SnapshotPointValues() []SnapshotPoint
SnapshotPointValues returns a list of the values for SnapshotPoint
func (SnapshotPoint) IsValid ¶
func (x SnapshotPoint) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (SnapshotPoint) MarshalText ¶
func (p SnapshotPoint) MarshalText() ([]byte, error)
func (SnapshotPoint) String ¶
func (x SnapshotPoint) String() string
String implements the Stringer interface.
func (*SnapshotPoint) UnmarshalText ¶
func (p *SnapshotPoint) UnmarshalText(text []byte) error
type SnapshotTimeFrame ¶
type SnapshotTimeFrame struct { Point SnapshotPoint `json:"point" validate:"required" example:"latest"` DateTime *time.Time `json:"dateTime,omitempty"` Rrule string `json:"rrule,omitempty"` }
type Spec ¶
type Spec struct { CreatedAt string `json:"createdAt,omitempty"` UpdatedAt string `json:"updatedAt,omitempty"` CreatedBy *string `json:"createdBy,omitempty"` Filters *Filters `json:"filters,omitempty"` SystemHealthReview *SystemHealthReviewConfig `json:"systemHealthReview,omitempty"` SLOHistory *SLOHistoryConfig `json:"sloHistory,omitempty"` ErrorBudgetStatus *ErrorBudgetStatusConfig `json:"errorBudgetStatus,omitempty"` }
type SystemHealthReviewConfig ¶
type SystemHealthReviewConfig struct { TimeFrame SystemHealthReviewTimeFrame `json:"timeFrame" validate:"required"` RowGroupBy RowGroupBy `json:"rowGroupBy" validate:"required" example:"project"` Columns []ColumnSpec `json:"columns" validate:"min=1,max=30"` Thresholds Thresholds `json:"thresholds" validate:"required"` }
type SystemHealthReviewTimeFrame ¶
type SystemHealthReviewTimeFrame struct { Snapshot SnapshotTimeFrame `json:"snapshot" validate:"required"` TimeZone string `json:"timeZone" validate:"required,timeZone" example:"America/New_York"` }
type Thresholds ¶ added in v0.85.0
type Thresholds struct { RedLessThanOrEqual *float64 `json:"redLte" validate:"required" example:"0.8"` // Yellow is calculated as the difference between Red and Green // thresholds. If Red and Green are the same, Yellow is not used on the report. GreenGreaterThan *float64 `json:"greenGt" validate:"required" example:"0.95"` // ShowNoData customizes the report to either show or hide rows with no data. ShowNoData bool `json:"showNoData"` }