public

package
v0.0.0-...-7c3836c Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2019 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrProjectFind             = errors.New("项目查询失败")
	ErrProjectDeploymentK8sGet = errors.New("项目查询失败,请检查Kubernetes是否存在")
	ErrProjectToken            = errors.New("项目Token校验错误")
	ErrProjectEventNotPush     = errors.New("EventName not push")
	ErrProjectDeploymentGet    = errors.New("项目Deployment获取错误")
	ErrProjectMemberGet        = errors.New("build用户获取错误,可能不存在")
	ErrProjectJenkinsBuild     = errors.New("调用Jenkins Build错误")
)
View Source
var ErrLimitExceed = errors.New("Rate limit exceed!")

Functions

func MakeHandler

func MakeHandler(svc Service, logger log.Logger) http.Handler

Types

type Alert

type Alert struct {
	Status       string      `json:"status"`
	Labels       Label       `json:"labels"`
	Annotations  Annotations `json:"annotations"`
	StartsAt     string      `json:"startsAt"`
	EndsAt       string      `json:"endsAt"`
	GeneratorURL string      `json:"generatorURL"`
}

type Annotations

type Annotations struct {
	Description string `json:"description"`
	Summary     string `json:"summary"`
	From        string `json:"from"`
	To          string `json:"to"`
}

type Label

type Label struct {
	AlertName           string `json:"alertname"`
	Container           string `json:"container"`
	ContainerName       string `json:"container_name"`
	Deployment          string `json:"deployment"`
	Instance            string `json:"instance"`
	Job                 string `json:"job"`
	K8sApp              string `json:"k8s_app"`
	KubernetesName      string `json:"kubernetes_name"`
	KubernetesNamespace string `json:"kubernetes_namespace"`
	Namespace           string `json:"namespace"`
	Pod                 string `json:"pod"`
	Severity            string `json:"severity"`
	SearchID            string `json:"searchID"`
	DestinationService  string `json:"destination_service"`
	SourceService       string `json:"source_service"`
}

type Prom

type Prom struct {
	Receiver    string  `json:"receiver"`
	Status      string  `json:"status"`
	Alerts      []Alert `json:"alerts"`
	GroupLabels struct {
		AlertName string `json:"alertname"`
	} `json:"groupLabels"`
	CommonLabels      Label `json:"commonLabels"`
	CommonAnnotations struct {
		Summary     string `json:"summary"`
		Description string `json:"description"`
	} `json:"common_annotations"`
	Labels      string `json:"labels"`
	ExternalURL string `json:"externalURL"`
	StartsAt    string `json:"startsAt"`
	EndsAt      string `json:"endsAt"`
	GroupKey    string `json:"group_key"`
	Version     string `json:"version"`
}

type PrometheusAlerts

type PrometheusAlerts interface {
	Get() (prom Prom)
	String() string
	Alerts() []Alert
	GetName(label *Label) string
	GetNamespace(label *Label) string
	GetAlertName() string
	GetDesc() string
	From(alert *Alert) string
	To(alert *Alert) string
}

func NewPrometheusAlerts

func NewPrometheusAlerts(body []byte) (p PrometheusAlerts, err error)

type Service

type Service interface {
	// gitlab post过来的数据
	GitPost(ctx context.Context, namespace, name, token, keyWord, branch string, req gitlabHook) (err error)

	// prometheus 的告警数据
	PrometheusAlert(ctx context.Context, req *prometheusAlerts) error

	// 获取配置信息
	Config(ctx context.Context) (res map[string]interface{}, err error)
}

func NewInstrumentingService

func NewInstrumentingService(counter metrics.Counter, latency metrics.Histogram, s Service) Service

func NewLoggingService

func NewLoggingService(logger log.Logger, s Service) Service

func NewService

func NewService(logger log.Logger,
	cf *config.Config,
	amqpClient amqpClient.AmqpClient,
	k8sClient kubernetes.K8sClient,
	jenkins jenkins.Jenkins,
	repository repository.Repository) Service

Jump to

Keyboard shortcuts

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