rest

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 8 more Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// VersionKey is a key of version
	VersionKey = "version"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AlarmMetric

type AlarmMetric struct {
	Measurement       string     `json:"Measurement"`
	MetricName        string     `json:"MetricName"`
	MetricDisplayName string     `json:"MetricDisplayName"`
	ContinuePeriod    int64      `json:"ContinuePeriod"`
	Evaluator         *Evaluator `json:"Evaluator"`
	Unit              string     `json:"Unit"`
}

AlarmMetric defines alarm metric info

func NewAlarmMetricFromRule

func NewAlarmMetricFromRule(ruleGroup *v1.RuleGroup, rule v1.Rule) *AlarmMetric

NewAlarmMetricFromRule creates AlarmMetric from rule and ruleGroup

func (*AlarmMetric) GetAnnotations

func (r *AlarmMetric) GetAnnotations(alarmPolicy *AlarmPolicy) map[string]string

GetAnnotations builds annotations of prometheus rule from AlarmMetric and AlarmPolicy

func (*AlarmMetric) GetExpr

func (r *AlarmMetric) GetExpr(alarmPolicy *AlarmPolicy) string

GetExpr builds expr of prometheus rule from AlarmMetric and AlarmPolicy

func (*AlarmMetric) GetFor

func (r *AlarmMetric) GetFor(statisticsPeriod int64) string

GetFor computes For of prometheus rule from statisticsPeriod and ContinuePeriod

func (*AlarmMetric) GetLabels

func (r *AlarmMetric) GetLabels(alarmPolicyName string, version string) map[string]string

GetLabels builds labels of prometheus rule from AlarmMetric

type AlarmPolicies

type AlarmPolicies []*AlarmPolicy

AlarmPolicies defines slice of AlarmPolicy

func (AlarmPolicies) Len

func (a AlarmPolicies) Len() int

Len implements sort interface for AlarmPolicies

func (AlarmPolicies) Less

func (a AlarmPolicies) Less(i, j int) bool

Less implements sort interface for AlarmPolicies

func (AlarmPolicies) Swap

func (a AlarmPolicies) Swap(i, j int)

Swap implements sort interface for AlarmPolicies

type AlarmPolicy

type AlarmPolicy struct {
	AlarmPolicySettings *AlarmPolicySettings `json:"AlarmPolicySettings"`
	NotifySettings      *NotifySettings      `json:"NotifySettings"`
	Namespace           string               `json:"Namespace"`
	WorkloadType        string               `json:"WorkloadType"`
}

AlarmPolicy defines alarm policy info

func NewAlarmPolicyFromRuleGroup

func NewAlarmPolicyFromRuleGroup(ruleGroup *v1.RuleGroup) *AlarmPolicy

NewAlarmPolicyFromRuleGroup creates AlarmPolicy from ruleGroup

func (*AlarmPolicy) GetInterval

func (p *AlarmPolicy) GetInterval() string

GetInterval computes interval of ruleGroup from AlarmPolicySettings.StatisticsPeriod

func (*AlarmPolicy) Validate

func (p *AlarmPolicy) Validate() error

Validate check if the policy is available

type AlarmPolicyPagination

type AlarmPolicyPagination struct {
	Page          int64         `json:"page"`
	PageSize      int64         `json:"pageSize"`
	Total         int64         `json:"total"`
	AlarmPolicies AlarmPolicies `json:"alarmPolicies"`
}

AlarmPolicyPagination defines alarm policy response with pagination ability

type AlarmPolicySettings

type AlarmPolicySettings struct {
	AlarmPolicyName  string         `json:"AlarmPolicyName"`
	AlarmPolicyType  string         `json:"AlarmPolicyType"`
	AlarmMetrics     []*AlarmMetric `json:"AlarmMetrics"`
	AlarmObjects     string         `json:"AlarmObjects"`
	AlarmObjectsType string         `json:"AlarmObjectsType"`
	StatisticsPeriod int64          `json:"statisticsPeriod"`
}

AlarmPolicySettings defines alarm policy settings

type Evaluator

type Evaluator struct {
	Type  string `json:"Type"`
	Value string `json:"Value"`
}

Evaluator contains type and value to form expr

func NewEvaluatorFromExpr

func NewEvaluatorFromExpr(expr string, isBool bool) *Evaluator

NewEvaluatorFromExpr creates Evaluator from expr

type Label

type Label struct {
	Name  string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
}

Label defines label of time series metrics

type MergedResponse

type MergedResponse struct {
	Response *MergedResult `json:"response"`
}

MergedResponse defines the merged result

type MergedResult

type MergedResult struct {
	Columns []string      `json:"columns"`
	Data    []interface{} `json:"data"`
}

MergedResult defines the result of columns and data

type MeshRequest

type MeshRequest struct {
	StartTime  int64         `json:"startTime"`
	EndTime    int64         `json:"endTime"`
	MeshID     string        `json:"meshId"`
	Namespaces []interface{} `json:"namespaces"`
	TopoType   string        `json:"topoType"`
	AppID      int           `json:"AppId"`
}

MeshRequest defines request for mesh serviceCallRelation

type MetricFilter

type MetricFilter struct {
	Namespace    string `json:"namespace"`
	WorkloadKind string `json:"workload_kind"`
	WorkloadName string `json:"workload_name"`
}

MetricFilter contains metric filter of expr

func NewMetricFilterFromExpr

func NewMetricFilterFromExpr(expr string) *MetricFilter

NewMetricFilterFromExpr creates MetricFilter from expr

func (*MetricFilter) ToStr

func (f *MetricFilter) ToStr() string

ToStr converts MetricFilter to string, which is used in expr

type MetricResult

type MetricResult struct {
	MaxValue *float64     `json:"maxValue,omitempty"`
	AvgValue *float64     `json:"avgValue,omitempty"`
	Series   []models.Row `json:"series"`
}

MetricResult defines the single metric result

type MetricsRequest

type MetricsRequest struct {
	Table      string          `json:"table"`
	StartTime  *int64          `json:"startTime"`
	EndTime    *int64          `json:"endTime"`
	Fields     []string        `json:"fields"`
	Conditions [][]interface{} `json:"conditions"`
	OrderBy    string          `json:"orderBy,omitempty"`
	Order      string          `json:"order,omitempty"`
	GroupBy    []string        `json:"groupBy"`
	Limit      int             `json:"limit,omitempty"`
	Offset     int             `json:"offset,omitempty"`
}

MetricsRequest defines the metrics request format, setting default request value

type MetricsResponse

type MetricsResponse struct {
	Results []*MetricResult `json:"results"`
}

MetricsResponse defines the metrics result

type NotifySettings

type NotifySettings struct {
	ReceiverGroups []string    `json:"ReceiverGroups"`
	Receivers      []string    `json:"Receivers"`
	NotifyWay      []NotifyWay `json:"NotifyWay"`
}

NotifySettings contains notification info of alarm policy

func NewNotifySettingsFromRuleAnnotations

func NewNotifySettingsFromRuleAnnotations(annotation map[string]string) *NotifySettings

NewNotifySettingsFromRuleAnnotations creates NotifySettings from rule annotation

type NotifyWay

type NotifyWay struct {
	ChannelName  string `json:"ChannelName"`
	TemplateName string `json:"TemplateName"`
}

NotifyWay contains notification channels and templates

type Request

type Request struct {
	Data string `json:"data,omitempty"`
}

Request defines the structure of http request of prometheus and alertmanager

func (*Request) Decode

func (r *Request) Decode(reader io.Reader) error

Decode decodes the reader content to request object

type Response

type Response struct {
	Result bool        `json:"result"`
	Err    string      `json:"err,omitempty"`
	Rev    int         `json:"rev,omitempty"`
	Data   interface{} `json:"data,omitempty"`
}

Response defines the structure of http response of prometheus and alertmanager

func NewResult

func NewResult(result bool, errMsg string) *Response

NewResult returns a response for http response of prometheus and alertmanager

func (*Response) Decode

func (r *Response) Decode(reader io.Reader) error

Decode decodes the reader content to response object

type ResponseForTest

type ResponseForTest struct {
	Result bool            `json:"result"`
	Err    string          `json:"err,omitempty"`
	Rev    int             `json:"rev,omitempty"`
	Data   json.RawMessage `json:"data,omitempty"`
}

ResponseForTest leaves data as json.RawMessage to unmarshal to struct we want, just for unit test

func (*ResponseForTest) Decode

func (r *ResponseForTest) Decode(reader io.Reader) error

Decode decodes the reader content to ResponseForTest object

type Sample

type Sample struct {
	Value     float64 `protobuf:"fixed64,1,opt,name=value,proto3" json:"value,omitempty"`
	Timestamp int64   `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
}

Sample defines one metrics sample

type TimeSeries

type TimeSeries struct {
	Labels  []Label  `protobuf:"bytes,1,rep,name=labels,proto3" json:"labels"`
	Samples []Sample `protobuf:"bytes,2,rep,name=samples,proto3" json:"samples"`
}

TimeSeries defines time series metrics that prepared to be send

type WriteRequest

type WriteRequest struct {
	Timeseries []TimeSeries `protobuf:"bytes,1,rep,name=timeseries,proto3" json:"timeseries"`
}

WriteRequest defines request for prom-beat

func (*WriteRequest) ProtoMessage

func (*WriteRequest) ProtoMessage()

func (*WriteRequest) Reset

func (m *WriteRequest) Reset()

func (*WriteRequest) String

func (m *WriteRequest) String() string

Jump to

Keyboard shortcuts

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