foremasttrigger

package
v0.0.0-...-3eef760 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MonitorPhaseHealthy = "Healthy"

	MonitorPhaseRunning = "Running"

	MonitorPhaseFailed = "Failed"

	MonitorPhaseUnhealthy = "Unhealthy"

	MonitorPhaseWarning = "Warning"

	MonitorPhaseExpired = "Expired"

	MonitorPhaseAbort = "Abort"
)

"healthy" deployment is considered healthy, "running" the deployment is running and it is detecting, "error" got error, "anomaly" engine detected anomaly issues,

View Source
const (
	//No remediation required
	RemediationNone = "None"
	//Trigger a rollback if error occured
	RemediationAutoRollback = "AutoRollback"
	//Trigger a pause only to reduce the error rate
	RemediationAutoPause = "AutoPause"
	//Trigger an auto scaling for specific use cases, for example, connection stack or CPU bump up a lot
	//RemediationAutoScaling = "AutoScaling"
	//Let foremast take care everything for you
	RemediationAuto = "Auto"
)

Constants for Actions

View Source
const CategoryBaseline = "baseline"
View Source
const CategoryCurrent = "current"
View Source
const CategoryHistorical = "historical"
View Source
const StrategyCanary = "canary"
View Source
const StrategyContinuous = "continuous"
View Source
const StrategyRollingUpdate = "rollingUpdate"

Variables

This section is empty.

Functions

func CreateDashboardURL

func CreateDashboardURL(serviceName string, jobmap *map[string]JobInfoM, healthresponse ApplicationHealthAnalyzeResponse) string

func ForemastQuery

func ForemastQuery(jobmap *map[string]JobInfoM, appName string, metricmap map[string]string) bool

create the initial request to be sent to foremast

func GenerateReport

func GenerateReport(serviceName string, info JobInfoM, currentYear *int, currentMonth *time.Month, currentDay *int) string

generate the anomaly counts for a single service

func GenerateSummaryReport

func GenerateSummaryReport(serviceslist map[string]JobInfoM, currentYear *int, currentMonth *time.Month, currentDay *int)

generate the anomaly counts for all services func GenerateSummaryReport(serviceslist []string, currentYear *int, currentMonth *time.Month, currentDay *int) {

func MonitorService

func MonitorService(serviceName string, mutex *sync.Mutex, anomalyfilename *string, jobmap *map[string]JobInfoM, currentYear *int, currentMonth *time.Month, currentDay *int)

continuously monitors a service by polling

func QueryWavefrontAnomalyCount

func QueryWavefrontAnomalyCount(serviceName string, query string, metricName string, unixtime int64, currentYear *int, currentMonth *time.Month, currentDay *int) float64

QueryWavefrontAnomalyCount - run query for servicename at unix time to get anomaly count from WAVEFRONT returns value of anomaly count

func StartAnalyzing

func StartAnalyzing(analyzingRequest ApplicationHealthAnalyzeRequest) (string, error)

StartAnalyzing - send the request to the foremast service to start the job

Types

type Analyst

type Analyst struct {
	Endpoint string `json:"endpoint"`

	//Default is 0.0.1
	Version string `json:"version,omitempty"`
}

type AnomalousMetric

type AnomalousMetric struct {
	Name string `json:"name"`

	Tags string `json:"tags,omitempty"`

	Values []AnomalousMetricValue `json:"values"`
}

type AnomalousMetricValue

type AnomalousMetricValue struct {
	Time  int64   `json:"time"`
	Value float64 `json:"value"`
}

type Anomaly

type Anomaly struct {
	AnomalousMetrics []AnomalousMetric `json:"anomalousMetrics,omitempty"`
}

Anomaly detected

type AnomalyInfo

type AnomalyInfo struct {
	Tags   string    `json:"tags"`
	Values []float64 `json:"values"`
}

type ApplicationHealthAnalyzeRequest

type ApplicationHealthAnalyzeRequest struct {
	AppName string `json:"appName"`

	//RFC3339     = "2006-01-02T15:04:05Z07:00"
	StartTime string `json:"startTime"`

	//RFC3339     = "2006-01-02T15:04:05Z07:00"
	EndTime string `json:"endTime"`

	//// key: current, baseline, historical
	Metrics MetricsInfo `json:"metrics"`

	// canary or blue-green
	Strategy string `json:"strategy"`
}

type ApplicationHealthAnalyzeResponse

type ApplicationHealthAnalyzeResponse struct {
	StatusCode int32 `json:"statusCode"`

	Reason string `json:"reason,omitempty"`

	JobId string `json:"jobId"`

	Status string `json:"status"`

	Anomaly map[string]AnomalyInfo `json:"anomaly,omitempty"`
}

func CheckJobStatus

func CheckJobStatus(jobID string, serviceName string) ApplicationHealthAnalyzeResponse

CheckJobStatus - query the foremast service for the job status

type Client

type Client struct {
	BaseURL   *url.URL
	UserAgent string

	HttpClient *http.Client
}

func NewClient

func NewClient(HttpClient *http.Client, endpoint string) (*Client, error)

func (*Client) GetStatus

func (c *Client) GetStatus(jobId string) (ApplicationHealthAnalyzeResponse, error)

func (*Client) StartAnalyzing

func (c *Client) StartAnalyzing(namespace string, appName string, podNames [][]string, endpoint string, metrics Metrics, timeWindow time.Duration, strategy string) (string, error)

type ContactData

type ContactData struct {
	// Name is the descriptive name.
	Name string `json:"name,omitempty"`

	// Url could typically be a website address.
	Url string `json:"url,omitempty"`

	// Email is the email address.
	Email string `json:"email,omitempty"`
}

ContactData contains information about an individual or organization.

type DeploymentMetadata

type DeploymentMetadata struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec DeploymentMetadataSpec `json:"spec"`
	// The status object for the Application.
	Status DeploymentMetadataStatus `json:"status,omitempty"`
}

DeploymentMetadata describes a DeploymentMetadata.

type DeploymentMetadataList

type DeploymentMetadataList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata"`

	Items []DeploymentMetadata `json:"items"`
}

DeploymentMetadataList is a list of DeploymentMetadata resources

type DeploymentMetadataSpec

type DeploymentMetadataSpec struct {
	Analyst Analyst `json:"analyst"`

	// Description is human readable content explaining the purpose of the link.
	Description string `json:"description,omitempty"`

	// Metrics metadata
	Metrics Metrics `json:"metrics"`

	// Logs should be monitored by canary deployment
	Logs []Logs `json:"logs,omitempty"`

	// Descriptor regroups information and metadata about an application.
	Descriptor Descriptor `json:"descriptor,omitempty"`
}

DeploymentMetadataSpec is the spec for a DeploymentMetadata resource

type DeploymentMetadataStatus

type DeploymentMetadataStatus struct {
	// ObservedGeneration is used by the DeploymentMetadata Controller to report the last Generation of a DeploymentMetadata
	// that it has observed.
	ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

DeploymentMetadataStatus defines controllers the observed state of DeploymentMetadata

type DeploymentMonitor

type DeploymentMonitor struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec DeploymentMonitorSpec `json:"spec"`
	// The status object for the Application.
	Status DeploymentMonitorStatus `json:"status,omitempty"`
}

DeploymentMonitor describes a DeploymentMonitor information.

type DeploymentMonitorList

type DeploymentMonitorList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata"`

	Items []DeploymentMonitor `json:"items"`
}

DeploymentMonitorList is a list of DeploymentMonitor resources

type DeploymentMonitorSpec

type DeploymentMonitorSpec struct {
	// Selector is a label query over kinds that created by the application. It must match the component objects' labels.
	// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
	Selector *metav1.LabelSelector `json:"selector,omitempty"`

	Analyst Analyst `json:"analyst,omitempty"`

	StartTime string `json:"startTime,omitempty"`

	WaitUntil string `json:"waitUntil,omitempty"`

	// Metrics metadata
	Metrics Metrics `json:"metrics,omitempty"`

	// Logs should be monitored by canary deployment
	Logs []Logs `json:"logs,omitempty"`

	// Continuous monitoring or not
	Continuous bool `json:"continuous,omitempty"`

	// Remediation action
	Remediation RemediationAction `json:"remediation,omitempty"`

	// Rollback revision
	RollbackRevision int64 `json:"rollbackRevision,omitempty"`
}

type DeploymentMonitorStatus

type DeploymentMonitorStatus struct {
	// ObservedGeneration is used by the DeploymentMetadata Controller to report the last Generation of a DeploymentMetadata
	// that it has observed.
	ObservedGeneration int64 `json:"observedGeneration,omitempty"`

	JobId string `json:"jobId,omitempty"`

	Phase string `json:"phase"`

	RemediationTaken bool `json:"remediationTaken"`

	Anomaly Anomaly `json:"anomaly,omitempty"`

	Timestamp string `json:"timestamp"`

	Expired bool `json:"expired"`
}

DeploymentMonitorStatus defines controllers the observed state of DeploymentMonitor

type Descriptor

type Descriptor struct {
	// Type is the type of the application (e.g. SpringBoot, NodeJS, Python).
	Type string `json:"type,omitempty"`

	// Version is an optional version indicator for the Application.
	Version string `json:"version,omitempty"`

	// Description is a brief string description of the Application.
	Description string `json:"description,omitempty"`

	// Icons is an optional list of icons for an application. Icon information includes the source, size,
	// and mime type.
	Icons []ImageSpec `json:"icons,omitempty"`

	// Maintainers is an optional list of maintainers of the application. The maintainers in this list maintain the
	// the source code, images, and package for the application.
	Maintainers []ContactData `json:"maintainers,omitempty"`

	// Owners is an optional list of the owners of the installed application. The owners of the application should be
	// contacted in the event of a planned or unplanned disruption affecting the application.
	Owners []ContactData `json:"owners,omitempty"`

	// Keywords is an optional list of key words associated with the application (e.g. MySQL, RDBMS, database).
	Keywords []string `json:"keywords,omitempty"`

	// Links are a list of descriptive URLs intended to be used to surface additional documentation, dashboards, etc.
	Links []Link `json:"links,omitempty"`

	// Notes contain a human readable snippets intended as a quick start for the users of the Application.
	// CommonMark markdown syntax may be used for rich text representation.
	Notes string `json:"notes,omitempty"`
}

The following descriptor https://github.com/kubernetes-sigs/application/blob/master/pkg/apis/app/v1beta1/application_types.go Descriptor defines the Metadata and information about the DeploymentMetadata.

type ImageSpec

type ImageSpec struct {
	// The source for image represented as either an absolute URL to the image or a Data URL containing
	// the image. Data URLs are defined in RFC 2397.
	Source string `json:"src"`

	// (optional) The size of the image in pixels (e.g., 25x25).
	Size string `json:"size,omitempty"`

	// (optional) The mine type of the image (e.g., "image/png").
	Type string `json:"type,omitempty"`
}

ImageSpec contains information about an image used as an icon.

type Interface

type Interface interface {
	StartAnalyzing(namespace string, appName string, podNames [][]string, endpoint string, metrics Metrics, timeWindow time.Duration) (string, error)
	GetStatus(jobId string) (ApplicationHealthAnalyzeResponse, error)
}

type JobInfo

type JobInfo struct {
	JobID        string
	ErrorQuery   string
	LatencyQuery string
	TPSQuery     string
	Request      ApplicationHealthAnalyzeRequest
}

type JobInfoM

type JobInfoM struct {
	JobID     string
	MetricMap map[string]string
	Request   ApplicationHealthAnalyzeRequest
}

type JobRequest

type JobRequest struct {
	Query map[string]map[string][]string `json:"query"`
}
type Link struct {
	// Description is human readable content explaining the purpose of the link.
	Description string `json:"description,omitempty"`

	// Url typically points at a website address.
	Url string `json:"url,omitempty"`
}

Link contains information about an URL to surface documentation, dashboards, etc.

type Logs

type Logs struct {
	LogName string `json:"logName"`

	LogType string `json:"logType"`

	// Default is "logName" + ".log"
	FilePattern string `json:"filePattern,omitempty"`
}

type MetricQuery

type MetricQuery struct {
	DataSourceType string `json:"dataSourceType"`

	Parameters map[string]interface{} `json:"parameters,omitempty"`
}

type Metrics

type Metrics struct {

	// prometheus or other metrics solution
	DataSourceType string `json:"dataSourceType"`

	// Endpoint of prometheus
	Endpoint string `json:"endpoint"`

	// Monitoring contains the metrics should be monitored by canary deployment
	Monitoring []Monitoring `json:"monitoring,omitempty"`
}

Metrics metadata

type MetricsInfo

type MetricsInfo struct {
	Current map[string]MetricQuery `json:"current"`

	Baseline map[string]MetricQuery `json:"baseline,omitempty"`

	Historical map[string]MetricQuery `json:"historical,omitempty"`
}

func CreateMetricsInfo

func CreateMetricsInfo(namespace string, appName string, podNames [][]string, metrics Metrics, timeWindow time.Duration, strategy string) (MetricsInfo, error)

type Monitoring

type Monitoring struct {
	MetricName string `json:"metricName"`

	// Gauge counter timer etc. Default is counter
	MetricType string `json:"metricType,omitempty"`

	// Shorten name in backend system
	MetricAlias string `json:"metricAlias"`
}

type RemediationAction

type RemediationAction struct {
	Option string `json:"option"`

	Parameters map[string]string `json:"parameters,omitempty"`
}

Option could be RemediationNone, RemediationAutoRollback, RemediationAutoPause, RemediationAutoScaling, RemediationAuto

Jump to

Keyboard shortcuts

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