Documentation ¶
Index ¶
- Constants
- Variables
- func AnnotatePointInTime(obj client.Object, ts time.Time, tags []Tag)
- func AnnotateTimerange(obj client.Object, tsStart time.Time, tsEnd time.Time, tags []Tag)
- func BuildURL(grafanaEndpoint string, dashboard string, from int64, to int64, postfix string) string
- func ConvertEvaluatorAlias(alias string) string
- func DeleteClientFor(obj metav1.Object)
- func HasClientFor(obj metav1.Object) bool
- func SetClientFor(obj metav1.Object, client *Client)
- type AlertRule
- type Annotation
- type Client
- func (c *Client) AddAnnotation(annotationRequest sdk.CreateAnnotationRequest) (reqID uint)
- func (c *Client) DownloadData(ctx context.Context, url *URL, destDir string) error
- func (c *Client) ListPanels(ctx context.Context, dashboardUID string) ([]PanelRef, error)
- func (c *Client) PatchAnnotation(reqID uint, annotationRequest sdk.PatchAnnotationRequest)
- func (c *Client) SetAlert(ctx context.Context, alert *AlertRule, name string, msg string) error
- func (c *Client) SetNotificationChannel(parentCtx context.Context, webhookURL string) error
- func (c *Client) UnsetAlert(alertID string)
- type DataRequest
- type ExecErrState
- type Metric
- type NoDataState
- type Option
- type Options
- type PanelRef
- type Query
- type RawTimeRange
- type Tag
- type TimeRange
- type URL
- func (url *URL) AnnotationsQuery() string
- func (url *URL) DataSourceQuery() string
- func (url *URL) WithDashboard(dashboardUID string) *URL
- func (url *URL) WithFromTS(ts time.Time) *URL
- func (url *URL) WithKiosk() *URL
- func (url *URL) WithPanel(panelID uint) *URL
- func (url *URL) WithToTS(ts time.Time) *URL
Constants ¶
const ( DefaultEvaluationFrequency = "1m" DefaultDecisionWindow = "0s" )
const ( ErrOK ExecErrState = "OK" ErrError ExecErrState = "Error" ErrAlerting ExecErrState = "Alerting" NoDataOk NoDataState = "OK" NoData NoDataState = "NoData" NoDataAlerting NoDataState = "Alerting" )
const ( TagCreated = "create" TagDeleted = "delete" TagFailed = "failed" TagChaos = "chaos" )
Variables ¶
var DefaultVariableEvaluation = map[string]string{
"Instance": ".+",
"Node": ".+",
}
DefaultVariableEvaluation contains the default replacement of environment variables in Grafana expressions.
var Timeout = 2 * time.Minute
Functions ¶
func AnnotatePointInTime ¶ added in v1.0.40
func AnnotateTimerange ¶ added in v1.0.40
func ConvertEvaluatorAlias ¶
func DeleteClientFor ¶
DeleteClientFor removes the client registered for the given object.
func HasClientFor ¶ added in v1.0.38
HasClientFor returns whether there is a non-nil grafana client is registered for the given object.
func SetClientFor ¶
SetClientFor creates a new client for the given object. It panics if it cannot parse the object's metadata, or if another client is already registers.
Types ¶
type AlertRule ¶ added in v1.0.37
type AlertRule struct { Metric Query // FromTime indicate a relative duration accounted for the alerting. e.g, 15m ago FromTime string // ToTime indicate a point of reference accounted for the alerting. e.g, now ToTime string // Frequency specifies how frequently an alert rule is evaluated Must be a multiple of 10 seconds. For examples, 1m, 30s. Frequency string // Duration, when configured, specifies the duration for which the condition must be true before an alert fires. Duration string }
AlertRule is a set of evaluation criteria that determines whether an alert will fire. The alert rule consists of one or more queries and expressions, a condition, the frequency of evaluation, and optionally, the duration over which the condition is met.
func ParseAlertExpr ¶
func ParseAlertExpr(query v1alpha1.ExprMetrics) (*AlertRule, error)
type Annotation ¶
type Annotation interface { // Add pushes an annotation to grafana indicating that a new component has joined the experiment. Add(obj client.Object) // Delete pushes an annotation to grafana indicating that a new component has left the experiment. Delete(obj client.Object) }
Annotation provides a way to mark points on the graph with rich events.
type Client ¶
type Client struct { Conn *sdk.Client GapiClient *gapi.Client BaseURL string // contains filtered or unexported fields }
func GetClientFor ¶
GetClientFor returns the client with the given name. It panics if it cannot parse the object's metadata, if the client does not exist, or if the client is empty.
func (*Client) AddAnnotation ¶ added in v1.0.40
func (c *Client) AddAnnotation(annotationRequest sdk.CreateAnnotationRequest) (reqID uint)
AddAnnotation inserts a new annotation to Grafana.
func (*Client) DownloadData ¶ added in v1.0.37
DownloadData returns data for the given panel.
func (*Client) ListPanels ¶ added in v1.0.37
ListPanels returns a list of Panels ID with a Grafana dashboard.
func (*Client) PatchAnnotation ¶
func (c *Client) PatchAnnotation(reqID uint, annotationRequest sdk.PatchAnnotationRequest)
PatchAnnotation updates an existing annotation to Grafana.
func (*Client) SetNotificationChannel ¶
func (*Client) UnsetAlert ¶
UnsetAlert removes an alert from Grafana.
type DataRequest ¶ added in v1.0.37
type DataRequest struct { Queries []interface{} `json:"queries"` Range TimeRange `json:"range"` From string `json:"from"` To string `json:"to"` }
DataRequest is used to ask DataFrame from Grafana.
type ExecErrState ¶ added in v1.0.41
type ExecErrState string
type Metric ¶
Metric points to the Grafana metric we are interested in. The location can be retrieved from the Grafana URL. Example: URL: http://grafana.platform.science-hangar.eu/d/wpFnYRwGk/iperf?orgId=1&viewPanel=2 Metric: wpFnYRwGk/2/bitrate.
type NoDataState ¶ added in v1.0.41
type NoDataState string
type Option ¶
type Option func(*Options)
func WithLogger ¶
WithLogger will use the given logger for printing info.
func WithNotifications ¶
WithNotifications will update the object's annotations if a Grafana alert is triggered.
func WithRegisterFor ¶
WithRegisterFor will register the client with the given name. Registered clients are retrievable by GetFrisbeeClient().
type Query ¶
type Query struct { /* == Evaluator * below * above * within_range * outside_range * empty */ Evaluator sdk.AlertEvaluator /* == Reducers * avg * min * max * sum * count * last * median * diff * diff_abs * percent_diff * percent_diff_abs * count_non_null */ Reducer sdk.AlertReducer }
type RawTimeRange ¶ added in v1.0.37
type TimeRange ¶
type TimeRange struct { From time.Time `json:"from"` To time.Time `json:"to"` Raw *RawTimeRange `json:"raw"` }
type URL ¶ added in v1.0.37
type URL struct { Endpoint string DashboardUID *string FromTS *time.Time ToTS *time.Time PanelID *uint Kiosk bool }
func NewURL ¶ added in v1.0.37
NewURL access an endpoint at the form: grafana-fedbed-48.knot-platform.eu