Documentation ¶
Index ¶
- Variables
- func BackfillOption(count int) func(*Options)
- func DryRunOption(dryRun bool) func(*Options)
- func MetricsComparate(c evaluator.Comparator, metrics Metrics, startAt, endAt time.Time) (map[time.Time]bool, error)
- type App
- type Config
- type Dashboard
- type Definition
- type DefinitionConfig
- type DefinitionConfigs
- type MackerelClient
- type Metric
- func (m *Metric) AggregationInterval() time.Duration
- func (m *Metric) AppendValue(t time.Time, v interface{}) error
- func (m *Metric) EndAt() time.Time
- func (m *Metric) GetValue(t time.Time) (float64, bool)
- func (m *Metric) GetValues(startAt time.Time, endAt time.Time) map[time.Time]float64
- func (m *Metric) ID() string
- func (m *Metric) StartAt() time.Time
- func (m *Metric) String() string
- type MetricConfig
- type MetricConfigs
- type MetricType
- type Metrics
- type ObjectiveConfig
- type Options
- type Report
- type Repository
- func (repo *Repository) FetchMetric(ctx context.Context, cfg *MetricConfig, startAt time.Time, endAt time.Time) (*Metric, error)
- func (repo *Repository) FetchMetrics(ctx context.Context, cfgs MetricConfigs, startAt time.Time, endAt time.Time) (Metrics, error)
- func (repo *Repository) FindDashboard(dashboardIDOrURL string) (*Dashboard, error)
- func (repo *Repository) FindDashboardID(dashboardIDOrURL string) (string, error)
- func (repo *Repository) SaveDashboard(ctx context.Context, dashboard *Dashboard) error
- func (repo *Repository) SaveReports(ctx context.Context, reports []*Report) error
Constants ¶
This section is empty.
Variables ¶
var ErrDashboardNotFound = errors.New("dashboard not found")
Functions ¶
func BackfillOption ¶
BackfillOption specifies how many points of data to calculate retroactively from the current time.
func DryRunOption ¶
DryRunOption is an option to output the calculated error budget as standard without posting it to Mackerel.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App manages life cycle
func NewWithMackerelClient ¶
func NewWithMackerelClient(client MackerelClient, cfg *Config) (*App, error)
NewWithMackerelClient is there to accept mock clients.
func (*App) DashboardBuild ¶ added in v0.3.0
func (*App) DashboardInit ¶ added in v0.3.0
type Config ¶
type Config struct { RequiredVersion string `yaml:"required_version" json:"required_version"` Metrics MetricConfigs `yaml:"metrics" json:"metrics"` Definitions DefinitionConfigs `yaml:"definitions" json:"definitions"` Dashboard string `json:"dashboard,omitempty" yaml:"dashboard,omitempty"` // contains filtered or unexported fields }
Config for App
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
NewDefaultConfig creates a default configuration.
func (*Config) ValidateVersion ¶
ValidateVersion validates a version satisfies required_version.
type Definition ¶
type Definition struct {
// contains filtered or unexported fields
}
Definition is SLI/SLO Definition
func NewDefinition ¶
func NewDefinition(cfg *DefinitionConfig) (*Definition, error)
NewDefinition creates Definition from DefinitionConfig
func (*Definition) CreateRepoorts ¶
CreateRepoorts returns Report with Metrics
type DefinitionConfig ¶
type DefinitionConfig struct { ID string `json:"id" yaml:"id"` TimeFrame string `yaml:"time_frame" json:"time_frame"` ServiceName string `json:"service_name" yaml:"service_name"` ErrorBudgetSize float64 `yaml:"error_budget_size" json:"error_budget_size"` CalculateInterval string `yaml:"calculate_interval" json:"calculate_interval"` Objectives []*ObjectiveConfig `json:"objectives" yaml:"objectives"` // contains filtered or unexported fields }
DefinitionConfig is a setting related to SLI/SLO
func (*DefinitionConfig) DurationCalculate ¶
func (c *DefinitionConfig) DurationCalculate() time.Duration
DurationCalculate converts CalculateInterval as time.Duration
func (*DefinitionConfig) DurationTimeFrame ¶
func (c *DefinitionConfig) DurationTimeFrame() time.Duration
DurationTimeFrame converts TimeFrame as time.Duration
func (*DefinitionConfig) MergeInto ¶
func (c *DefinitionConfig) MergeInto(o *DefinitionConfig)
MergeInto merges DefinitionConfig together
func (*DefinitionConfig) Restrict ¶
func (c *DefinitionConfig) Restrict() error
Restrict restricts a definition configuration.
type DefinitionConfigs ¶
type DefinitionConfigs map[string]*DefinitionConfig
DefinitionConfigs is a collection of DefinitionConfigs that corrects the uniqueness of IDs.
func (DefinitionConfigs) MarshalYAML ¶
func (c DefinitionConfigs) MarshalYAML() (interface{}, error)
MarshalYAML implements yaml.Marhaller
func (DefinitionConfigs) Restrict ¶
func (c DefinitionConfigs) Restrict() error
Restrict restricts a definition configuration.
func (DefinitionConfigs) String ¶
func (c DefinitionConfigs) String() string
String implements fmt.Stringer
func (DefinitionConfigs) ToSlice ¶
func (c DefinitionConfigs) ToSlice() []*DefinitionConfig
func (*DefinitionConfigs) UnmarshalYAML ¶
func (c *DefinitionConfigs) UnmarshalYAML(unmarshal func(interface{}) error) error
MarshalYAML implements yaml.Unmarhaller
type MackerelClient ¶
type MackerelClient interface { FindHosts(param *mackerel.FindHostsParam) ([]*mackerel.Host, error) FetchHostMetricValues(hostID string, metricName string, from int64, to int64) ([]mackerel.MetricValue, error) FetchServiceMetricValues(serviceName string, metricName string, from int64, to int64) ([]mackerel.MetricValue, error) PostServiceMetricValues(serviceName string, metricValues []*mackerel.MetricValue) error FindDashboards() ([]*mackerel.Dashboard, error) FindDashboard(dashboardID string) (*mackerel.Dashboard, error) CreateDashboard(param *mackerel.Dashboard) (*mackerel.Dashboard, error) UpdateDashboard(dashboardID string, param *mackerel.Dashboard) (*mackerel.Dashboard, error) }
MackerelClient is an abstraction interface for mackerel-client-go.Client
type Metric ¶
type Metric struct {
// contains filtered or unexported fields
}
Metric handles aggregated Mackerel metrics
func NewMetric ¶
func NewMetric(cfg *MetricConfig) *Metric
func (*Metric) AggregationInterval ¶
AggregationInterval returns the aggregation interval for metrics
func (*Metric) AppendValue ¶
AppendValue adds a value to the metric
type MetricConfig ¶
type MetricConfig struct { ID string `yaml:"id,omitempty" json:"id,omitempty"` Type MetricType `yaml:"type,omitempty" json:"type,omitempty"` Name string `yaml:"name,omitempty" json:"name,omitempty"` ServiceName string `yaml:"service_name,omitempty" json:"service_name,omitempty"` Roles []string `yaml:"roles,omitempty" json:"roles,omitempty"` HostName string `yaml:"host_name,omitempty" json:"host_name,omitempty"` AggregationInterval string `yaml:"aggregation_interval,omitempty" json:"aggregation_interval,omitempty"` AggregationMethod string `json:"aggregation_method,omitempty" yaml:"aggregation_method,omitempty"` // contains filtered or unexported fields }
MetricConfig handles metric information obtained from Mackerel
func (*MetricConfig) DurationAggregation ¶ added in v0.1.0
func (c *MetricConfig) DurationAggregation() time.Duration
DurationAggregation converts CalculateInterval as time.Duration
func (*MetricConfig) MergeInto ¶
func (c *MetricConfig) MergeInto(o *MetricConfig)
MergeInto merges MetricConfigs together
func (*MetricConfig) Restrict ¶
func (c *MetricConfig) Restrict() error
Restrict restricts a configuration.
type MetricConfigs ¶
type MetricConfigs map[string]*MetricConfig
MetricConfigs is a collection of MetricConfig
func (MetricConfigs) MarshalYAML ¶
func (c MetricConfigs) MarshalYAML() (interface{}, error)
MarshalYAML controls Yamlization
func (MetricConfigs) Restrict ¶
func (c MetricConfigs) Restrict() error
Restrict restricts a metric configuration.
func (MetricConfigs) ToSlice ¶
func (c MetricConfigs) ToSlice() []*MetricConfig
ToSlice converts the collection to Slice
func (*MetricConfigs) UnmarshalYAML ¶
func (c *MetricConfigs) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML merges duplicate ID MetricConfig
type MetricType ¶
type MetricType int
MetricType is the type of metric in Mackerel
const ( HostMetric MetricType = iota + 1 //host ServiceMetric //service )
Reserved value
func MetricTypeString ¶
func MetricTypeString(s string) (MetricType, error)
MetricTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func MetricTypeValues ¶
func MetricTypeValues() []MetricType
MetricTypeValues returns all values of the enum
func (MetricType) IsAMetricType ¶
func (i MetricType) IsAMetricType() bool
IsAMetricType returns "true" if the value is listed in the enum definition. "false" otherwise
func (MetricType) MarshalJSON ¶
func (i MetricType) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for MetricType
func (MetricType) MarshalText ¶
func (i MetricType) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface for MetricType
func (MetricType) String ¶
func (i MetricType) String() string
func (*MetricType) UnmarshalJSON ¶
func (i *MetricType) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for MetricType
func (*MetricType) UnmarshalText ¶
func (i *MetricType) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface for MetricType
type Metrics ¶
Metrics is a collection of metrics
func (Metrics) AggregationInterval ¶
AggregationInterval returns the longest aggregation period for the metric in the collection
type ObjectiveConfig ¶
type ObjectiveConfig struct { Expr string `yaml:"expr" json:"expr"` // contains filtered or unexported fields }
Objective Config is a SLO setting
func (*ObjectiveConfig) GetComparator ¶ added in v0.2.3
func (c *ObjectiveConfig) GetComparator() evaluator.Comparator
GetComparator returns a Comparator generated from ObjectiveConfig
func (*ObjectiveConfig) Restrict ¶
func (c *ObjectiveConfig) Restrict() error
Restrict restricts a configuration.
type Report ¶
type Report struct { DefinitionID string ServiceName string DataPoint time.Time TimeFrameStartAt time.Time TimeFrameEndAt time.Time UpTime time.Duration FailureTime time.Duration ErrorBudgetSize time.Duration ErrorBudget time.Duration ErrorBudgetConsumption time.Duration }
Report has SLI/ SLO/ErrorBudget numbers in one rolling window
func (*Report) ErrorBudgetConsumptionRate ¶
ErrorBudgetConsumptionRate returns ErrorBudgetConsumption/ErrorBudgetSize
func (*Report) ErrorBudgetUsageRate ¶
ErrorBudgetUsageRate returns (1.0 - ErrorBudget/ErrorBudgetSize)
func (*Report) MarshalJSON ¶
MarshalJSON implements json.Marshaler
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository handles reading and writing data
func NewRepository ¶
func NewRepository(client MackerelClient) *Repository
NewRepository cretates Repository
func (*Repository) FetchMetric ¶
func (repo *Repository) FetchMetric(ctx context.Context, cfg *MetricConfig, startAt time.Time, endAt time.Time) (*Metric, error)
FetchMetric gets Metric using MatricConfig
func (*Repository) FetchMetrics ¶
func (repo *Repository) FetchMetrics(ctx context.Context, cfgs MetricConfigs, startAt time.Time, endAt time.Time) (Metrics, error)
FetchMetrics gets metrics togetheri
func (*Repository) FindDashboard ¶ added in v0.3.0
func (repo *Repository) FindDashboard(dashboardIDOrURL string) (*Dashboard, error)
FindDashboard get Mackerel Dashboard
func (*Repository) FindDashboardID ¶ added in v0.3.0
func (repo *Repository) FindDashboardID(dashboardIDOrURL string) (string, error)
FindDashboardID get Mackerel Dashboard ID from url or id
func (*Repository) SaveDashboard ¶ added in v0.3.0
func (repo *Repository) SaveDashboard(ctx context.Context, dashboard *Dashboard) error
SaveDashboard post Mackerel Dashboard
func (*Repository) SaveReports ¶
func (repo *Repository) SaveReports(ctx context.Context, reports []*Report) error
SaveReports posts Reports to Mackerel