Help us shape the future of Go! Take the 2026 Go Developer Survey

ocimonitoring

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 29 Imported by: 0

README

OCI Monitoring

Parity grade: B · SDK github.com/oracle/oci-go-sdk/v65@v65.126.2 · last audited 2026-10-29 (ee4983645)

Coverage

Metric Value
PARITY entries audited 11 (8 ok, 3 partial)
Feature families 8 (6 ok, 2 partial)
Known gaps 9
Deferred items 0
Resource leaks unknown
Known gaps
  • Alarm suppressions (CreateAlarmSuppression, GetAlarmSuppression, ListAlarmSuppressions, DeleteAlarmSuppression, RemoveAlarmSuppression, SummarizeAlarmSuppressionHistory) and RetrieveDimensionStates are not routed; only the suppression property on the alarm itself is honoured.
  • Alarm evaluation is per alarm, not per metric stream: isNotificationsPerMetricDimensionEnabled is stored but notifications are always grouped, and alarm overrides, ruleName rules and evaluationSlackDuration are stored but not evaluated.
  • Alarm notifications to Streaming destinations are accepted but not delivered; only Notifications topics receive them.
  • MQL lacks grouping(), joins, arithmetic and nested queries; see families.mql. Metrics emitted by other OCI services (oci_computeagent and so on) do not exist, only posted custom metrics.
  • compartmentIdInSubtree and metricCompartmentIdInSubtree are ignored (the emulator has no compartment tree); metrics and alarms match the exact compartment.
  • The datapoint timestamp window, the 50 stream limit, the dimension and name rules, the 90 day retention and the pendingDuration and repeat limits are recalled from the Oracle documentation and SDK comments, not verified against the live service; the notification JSON layout follows the documented alarm message format only approximately.
  • Datapoints are held in memory and in snapshots, so heavy ingestion grows the snapshot; there is no per-stream cap.
  • opc-retry-token idempotency, content-encoding gzip request bodies, IAM policy checks, resource principals and instance principals are not applied; only API-key signatures are verified.
  • Tag values and defined-tag namespaces are stored verbatim, not validated against a tag namespace; systemTags are never set.

More

Documentation

Index

Constants

View Source
const DefaultPort = 8161

DefaultPort is the dedicated listener's default TCP port.

View Source
const (
	// Region is the fixed region baked into emulated OCIDs.
	Region = "us-ashburn-1"
)

Variables

View Source
var ErrNilAppContext = errors.New("ocimonitoring: nil app context")

ErrNilAppContext is returned when Init is called with a nil AppContext.

View Source
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

type APIError struct {
	Code    string
	Message string
	Status  int
}

APIError is an OCI error response: HTTP status plus the `code` and `message` body fields.

func (*APIError) Error

func (e *APIError) Error() string

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

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation returns the operation name for metrics.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource returns the addressed resource id for metrics.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

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

func (h *Handler) MatchPriority() int

MatchPriority is irrelevant because RouteMatcher never matches.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all in-memory state.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher never matches: OCIMonitoring runs on its own listener.

func (*Handler) Shutdown

func (h *Handler) Shutdown(ctx context.Context)

Shutdown stops the listener and the sweeper.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

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

type HistoryFilter struct {
	From, To *time.Time
	Type     string
}

HistoryFilter narrows GetAlarmHistory.

type InMemoryBackend

type InMemoryBackend struct {
	Auth *ociauth.Registry
	// contains filtered or unexported fields
}

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

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) Reset

func (b *InMemoryBackend) Reset()

Reset clears all state.

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 ListOpts

type ListOpts struct {
	SortBy string
	Order  string
	Page   string
	Limit  int
}

ListOpts carries the shared list query parameters.

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.

func ParseMQL

func ParseMQL(src string) (*MQL, error)

ParseMQL parses `Metric[interval]{filters}.groupBy(dims).stat() [predicate]`.

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 Point

type Point struct {
	T time.Time `json:"t"`
	V float64   `json:"v"`
	N int       `json:"n"`
}

Point is one stored datapoint.

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

Init creates the backend and handler; the port is bound in StartWorker.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the service provider name.

type Publisher

type Publisher func(ctx context.Context, topicID, title, body string, asJSON bool) error

Publisher delivers an alarm notification to a Notifications topic.

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

type TopicChecker func(topicID string) bool

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.

Jump to

Keyboard shortcuts

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