Documentation
¶
Index ¶
- Constants
- Variables
- type APIError
- type Alarm
- type AlarmFilter
- type AlarmHistoryWire
- type AlarmStatusWire
- type AlarmSummaryWire
- type AlarmWire
- type ConfigProvider
- type CreateAlarmIn
- type DatapointIn
- type FailedMetric
- type Handler
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Shutdown(ctx context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- func (h *Handler) Trusted() echo.HandlerFunc
- type HistoryEntry
- type HistoryFilter
- type InMemoryBackend
- func (b *InMemoryBackend) ChangeAlarmCompartment(id, ifMatch, compartment string) error
- func (b *InMemoryBackend) Compartments() []string
- func (b *InMemoryBackend) CreateAlarm(in CreateAlarmIn) (AlarmWire, string, error)
- func (b *InMemoryBackend) DeleteAlarm(id, ifMatch string) error
- func (b *InMemoryBackend) GetAlarm(id string) (AlarmWire, string, error)
- func (b *InMemoryBackend) GetAlarmHistory(id string, f HistoryFilter, o ListOpts) (AlarmHistoryWire, string, error)
- func (b *InMemoryBackend) ListAlarms(f AlarmFilter, o ListOpts) (page.Page[AlarmSummaryWire], error)
- func (b *InMemoryBackend) ListAlarmsStatus(f AlarmFilter, o ListOpts) (page.Page[AlarmStatusWire], error)
- func (b *InMemoryBackend) ListMetrics(compartment string, in ListMetricsIn, pageToken string, limit int) (page.Page[MetricWire], error)
- func (b *InMemoryBackend) PostMetricData(in PostMetricDataIn) (PostMetricDataOut, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) SetClock(now func() time.Time)
- func (b *InMemoryBackend) SetPublisher(p Publisher)
- func (b *InMemoryBackend) SetTopicChecker(c TopicChecker)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) SummarizeMetricsData(compartment string, in SummarizeIn) ([]MetricDataWire, error)
- func (b *InMemoryBackend) Sweep(ctx context.Context)
- func (b *InMemoryBackend) UpdateAlarm(id, ifMatch string, in UpdateAlarmIn) (AlarmWire, string, error)
- type ListMetricsIn
- type ListOpts
- type MQL
- type MetricDataIn
- type MetricDataWire
- type MetricWire
- type Point
- type PostMetricDataIn
- type PostMetricDataOut
- type Provider
- type Publisher
- type Settings
- type Stream
- type SummarizeIn
- type SuppressionSpec
- type SuppressionWire
- type Tags
- type TopicChecker
- type UpdateAlarmIn
Constants ¶
const DefaultPort = 8161
DefaultPort is the dedicated listener's default TCP port.
const (
// Region is the fixed region baked into emulated OCIDs.
Region = "us-ashburn-1"
)
Variables ¶
var ErrNilAppContext = errors.New("ocimonitoring: nil app context")
ErrNilAppContext is returned when Init is called with a nil AppContext.
var ErrSnapshotNull = errors.New("ocimonitoring: null entry in snapshot")
ErrSnapshotNull is returned when a snapshot contains a null entry.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
APIError is an OCI error response: HTTP status plus the `code` and `message` body fields.
type Alarm ¶
type Alarm struct {
TimeCreated time.Time `json:"timeCreated"`
TimeUpdated time.Time `json:"timeUpdated"`
StatusSince time.Time `json:"statusSince"`
PendingSince *time.Time `json:"pendingSince,omitempty"`
LastNotified *time.Time `json:"lastNotified,omitempty"`
Suppression *SuppressionSpec `json:"suppression,omitempty"`
InSubtree *bool `json:"metricCompartmentIdInSubtree,omitempty"`
PerDimension *bool `json:"isNotificationsPerMetricDimensionEnabled,omitempty"`
Tags Tags `json:"tags"`
Extra map[string]string `json:"extra,omitempty"`
Overrides []json.RawMessage `json:"overrides,omitempty"`
ID string `json:"id"`
Name string `json:"displayName"`
CompartmentID string `json:"compartmentId"`
MetricCompartmentID string `json:"metricCompartmentId"`
Namespace string `json:"namespace"`
ResourceGroup string `json:"resourceGroup,omitempty"`
Query string `json:"query"`
Severity string `json:"severity"`
Body string `json:"body,omitempty"`
Resolution string `json:"resolution"`
PendingDuration string `json:"pendingDuration"`
RepeatNotification string `json:"repeatNotificationDuration,omitempty"`
MessageFormat string `json:"messageFormat"`
Status string `json:"status"`
Etag string `json:"etag"`
Destinations []string `json:"destinations"`
History []HistoryEntry `json:"history,omitempty"`
Seq int64 `json:"seq"`
Enabled bool `json:"isEnabled"`
}
Alarm is a stored alarm and its evaluation state.
type AlarmFilter ¶
type AlarmFilter struct {
Compartment, Name, State string
}
AlarmFilter narrows ListAlarms and ListAlarmsStatus.
type AlarmHistoryWire ¶
type AlarmHistoryWire struct {
AlarmID string `json:"alarmId"`
Entries []historyEntryWire `json:"entries"`
IsEnabled bool `json:"isEnabled"`
}
AlarmHistoryWire is the GetAlarmHistory response body.
type AlarmStatusWire ¶
type AlarmStatusWire struct {
TimestampTriggered time.Time `json:"timestampTriggered"`
Suppression *SuppressionWire `json:"suppression,omitempty"`
ID string `json:"id"`
Name string `json:"displayName"`
Severity string `json:"severity"`
Status string `json:"status"`
}
AlarmStatusWire is the ListAlarmsStatus item.
type AlarmSummaryWire ¶
type AlarmSummaryWire struct {
Suppression *SuppressionWire `json:"suppression,omitempty"`
PerDimension *bool `json:"isNotificationsPerMetricDimensionEnabled,omitempty"`
FreeformTags map[string]string `json:"freeformTags,omitempty"`
DefinedTags map[string]map[string]any `json:"definedTags,omitempty"`
ID string `json:"id"`
Name string `json:"displayName"`
CompartmentID string `json:"compartmentId"`
MetricComp string `json:"metricCompartmentId"`
Namespace string `json:"namespace"`
ResourceGroup string `json:"resourceGroup,omitempty"`
Query string `json:"query"`
Severity string `json:"severity"`
LifecycleState string `json:"lifecycleState"`
Destinations []string `json:"destinations"`
Enabled bool `json:"isEnabled"`
}
AlarmSummaryWire is the ListAlarms item.
type AlarmWire ¶
type AlarmWire struct {
TimeCreated time.Time `json:"timeCreated"`
TimeUpdated time.Time `json:"timeUpdated"`
Suppression *SuppressionWire `json:"suppression,omitempty"`
InSubtree *bool `json:"metricCompartmentIdInSubtree,omitempty"`
PerDimension *bool `json:"isNotificationsPerMetricDimensionEnabled,omitempty"`
FreeformTags map[string]string `json:"freeformTags,omitempty"`
DefinedTags map[string]map[string]any `json:"definedTags,omitempty"`
RuleName *string `json:"ruleName,omitempty"`
NotifVersion *string `json:"notificationVersion,omitempty"`
NotifTitle *string `json:"notificationTitle,omitempty"`
EvalSlack *string `json:"evaluationSlackDuration,omitempty"`
AlarmSummary *string `json:"alarmSummary,omitempty"`
ID string `json:"id"`
Name string `json:"displayName"`
CompartmentID string `json:"compartmentId"`
MetricComp string `json:"metricCompartmentId"`
Namespace string `json:"namespace"`
ResourceGroup string `json:"resourceGroup,omitempty"`
Query string `json:"query"`
Resolution string `json:"resolution"`
Pending string `json:"pendingDuration"`
Severity string `json:"severity"`
Body string `json:"body,omitempty"`
MessageFormat string `json:"messageFormat"`
Repeat string `json:"repeatNotificationDuration,omitempty"`
LifecycleState string `json:"lifecycleState"`
Destinations []string `json:"destinations"`
Overrides []json.RawMessage `json:"overrides,omitempty"`
Enabled bool `json:"isEnabled"`
}
AlarmWire is the Alarm response shape.
type ConfigProvider ¶
type ConfigProvider interface {
GetOCIMonitoringSettings() Settings
}
ConfigProvider extracts OCI Monitoring configuration from the AppContext Config.
type CreateAlarmIn ¶
type CreateAlarmIn struct {
Tags
InSubtree *bool `json:"metricCompartmentIdInSubtree"`
PerDimension *bool `json:"isNotificationsPerMetricDimensionEnabled"`
Enabled *bool `json:"isEnabled"`
Suppression *SuppressionWire `json:"suppression"`
ResourceGroup *string `json:"resourceGroup"`
Resolution *string `json:"resolution"`
Pending *string `json:"pendingDuration"`
Body *string `json:"body"`
MessageFormat *string `json:"messageFormat"`
Repeat *string `json:"repeatNotificationDuration"`
RuleName *string `json:"ruleName"`
NotifVersion *string `json:"notificationVersion"`
NotifTitle *string `json:"notificationTitle"`
EvalSlack *string `json:"evaluationSlackDuration"`
AlarmSummary *string `json:"alarmSummary"`
Name string `json:"displayName"`
Compartment string `json:"compartmentId"`
MetricComp string `json:"metricCompartmentId"`
Namespace string `json:"namespace"`
Query string `json:"query"`
Severity string `json:"severity"`
Destinations []string `json:"destinations"`
Overrides []json.RawMessage `json:"overrides"`
}
CreateAlarmIn is the CreateAlarm request body.
type DatapointIn ¶
type DatapointIn struct {
Timestamp *time.Time `json:"timestamp"`
Value *float64 `json:"value"`
Count *int `json:"count,omitempty"`
}
DatapointIn is one posted datapoint.
type FailedMetric ¶
type FailedMetric struct {
Message string `json:"message"`
MetricData MetricDataIn `json:"metricData"`
}
FailedMetric describes a rejected metric stream.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
Port int
EnforceAuth bool
// contains filtered or unexported fields
}
Handler serves OCI Monitoring: alarms, metric ingestion and metric queries.
func NewHandler ¶
func NewHandler(backend *InMemoryBackend) *Handler
NewHandler creates a Handler; callers override Port and EnforceAuth from Settings.
func (*Handler) ExtractOperation ¶
ExtractOperation returns the operation name for metrics.
func (*Handler) ExtractResource ¶
ExtractResource returns the addressed resource id for metrics.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists the supported operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler for all OCIMonitoring requests.
func (*Handler) MatchPriority ¶
MatchPriority is irrelevant because RouteMatcher never matches.
func (*Handler) RouteMatcher ¶
RouteMatcher never matches: OCIMonitoring runs on its own listener.
func (*Handler) Snapshot ¶
Snapshot implements persistence.Persistable by delegating to the backend.
func (*Handler) StartWorker ¶
StartWorker binds the dedicated listener synchronously so a port conflict is returned to the caller.
func (*Handler) Trusted ¶
func (h *Handler) Trusted() echo.HandlerFunc
Trusted returns a handler that skips request-signature verification, for the in-process dashboard proxy.
type HistoryEntry ¶
type HistoryEntry struct {
Timestamp time.Time `json:"timestamp"`
TimestampTriggered time.Time `json:"timestampTriggered"`
From string `json:"from,omitempty"`
To string `json:"to"`
Summary string `json:"summary"`
}
HistoryEntry records one alarm state change.
type HistoryFilter ¶
HistoryFilter narrows GetAlarmHistory.
type InMemoryBackend ¶
InMemoryBackend holds every metric stream and alarm under one lock.
func NewInMemoryBackend ¶
func NewInMemoryBackend() *InMemoryBackend
NewInMemoryBackend creates an empty backend.
func (*InMemoryBackend) ChangeAlarmCompartment ¶
func (b *InMemoryBackend) ChangeAlarmCompartment(id, ifMatch, compartment string) error
ChangeAlarmCompartment moves an alarm to another compartment.
func (*InMemoryBackend) Compartments ¶
func (b *InMemoryBackend) Compartments() []string
Compartments lists the distinct compartments that hold alarms or metric streams.
func (*InMemoryBackend) CreateAlarm ¶
func (b *InMemoryBackend) CreateAlarm(in CreateAlarmIn) (AlarmWire, string, error)
CreateAlarm validates and stores an alarm; it starts OK.
func (*InMemoryBackend) DeleteAlarm ¶
func (b *InMemoryBackend) DeleteAlarm(id, ifMatch string) error
DeleteAlarm removes an alarm.
func (*InMemoryBackend) GetAlarm ¶
func (b *InMemoryBackend) GetAlarm(id string) (AlarmWire, string, error)
GetAlarm returns one alarm and its etag.
func (*InMemoryBackend) GetAlarmHistory ¶
func (b *InMemoryBackend) GetAlarmHistory(id string, f HistoryFilter, o ListOpts) (AlarmHistoryWire, string, error)
func (*InMemoryBackend) ListAlarms ¶
func (b *InMemoryBackend) ListAlarms(f AlarmFilter, o ListOpts) (page.Page[AlarmSummaryWire], error)
ListAlarms lists the alarms of a compartment.
func (*InMemoryBackend) ListAlarmsStatus ¶
func (b *InMemoryBackend) ListAlarmsStatus(f AlarmFilter, o ListOpts) (page.Page[AlarmStatusWire], error)
ListAlarmsStatus lists the evaluation status of the alarms of a compartment.
func (*InMemoryBackend) ListMetrics ¶
func (b *InMemoryBackend) ListMetrics( compartment string, in ListMetricsIn, pageToken string, limit int, ) (page.Page[MetricWire], error)
ListMetrics lists the metric definitions of a compartment.
func (*InMemoryBackend) PostMetricData ¶
func (b *InMemoryBackend) PostMetricData(in PostMetricDataIn) (PostMetricDataOut, error)
PostMetricData stores the datapoints of every valid stream.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads backend state from a snapshot.
func (*InMemoryBackend) SetClock ¶
func (b *InMemoryBackend) SetClock(now func() time.Time)
SetClock injects the time source used for datapoint validation, evaluation and retention.
func (*InMemoryBackend) SetPublisher ¶
func (b *InMemoryBackend) SetPublisher(p Publisher)
SetPublisher wires alarm notification delivery to a Notifications backend.
func (*InMemoryBackend) SetTopicChecker ¶
func (b *InMemoryBackend) SetTopicChecker(c TopicChecker)
SetTopicChecker wires validation of alarm destinations against a Notifications backend.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises the backend state, including registered API keys.
func (*InMemoryBackend) SummarizeMetricsData ¶
func (b *InMemoryBackend) SummarizeMetricsData(compartment string, in SummarizeIn) ([]MetricDataWire, error)
SummarizeMetricsData aggregates stored datapoints with the MQL statistic of the query.
func (*InMemoryBackend) Sweep ¶
func (b *InMemoryBackend) Sweep(ctx context.Context)
Sweep drops datapoints past retention, then evaluates every alarm and delivers the notifications it raised.
func (*InMemoryBackend) UpdateAlarm ¶
func (b *InMemoryBackend) UpdateAlarm(id, ifMatch string, in UpdateAlarmIn) (AlarmWire, string, error)
UpdateAlarm changes the supplied fields of an alarm.
type ListMetricsIn ¶
type ListMetricsIn struct {
DimensionFilters map[string]string `json:"dimensionFilters"`
Name *string `json:"name"`
Namespace *string `json:"namespace"`
ResourceGroup *string `json:"resourceGroup"`
SortBy string `json:"sortBy"`
SortOrder string `json:"sortOrder"`
GroupBy []string `json:"groupBy"`
}
ListMetricsIn is the ListMetrics request body.
type MQL ¶
type MQL struct {
Pred *predicate
Metric string
Stat string
Filters []dimFilter
GroupBy []string
Interval time.Duration
Quantile float64
Grouped bool
}
MQL is a parsed Monitoring Query Language expression.
type MetricDataIn ¶
type MetricDataIn struct {
Dimensions map[string]string `json:"dimensions"`
Metadata map[string]string `json:"metadata,omitempty"`
ResourceGroup *string `json:"resourceGroup,omitempty"`
Namespace string `json:"namespace"`
CompartmentID string `json:"compartmentId"`
Name string `json:"name"`
Datapoints []DatapointIn `json:"datapoints"`
}
MetricDataIn is one posted metric stream.
type MetricDataWire ¶
type MetricDataWire struct {
Dimensions map[string]string `json:"dimensions"`
Metadata map[string]string `json:"metadata,omitempty"`
Namespace string `json:"namespace"`
CompartmentID string `json:"compartmentId"`
Name string `json:"name"`
ResourceGroup string `json:"resourceGroup,omitempty"`
Resolution string `json:"resolution"`
AggregatedDatapoints []aggregatedWire `json:"aggregatedDatapoints"`
}
MetricDataWire is one aggregated series of a SummarizeMetricsData response.
type MetricWire ¶
type MetricWire struct {
Dimensions map[string]string `json:"dimensions,omitempty"`
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
ResourceGroup string `json:"resourceGroup,omitempty"`
CompartmentID string `json:"compartmentId"`
}
MetricWire is one ListMetrics item.
type PostMetricDataIn ¶
type PostMetricDataIn struct {
BatchAtomicity string `json:"batchAtomicity"`
MetricData []MetricDataIn `json:"metricData"`
}
PostMetricDataIn is the PostMetricData request body.
type PostMetricDataOut ¶
type PostMetricDataOut struct {
FailedMetrics []FailedMetric `json:"failedMetrics,omitempty"`
FailedMetricsCount int `json:"failedMetricsCount"`
}
PostMetricDataOut is the PostMetricData response body.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for OCI Monitoring. It runs on its own listener (see Handler.StartWorker) and never matches on the shared AWS router.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init creates the backend and handler; the port is bound in StartWorker.
type Settings ¶
type Settings struct {
Port int `` //nolint:lll // config struct tags are intentionally verbose
/* 234-byte string literal not displayed */
EnforceAuth bool `` //nolint:lll // config struct tags are intentionally verbose
/* 226-byte string literal not displayed */
}
Settings holds service-level configuration, embedded in the root CLI as CLI.OCIMonitoring.
func DefaultSettings ¶
func DefaultSettings() Settings
DefaultSettings returns the settings used when no ConfigProvider is available.
type Stream ¶
type Stream struct {
Dimensions map[string]string `json:"dimensions"`
Metadata map[string]string `json:"metadata,omitempty"`
Namespace string `json:"namespace"`
CompartmentID string `json:"compartmentId"`
Name string `json:"name"`
ResourceGroup string `json:"resourceGroup,omitempty"`
Points []Point `json:"points"`
}
Stream is a unique metric stream: namespace, compartment, name, resource group and dimensions.
type SummarizeIn ¶
type SummarizeIn struct {
StartTime *time.Time `json:"startTime"`
EndTime *time.Time `json:"endTime"`
ResourceGroup *string `json:"resourceGroup"`
Namespace string `json:"namespace"`
Query string `json:"query"`
Resolution string `json:"resolution"`
}
SummarizeIn is the SummarizeMetricsData request body.
type SuppressionSpec ¶
type SuppressionSpec struct {
From time.Time `json:"timeSuppressFrom"`
Until time.Time `json:"timeSuppressUntil"`
Description string `json:"description,omitempty"`
}
SuppressionSpec is the alarm suppression window.
type SuppressionWire ¶
type SuppressionWire struct {
TimeSuppressFrom time.Time `json:"timeSuppressFrom"`
TimeSuppressUntil time.Time `json:"timeSuppressUntil"`
Description string `json:"description,omitempty"`
}
SuppressionWire is the alarm suppression window.
type Tags ¶
type Tags struct {
FreeformTags map[string]string `json:"freeformTags,omitempty"`
DefinedTags map[string]map[string]any `json:"definedTags,omitempty"`
}
Tags are the shared freeform and defined tag sets of a resource.
type TopicChecker ¶
TopicChecker reports whether a Notifications topic exists.
type UpdateAlarmIn ¶
type UpdateAlarmIn struct {
Tags
Name *string `json:"displayName"`
Compartment *string `json:"compartmentId"`
MetricComp *string `json:"metricCompartmentId"`
InSubtree *bool `json:"metricCompartmentIdInSubtree"`
Namespace *string `json:"namespace"`
ResourceGroup *string `json:"resourceGroup"`
Query *string `json:"query"`
Resolution *string `json:"resolution"`
Pending *string `json:"pendingDuration"`
Severity *string `json:"severity"`
Body *string `json:"body"`
PerDimension *bool `json:"isNotificationsPerMetricDimensionEnabled"`
MessageFormat *string `json:"messageFormat"`
Destinations []string `json:"destinations"`
Repeat *string `json:"repeatNotificationDuration"`
Suppression *SuppressionWire `json:"suppression"`
Enabled *bool `json:"isEnabled"`
RuleName *string `json:"ruleName"`
NotifVersion *string `json:"notificationVersion"`
NotifTitle *string `json:"notificationTitle"`
EvalSlack *string `json:"evaluationSlackDuration"`
AlarmSummary *string `json:"alarmSummary"`
Overrides []json.RawMessage `json:"overrides"`
}
UpdateAlarmIn is the UpdateAlarm request body.