report

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package report is the package for SLA report

Index

Constants

This section is empty.

Variables

FormatFuncs is the format function map

Functions

func AutoRefreshJS added in v1.4.0

func AutoRefreshJS(time string) string

AutoRefreshJS return the auto refresh javascript

func DurationStr

func DurationStr(d time.Duration) string

DurationStr convert the curation to string

func FormatTime added in v1.7.0

func FormatTime(t time.Time) string

FormatTime format the time with time zone and time format

func HTMLFooter

func HTMLFooter(time string) string

HTMLFooter return the HTML footer

func HTMLHeader

func HTMLHeader(title string) string

HTMLHeader return the HTML head

func JSONEscape

func JSONEscape(str string) string

JSONEscape escape the string

func LogSend

func LogSend(kind, name, tag, message string, err error)

LogSend is helper function to log the send logs.

func SLACSV added in v1.6.0

func SLACSV(probers []probe.Prober) string

SLACSV return a full stat report with CSV format

func SLACSVSection added in v1.6.0

func SLACSVSection(r *probe.Result) []string

SLACSVSection set the CSV format for SLA

func SLAHTML

func SLAHTML(probers []probe.Prober) string

SLAHTML return a full stat report

func SLAHTMLFilter added in v1.7.0

func SLAHTMLFilter(probers []probe.Prober, filter *SLAFilter) string

SLAHTMLFilter return a stat report with filter

func SLAHTMLSection

func SLAHTMLSection(r *probe.Result) string

SLAHTMLSection return the HTML format string to stat

func SLAJSON

func SLAJSON(probers []probe.Prober) string

SLAJSON return a full stat report

func SLAJSONSection

func SLAJSONSection(r *probe.Result) string

SLAJSONSection return the JSON format string to stat

func SLALark

func SLALark(probers []probe.Prober) string

SLALark return a full stat report

func SLALarkSection

func SLALarkSection(r *probe.Result) string

SLALarkSection return the Text format string to stat

func SLALog added in v1.6.0

func SLALog(probers []probe.Prober) string

SLALog return a full stat report with Log format

func SLALogSection added in v1.6.0

func SLALogSection(r *probe.Result) string

SLALogSection return the Log format string to stat

func SLAMarkdown

func SLAMarkdown(probers []probe.Prober) string

SLAMarkdown return a full stat report with Markdown format

func SLAMarkdownSection

func SLAMarkdownSection(r *probe.Result, f Format) string

SLAMarkdownSection return the Markdown format string to stat

func SLAMarkdownSocial

func SLAMarkdownSocial(probers []probe.Prober) string

SLAMarkdownSocial return a full stat report with social markdown

func SLAShell added in v1.6.0

func SLAShell(probers []probe.Prober) string

SLAShell set the environment for SLA

func SLASlack

func SLASlack(probers []probe.Prober) string

SLASlack generate all probes stat message to slack block string

func SLASlackSection

func SLASlackSection(r *probe.Result) string

SLASlackSection return the slack json format string to stat

func SLAStatusText

func SLAStatusText(s probe.Stat, t Format) string

SLAStatusText return the string of status statices

func SLASummary added in v1.5.0

func SLASummary(probers []probe.Prober) string

SLASummary return a summary stat report

func SLAText

func SLAText(probers []probe.Prober) string

SLAText return a full stat report

func SLATextSection

func SLATextSection(r *probe.Result) string

SLATextSection return the Text format string to stat

func SlackTimeFormation

func SlackTimeFormation(t time.Time, act string, format string) string

SlackTimeFormation return the slack time formation

func ToCSV added in v1.6.0

func ToCSV(r probe.Result) string

ToCSV convert the object to CSV

func ToHTML

func ToHTML(r probe.Result) string

ToHTML convert the object to ToHTML

func ToJSON

func ToJSON(r probe.Result) string

ToJSON convert the result object to ToJSON

func ToJSONIndent

func ToJSONIndent(r probe.Result) string

ToJSONIndent convert the object to indent JSON

func ToLark

func ToLark(r probe.Result) string

ToLark convert the object to Lark notification Go to https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN#4996824a to build the notification block

func ToLog added in v1.6.0

func ToLog(r probe.Result) string

ToLog convert the result object to Log format

func ToMarkdown

func ToMarkdown(r probe.Result) string

ToMarkdown convert the object to ToMarkdown

func ToMarkdownSocial

func ToMarkdownSocial(r probe.Result) string

ToMarkdownSocial convert the object to Markdown

func ToShell added in v1.6.0

func ToShell(r probe.Result) string

ToShell convert the result object to shell variables

func ToSlack

func ToSlack(r probe.Result) string

ToSlack convert the object to ToSlack notification Go to https://app.slack.com/block-kit-builder to build the notification block

func ToText

func ToText(r probe.Result) string

ToText convert the result object to ToText

Types

type Availability

type Availability struct {
	UpTime   time.Duration `json:"up"`
	DownTime time.Duration `json:"down"`
	SLA      float64       `json:"sla"`
}

Availability is the Availability JSON structure

type Format

type Format int

Format is the format of text

const (
	Unknown        Format = iota
	MarkdownSocial        // *text* is bold
	Markdown              // **text** is bold
	HTML
	JSON
	Text
	Log
	Slack
	Discord
	Lark
	SMS
	Shell
)

The format types

func (*Format) Format

func (f *Format) Format(s string)

Format covert the string to Format

func (Format) MarshalYAML

func (f Format) MarshalYAML() (interface{}, error)

MarshalYAML is marshal the format

func (Format) String

func (f Format) String() string

String covert the Format to string

func (*Format) UnmarshalYAML

func (f *Format) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is unmarshal the format

type FormatFuncStruct

type FormatFuncStruct struct {
	ResultFn FormatFuncType
	StatFn   StatFormatFuncType
}

FormatFuncStruct is the format function struct

type FormatFuncType

type FormatFuncType func(probe.Result) string

FormatFuncType is the format function

type LatestProbe

type LatestProbe struct {
	Time    time.Time    `json:"time"`
	Status  probe.Status `json:"status"`
	Message string       `json:"message"`
}

LatestProbe is the LatestProbe JSON structure

type SLA

type SLA struct {
	Name         string       `json:"name"`
	Endpoint     string       `json:"endpoint"`
	Availability Availability `json:"sla"`
	ProbeTimes   Summary      `json:"probe_summary"`
	LatestProbe  LatestProbe  `json:"latest_probe"`
}

SLA is the SLA JSON structure

func SLAObject

func SLAObject(r *probe.Result) SLA

SLAObject covert the result to SLA struct

type SLAFilter added in v1.7.0

type SLAFilter struct {
	Name       string
	Kind       string
	Endpoint   string
	Status     *probe.Status
	SLAGreater float64
	SLALess    float64
	Message    string
	PageNum    int
	PageSize   int
	// contains filtered or unexported fields
}

SLAFilter filter the probers

func NewEmptyFilter added in v1.7.0

func NewEmptyFilter() *SLAFilter

NewEmptyFilter create a new SLAFilter

func (*SLAFilter) Check added in v1.7.0

func (f *SLAFilter) Check() error

Check check the filter is valid or not

func (*SLAFilter) Filter added in v1.7.0

func (f *SLAFilter) Filter(probers []probe.Prober) []probe.Prober

Filter filter the probers

func (*SLAFilter) HTML added in v1.7.0

func (f *SLAFilter) HTML() string

HTML return the HTML format string

type StatFormatFuncType

type StatFormatFuncType func([]probe.Prober) string

StatFormatFuncType is the format function for Stat

type Summary

type Summary struct {
	Total int64 `json:"total"`
	Up    int64 `json:"up"`
	Down  int64 `json:"down"`
}

Summary is the Summary JSON structure

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL