Documentation
¶
Index ¶
- Constants
- Variables
- func IsPrometheusPath(path string) bool
- type API
- type ConfigProvider
- type Delivery
- type Handler
- func (h *Handler) API() *API
- func (h *Handler) Addr() string
- func (h *Handler) ExtractOperation(*echo.Context) string
- func (h *Handler) ExtractResource(*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
- type InMemoryBackend
- func (b *InMemoryBackend) CreateAlertPolicy(req *monitoringpb.CreateAlertPolicyRequest) (*monitoringpb.AlertPolicy, error)
- func (b *InMemoryBackend) CreateGroup(req *monitoringpb.CreateGroupRequest) (*monitoringpb.Group, error)
- func (b *InMemoryBackend) CreateMetricDescriptor(req *monitoringpb.CreateMetricDescriptorRequest) (*metricpb.MetricDescriptor, error)
- func (b *InMemoryBackend) CreateNotificationChannel(req *monitoringpb.CreateNotificationChannelRequest) (*monitoringpb.NotificationChannel, error)
- func (b *InMemoryBackend) CreateService(req *monitoringpb.CreateServiceRequest) (*monitoringpb.Service, error)
- func (b *InMemoryBackend) CreateServiceLevelObjective(req *monitoringpb.CreateServiceLevelObjectiveRequest) (*monitoringpb.ServiceLevelObjective, error)
- func (b *InMemoryBackend) CreateServiceTimeSeries(req *monitoringpb.CreateTimeSeriesRequest) error
- func (b *InMemoryBackend) CreateSnooze(req *monitoringpb.CreateSnoozeRequest) (*monitoringpb.Snooze, error)
- func (b *InMemoryBackend) CreateTimeSeries(req *monitoringpb.CreateTimeSeriesRequest) error
- func (b *InMemoryBackend) CreateUptimeCheckConfig(req *monitoringpb.CreateUptimeCheckConfigRequest) (*monitoringpb.UptimeCheckConfig, error)
- func (b *InMemoryBackend) DeleteAlertPolicy(name string) error
- func (b *InMemoryBackend) DeleteGroup(req *monitoringpb.DeleteGroupRequest) error
- func (b *InMemoryBackend) DeleteMetricDescriptor(name string) error
- func (b *InMemoryBackend) DeleteNotificationChannel(req *monitoringpb.DeleteNotificationChannelRequest) error
- func (b *InMemoryBackend) DeleteService(name string) error
- func (b *InMemoryBackend) DeleteServiceLevelObjective(name string) error
- func (b *InMemoryBackend) DeleteUptimeCheckConfig(name string) error
- func (b *InMemoryBackend) Deliveries() []Delivery
- func (b *InMemoryBackend) GetAlertPolicy(name string) (*monitoringpb.AlertPolicy, error)
- func (b *InMemoryBackend) GetGroup(name string) (*monitoringpb.Group, error)
- func (b *InMemoryBackend) GetMetricDescriptor(name string) (*metricpb.MetricDescriptor, error)
- func (b *InMemoryBackend) GetMonitoredResourceDescriptor(name string) (*monitoredres.MonitoredResourceDescriptor, error)
- func (b *InMemoryBackend) GetNotificationChannel(name string) (*monitoringpb.NotificationChannel, error)
- func (b *InMemoryBackend) GetNotificationChannelDescriptor(name string) (*monitoringpb.NotificationChannelDescriptor, error)
- func (b *InMemoryBackend) GetNotificationChannelVerificationCode(req *monitoringpb.GetNotificationChannelVerificationCodeRequest) (*monitoringpb.GetNotificationChannelVerificationCodeResponse, error)
- func (b *InMemoryBackend) GetService(name string) (*monitoringpb.Service, error)
- func (b *InMemoryBackend) GetServiceLevelObjective(name string) (*monitoringpb.ServiceLevelObjective, error)
- func (b *InMemoryBackend) GetSnooze(name string) (*monitoringpb.Snooze, error)
- func (b *InMemoryBackend) GetUptimeCheckConfig(name string) (*monitoringpb.UptimeCheckConfig, error)
- func (b *InMemoryBackend) Incidents(project string) []Incident
- func (b *InMemoryBackend) ListAlertPolicies(req *monitoringpb.ListAlertPoliciesRequest) ([]*monitoringpb.AlertPolicy, string, int32, error)
- func (b *InMemoryBackend) ListGroupMembers(req *monitoringpb.ListGroupMembersRequest) ([]*monitoredres.MonitoredResource, string, int32, error)
- func (b *InMemoryBackend) ListGroups(req *monitoringpb.ListGroupsRequest) ([]*monitoringpb.Group, string, error)
- func (b *InMemoryBackend) ListMetricDescriptors(req *monitoringpb.ListMetricDescriptorsRequest) ([]*metricpb.MetricDescriptor, string, error)
- func (b *InMemoryBackend) ListMonitoredResourceDescriptors(req *monitoringpb.ListMonitoredResourceDescriptorsRequest) ([]*monitoredres.MonitoredResourceDescriptor, string, error)
- func (b *InMemoryBackend) ListNotificationChannelDescriptors(req *monitoringpb.ListNotificationChannelDescriptorsRequest) ([]*monitoringpb.NotificationChannelDescriptor, string, error)
- func (b *InMemoryBackend) ListNotificationChannels(req *monitoringpb.ListNotificationChannelsRequest) ([]*monitoringpb.NotificationChannel, string, int32, error)
- func (b *InMemoryBackend) ListServiceLevelObjectives(req *monitoringpb.ListServiceLevelObjectivesRequest) ([]*monitoringpb.ServiceLevelObjective, string, error)
- func (b *InMemoryBackend) ListServices(req *monitoringpb.ListServicesRequest) ([]*monitoringpb.Service, string, error)
- func (b *InMemoryBackend) ListSnoozes(req *monitoringpb.ListSnoozesRequest) ([]*monitoringpb.Snooze, string, error)
- func (b *InMemoryBackend) ListTimeSeries(req *monitoringpb.ListTimeSeriesRequest) (*monitoringpb.ListTimeSeriesResponse, error)
- func (b *InMemoryBackend) ListUptimeCheckConfigs(req *monitoringpb.ListUptimeCheckConfigsRequest) ([]*monitoringpb.UptimeCheckConfig, string, int32, error)
- func (b *InMemoryBackend) ListUptimeCheckIps() []*monitoringpb.UptimeCheckIp
- func (b *InMemoryBackend) PrometheusHandler() http.Handler
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) RunLoop(ctx context.Context, interval time.Duration)
- func (b *InMemoryBackend) SendNotificationChannelVerificationCode(name string) error
- func (b *InMemoryBackend) SetClock(now func() time.Time)
- func (b *InMemoryBackend) SetLogMetricSource(s LogMetricSource)
- func (b *InMemoryBackend) SetPublisher(p Publisher)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) Tick(ctx context.Context)
- func (b *InMemoryBackend) UpdateAlertPolicy(req *monitoringpb.UpdateAlertPolicyRequest) (*monitoringpb.AlertPolicy, error)
- func (b *InMemoryBackend) UpdateGroup(req *monitoringpb.UpdateGroupRequest) (*monitoringpb.Group, error)
- func (b *InMemoryBackend) UpdateNotificationChannel(req *monitoringpb.UpdateNotificationChannelRequest) (*monitoringpb.NotificationChannel, error)
- func (b *InMemoryBackend) UpdateService(req *monitoringpb.UpdateServiceRequest) (*monitoringpb.Service, error)
- func (b *InMemoryBackend) UpdateServiceLevelObjective(req *monitoringpb.UpdateServiceLevelObjectiveRequest) (*monitoringpb.ServiceLevelObjective, error)
- func (b *InMemoryBackend) UpdateSnooze(req *monitoringpb.UpdateSnoozeRequest) (*monitoringpb.Snooze, error)
- func (b *InMemoryBackend) UpdateUptimeCheckConfig(req *monitoringpb.UpdateUptimeCheckConfigRequest) (*monitoringpb.UptimeCheckConfig, error)
- func (b *InMemoryBackend) VerifyNotificationChannel(req *monitoringpb.VerifyNotificationChannelRequest) (*monitoringpb.NotificationChannel, error)
- type Incident
- type LogMetric
- type LogMetricSeries
- type LogMetricSource
- type Provider
- type Publisher
- type Settings
Constants ¶
const ( // DefaultEvalInterval is how often alert policies and uptime checks are evaluated. DefaultEvalInterval = 5 * time.Second )
const DefaultPort = 8132
DefaultPort is the dedicated gRPC listener's default TCP port.
Variables ¶
var ErrNilAppContext = errors.New("gcpmonitoring: nil app context")
ErrNilAppContext is returned when Init is called with a nil AppContext.
Functions ¶
func IsPrometheusPath ¶
IsPrometheusPath reports whether the URL path addresses the Prometheus-compatible query API.
Types ¶
type API ¶
type API struct {
Metrics monitoringpb.MetricServiceServer
Alerts monitoringpb.AlertPolicyServiceServer
Uptime monitoringpb.UptimeCheckServiceServer
Snoozes monitoringpb.SnoozeServiceServer
Channels monitoringpb.NotificationChannelServiceServer
}
API groups the Monitoring services for in-process callers (dashboard proxy).
type ConfigProvider ¶
type ConfigProvider interface {
GetGCPMonitoringSettings() Settings
}
ConfigProvider extracts Cloud Monitoring configuration from the AppContext Config.
type Delivery ¶
type Delivery struct {
At time.Time `json:"at"`
IncidentID string `json:"incidentId"`
Channel string `json:"channel"`
Type string `json:"type"`
State string `json:"state"`
Result string `json:"result"`
Error string `json:"error,omitempty"`
}
Delivery records the outcome of one notification attempt.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
// EvalInterval is the alert and uptime tick; zero disables the background loop.
EvalInterval time.Duration
Port int
// contains filtered or unexported fields
}
Handler serves the Cloud Monitoring gRPC API (and its REST transcoding) on a dedicated listener.
func NewHandler ¶
func NewHandler(backend *InMemoryBackend) *Handler
NewHandler creates a Handler; callers override Port from Settings.
func (*Handler) API ¶
API exposes the metric, alert policy, uptime check, snooze and notification channel services.
func (*Handler) ExtractOperation ¶
ExtractOperation is unused: requests never reach the shared router.
func (*Handler) ExtractResource ¶
ExtractResource is unused: requests never reach the shared router.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists the supported gRPC methods.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns a 404 handler; the real API is on the dedicated port.
func (*Handler) MatchPriority ¶
MatchPriority is irrelevant because RouteMatcher never matches.
func (*Handler) RouteMatcher ¶
RouteMatcher never matches: Cloud Monitoring runs on its own listener.
func (*Handler) Shutdown ¶
Shutdown stops the gRPC server, forcing a close after a short grace period.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend holds all Cloud Monitoring state under one lock.
func NewInMemoryBackend ¶
func NewInMemoryBackend() *InMemoryBackend
NewInMemoryBackend creates an empty backend.
func (*InMemoryBackend) CreateAlertPolicy ¶
func (b *InMemoryBackend) CreateAlertPolicy( req *monitoringpb.CreateAlertPolicyRequest, ) (*monitoringpb.AlertPolicy, error)
CreateAlertPolicy stores a policy and names its conditions.
func (*InMemoryBackend) CreateGroup ¶
func (b *InMemoryBackend) CreateGroup(req *monitoringpb.CreateGroupRequest) (*monitoringpb.Group, error)
CreateGroup stores a group.
func (*InMemoryBackend) CreateMetricDescriptor ¶
func (b *InMemoryBackend) CreateMetricDescriptor( req *monitoringpb.CreateMetricDescriptorRequest, ) (*metricpb.MetricDescriptor, error)
CreateMetricDescriptor stores a custom metric descriptor; an identical re-create returns the existing one.
func (*InMemoryBackend) CreateNotificationChannel ¶
func (b *InMemoryBackend) CreateNotificationChannel( req *monitoringpb.CreateNotificationChannelRequest, ) (*monitoringpb.NotificationChannel, error)
CreateNotificationChannel stores a channel; email and SMS channels start unverified.
func (*InMemoryBackend) CreateService ¶
func (b *InMemoryBackend) CreateService(req *monitoringpb.CreateServiceRequest) (*monitoringpb.Service, error)
CreateService stores a service under the given or a generated id.
func (*InMemoryBackend) CreateServiceLevelObjective ¶
func (b *InMemoryBackend) CreateServiceLevelObjective( req *monitoringpb.CreateServiceLevelObjectiveRequest, ) (*monitoringpb.ServiceLevelObjective, error)
CreateServiceLevelObjective stores an objective under an existing service.
func (*InMemoryBackend) CreateServiceTimeSeries ¶
func (b *InMemoryBackend) CreateServiceTimeSeries(req *monitoringpb.CreateTimeSeriesRequest) error
CreateServiceTimeSeries writes to built-in service metrics as well as custom ones.
func (*InMemoryBackend) CreateSnooze ¶
func (b *InMemoryBackend) CreateSnooze(req *monitoringpb.CreateSnoozeRequest) (*monitoringpb.Snooze, error)
CreateSnooze stores a snooze with a generated id.
func (*InMemoryBackend) CreateTimeSeries ¶
func (b *InMemoryBackend) CreateTimeSeries(req *monitoringpb.CreateTimeSeriesRequest) error
CreateTimeSeries writes one point per series as a user; valid series are stored even when others fail.
func (*InMemoryBackend) CreateUptimeCheckConfig ¶
func (b *InMemoryBackend) CreateUptimeCheckConfig( req *monitoringpb.CreateUptimeCheckConfigRequest, ) (*monitoringpb.UptimeCheckConfig, error)
CreateUptimeCheckConfig stores a check; it is probed on the next Tick.
func (*InMemoryBackend) DeleteAlertPolicy ¶
func (b *InMemoryBackend) DeleteAlertPolicy(name string) error
DeleteAlertPolicy removes a policy; its open incidents close on the next evaluation.
func (*InMemoryBackend) DeleteGroup ¶
func (b *InMemoryBackend) DeleteGroup(req *monitoringpb.DeleteGroupRequest) error
DeleteGroup removes a group, and with recursive its descendants.
func (*InMemoryBackend) DeleteMetricDescriptor ¶
func (b *InMemoryBackend) DeleteMetricDescriptor(name string) error
DeleteMetricDescriptor removes a custom descriptor and the series written with it.
func (*InMemoryBackend) DeleteNotificationChannel ¶
func (b *InMemoryBackend) DeleteNotificationChannel(req *monitoringpb.DeleteNotificationChannelRequest) error
DeleteNotificationChannel removes a channel; policies that use it block deletion unless forced.
func (*InMemoryBackend) DeleteService ¶
func (b *InMemoryBackend) DeleteService(name string) error
DeleteService removes a service and its service level objectives.
func (*InMemoryBackend) DeleteServiceLevelObjective ¶
func (b *InMemoryBackend) DeleteServiceLevelObjective(name string) error
DeleteServiceLevelObjective removes an objective.
func (*InMemoryBackend) DeleteUptimeCheckConfig ¶
func (b *InMemoryBackend) DeleteUptimeCheckConfig(name string) error
DeleteUptimeCheckConfig removes a check.
func (*InMemoryBackend) Deliveries ¶
func (b *InMemoryBackend) Deliveries() []Delivery
Deliveries returns the most recent notification attempts, oldest first.
func (*InMemoryBackend) GetAlertPolicy ¶
func (b *InMemoryBackend) GetAlertPolicy(name string) (*monitoringpb.AlertPolicy, error)
GetAlertPolicy returns one policy.
func (*InMemoryBackend) GetGroup ¶
func (b *InMemoryBackend) GetGroup(name string) (*monitoringpb.Group, error)
GetGroup returns one group.
func (*InMemoryBackend) GetMetricDescriptor ¶
func (b *InMemoryBackend) GetMetricDescriptor(name string) (*metricpb.MetricDescriptor, error)
GetMetricDescriptor returns a custom, built-in or log-based descriptor.
func (*InMemoryBackend) GetMonitoredResourceDescriptor ¶
func (b *InMemoryBackend) GetMonitoredResourceDescriptor( name string, ) (*monitoredres.MonitoredResourceDescriptor, error)
GetMonitoredResourceDescriptor returns one catalog entry.
func (*InMemoryBackend) GetNotificationChannel ¶
func (b *InMemoryBackend) GetNotificationChannel(name string) (*monitoringpb.NotificationChannel, error)
GetNotificationChannel returns one channel without its sensitive labels.
func (*InMemoryBackend) GetNotificationChannelDescriptor ¶
func (b *InMemoryBackend) GetNotificationChannelDescriptor( name string, ) (*monitoringpb.NotificationChannelDescriptor, error)
GetNotificationChannelDescriptor returns one channel type.
func (*InMemoryBackend) GetNotificationChannelVerificationCode ¶
func (b *InMemoryBackend) GetNotificationChannelVerificationCode( req *monitoringpb.GetNotificationChannelVerificationCodeRequest, ) (*monitoringpb.GetNotificationChannelVerificationCodeResponse, error)
GetNotificationChannelVerificationCode returns a fresh code for a channel and when it expires.
func (*InMemoryBackend) GetService ¶
func (b *InMemoryBackend) GetService(name string) (*monitoringpb.Service, error)
GetService returns one service.
func (*InMemoryBackend) GetServiceLevelObjective ¶
func (b *InMemoryBackend) GetServiceLevelObjective(name string) (*monitoringpb.ServiceLevelObjective, error)
GetServiceLevelObjective returns one objective.
func (*InMemoryBackend) GetSnooze ¶
func (b *InMemoryBackend) GetSnooze(name string) (*monitoringpb.Snooze, error)
GetSnooze returns one snooze.
func (*InMemoryBackend) GetUptimeCheckConfig ¶
func (b *InMemoryBackend) GetUptimeCheckConfig(name string) (*monitoringpb.UptimeCheckConfig, error)
GetUptimeCheckConfig returns one check.
func (*InMemoryBackend) Incidents ¶
func (b *InMemoryBackend) Incidents(project string) []Incident
Incidents returns the project's incidents, oldest first; open ones have a zero EndedAt.
func (*InMemoryBackend) ListAlertPolicies ¶
func (b *InMemoryBackend) ListAlertPolicies( req *monitoringpb.ListAlertPoliciesRequest, ) ([]*monitoringpb.AlertPolicy, string, int32, error)
ListAlertPolicies pages the project's policies ordered by name, or by display_name when requested.
func (*InMemoryBackend) ListGroupMembers ¶
func (b *InMemoryBackend) ListGroupMembers( req *monitoringpb.ListGroupMembersRequest, ) ([]*monitoredres.MonitoredResource, string, int32, error)
ListGroupMembers returns the distinct monitored resources that match the group's filter.
func (*InMemoryBackend) ListGroups ¶
func (b *InMemoryBackend) ListGroups(req *monitoringpb.ListGroupsRequest) ([]*monitoringpb.Group, string, error)
ListGroups pages the project's groups, optionally restricted to a group's children, ancestors or descendants.
func (*InMemoryBackend) ListMetricDescriptors ¶
func (b *InMemoryBackend) ListMetricDescriptors( req *monitoringpb.ListMetricDescriptorsRequest, ) ([]*metricpb.MetricDescriptor, string, error)
ListMetricDescriptors pages every descriptor of the project, narrowed by a metric.type filter.
func (*InMemoryBackend) ListMonitoredResourceDescriptors ¶
func (b *InMemoryBackend) ListMonitoredResourceDescriptors( req *monitoringpb.ListMonitoredResourceDescriptorsRequest, ) ([]*monitoredres.MonitoredResourceDescriptor, string, error)
ListMonitoredResourceDescriptors pages the static catalog, narrowed by a resource.type filter.
func (*InMemoryBackend) ListNotificationChannelDescriptors ¶
func (b *InMemoryBackend) ListNotificationChannelDescriptors( req *monitoringpb.ListNotificationChannelDescriptorsRequest, ) ([]*monitoringpb.NotificationChannelDescriptor, string, error)
ListNotificationChannelDescriptors pages the supported channel types.
func (*InMemoryBackend) ListNotificationChannels ¶
func (b *InMemoryBackend) ListNotificationChannels( req *monitoringpb.ListNotificationChannelsRequest, ) ([]*monitoringpb.NotificationChannel, string, int32, error)
ListNotificationChannels pages the project's channels ordered by name.
func (*InMemoryBackend) ListServiceLevelObjectives ¶
func (b *InMemoryBackend) ListServiceLevelObjectives( req *monitoringpb.ListServiceLevelObjectivesRequest, ) ([]*monitoringpb.ServiceLevelObjective, string, error)
ListServiceLevelObjectives pages the objectives of a service, or of every service of the project for "-".
func (*InMemoryBackend) ListServices ¶
func (b *InMemoryBackend) ListServices(req *monitoringpb.ListServicesRequest) ([]*monitoringpb.Service, string, error)
ListServices pages the project's services ordered by name.
func (*InMemoryBackend) ListSnoozes ¶
func (b *InMemoryBackend) ListSnoozes(req *monitoringpb.ListSnoozesRequest) ([]*monitoringpb.Snooze, string, error)
ListSnoozes pages the project's snoozes ordered by name.
func (*InMemoryBackend) ListTimeSeries ¶
func (b *InMemoryBackend) ListTimeSeries( req *monitoringpb.ListTimeSeriesRequest, ) (*monitoringpb.ListTimeSeriesResponse, error)
ListTimeSeries returns the series matching the filter with aggregation applied, newest point first.
func (*InMemoryBackend) ListUptimeCheckConfigs ¶
func (b *InMemoryBackend) ListUptimeCheckConfigs( req *monitoringpb.ListUptimeCheckConfigsRequest, ) ([]*monitoringpb.UptimeCheckConfig, string, int32, error)
ListUptimeCheckConfigs pages the project's checks ordered by name.
func (*InMemoryBackend) ListUptimeCheckIps ¶
func (b *InMemoryBackend) ListUptimeCheckIps() []*monitoringpb.UptimeCheckIp
ListUptimeCheckIps lists the checker locations; probes originate from the emulator itself.
func (*InMemoryBackend) PrometheusHandler ¶
func (b *InMemoryBackend) PrometheusHandler() http.Handler
PrometheusHandler serves the Managed Service for Prometheus query API over the stored metrics: /v1/projects/P/location/global/prometheus/api/v1/{query,query_range,series,labels,label/NAME/values,metadata}.
func (*InMemoryBackend) Reset ¶
func (b *InMemoryBackend) Reset()
Reset clears all state; seam wiring is kept.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads backend state from a snapshot.
func (*InMemoryBackend) RunLoop ¶
func (b *InMemoryBackend) RunLoop(ctx context.Context, interval time.Duration)
RunLoop calls Tick every interval until ctx is cancelled.
func (*InMemoryBackend) SendNotificationChannelVerificationCode ¶
func (b *InMemoryBackend) SendNotificationChannelVerificationCode(name string) error
SendNotificationChannelVerificationCode issues a code for an email or SMS channel.
func (*InMemoryBackend) SetClock ¶
func (b *InMemoryBackend) SetClock(now func() time.Time)
SetClock replaces the backend clock; alert evaluation, uptime checks and timestamp validation use it.
func (*InMemoryBackend) SetLogMetricSource ¶
func (b *InMemoryBackend) SetLogMetricSource(s LogMetricSource)
SetLogMetricSource wires log-based metrics from Cloud Logging.
func (*InMemoryBackend) SetPublisher ¶
func (b *InMemoryBackend) SetPublisher(p Publisher)
SetPublisher wires Pub/Sub notification channels.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises descriptors, series, policies, channels, uptime checks, groups and incidents.
func (*InMemoryBackend) Tick ¶
func (b *InMemoryBackend) Tick(ctx context.Context)
Tick runs one round of uptime checks and alert evaluation at the backend clock's current time.
func (*InMemoryBackend) UpdateAlertPolicy ¶
func (b *InMemoryBackend) UpdateAlertPolicy( req *monitoringpb.UpdateAlertPolicyRequest, ) (*monitoringpb.AlertPolicy, error)
UpdateAlertPolicy replaces the fields named in the mask (every mutable field when empty).
func (*InMemoryBackend) UpdateGroup ¶
func (b *InMemoryBackend) UpdateGroup(req *monitoringpb.UpdateGroupRequest) (*monitoringpb.Group, error)
UpdateGroup replaces a group's mutable fields.
func (*InMemoryBackend) UpdateNotificationChannel ¶
func (b *InMemoryBackend) UpdateNotificationChannel( req *monitoringpb.UpdateNotificationChannelRequest, ) (*monitoringpb.NotificationChannel, error)
UpdateNotificationChannel replaces the fields named in the mask (all mutable fields when empty).
func (*InMemoryBackend) UpdateService ¶
func (b *InMemoryBackend) UpdateService(req *monitoringpb.UpdateServiceRequest) (*monitoringpb.Service, error)
UpdateService replaces the mutable fields in the mask: display_name, user_labels and telemetry.
func (*InMemoryBackend) UpdateServiceLevelObjective ¶
func (b *InMemoryBackend) UpdateServiceLevelObjective( req *monitoringpb.UpdateServiceLevelObjectiveRequest, ) (*monitoringpb.ServiceLevelObjective, error)
UpdateServiceLevelObjective replaces the fields in the mask (every mutable field when empty).
func (*InMemoryBackend) UpdateSnooze ¶
func (b *InMemoryBackend) UpdateSnooze(req *monitoringpb.UpdateSnoozeRequest) (*monitoringpb.Snooze, error)
UpdateSnooze changes the display name or interval; an ended snooze is immutable and a started one keeps its start.
func (*InMemoryBackend) UpdateUptimeCheckConfig ¶
func (b *InMemoryBackend) UpdateUptimeCheckConfig( req *monitoringpb.UpdateUptimeCheckConfigRequest, ) (*monitoringpb.UptimeCheckConfig, error)
UpdateUptimeCheckConfig replaces the fields in the mask (the whole config when empty).
func (*InMemoryBackend) VerifyNotificationChannel ¶
func (b *InMemoryBackend) VerifyNotificationChannel( req *monitoringpb.VerifyNotificationChannelRequest, ) (*monitoringpb.NotificationChannel, error)
VerifyNotificationChannel marks a channel verified when the code matches one issued for it or an equivalent channel.
type Incident ¶
type Incident struct {
StartedAt time.Time `json:"startedAt"`
EndedAt time.Time `json:"endedAt"`
MetricLabels map[string]string `json:"metricLabels,omitempty"`
ResourceLabels map[string]string `json:"resourceLabels,omitempty"`
ID string `json:"id"`
Key string `json:"key"`
Project string `json:"project"`
Policy string `json:"policy"`
PolicyDisplayName string `json:"policyDisplayName"`
Condition string `json:"condition"`
ConditionDisplayName string `json:"conditionDisplayName"`
State string `json:"state"`
MetricType string `json:"metricType"`
ResourceType string `json:"resourceType"`
Observed float64 `json:"observed"`
Threshold float64 `json:"threshold"`
}
Incident is one alert firing: it opens when a condition is met and closes when it recovers.
type LogMetric ¶
type LogMetric struct {
CreateTime time.Time
Descriptor *metricpb.MetricDescriptor
Name string
Series []LogMetricSeries
}
LogMetric is a Cloud Logging log-based metric with its accumulated series.
type LogMetricSeries ¶
type LogMetricSeries struct {
Labels map[string]string
BucketOptions *distribution.Distribution_BucketOptions
BucketCounts []int64
Count int64
Sum float64
SumSqDev float64
}
LogMetricSeries is the accumulated value of one label combination of a log-based metric.
type LogMetricSource ¶
LogMetricSource lists the log-based metrics of a project; it is the seam to Cloud Logging.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for Google Cloud Monitoring. It serves gRPC and REST 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 Publisher ¶
Publisher publishes an alert notification to a Pub/Sub topic (projects/P/topics/T).
type Settings ¶
type Settings struct {
Port int `` //nolint:lll // config struct tags are intentionally verbose
/* 188-byte string literal not displayed */
}
Settings holds service-level configuration, embedded in the root CLI command as CLI.GCPMonitoring.
func DefaultSettings ¶
func DefaultSettings() Settings
DefaultSettings returns the settings used when no ConfigProvider is available.
Source Files
¶
- agg_validate.go
- align.go
- channel_types.go
- channels.go
- consts.go
- descriptors.go
- dist.go
- errors.go
- eval.go
- filter.go
- groups.go
- grpc_alert.go
- grpc_group.go
- grpc_metric.go
- handler.go
- incidents.go
- inproc.go
- logmetrics.go
- names.go
- notify.go
- persistence.go
- policies.go
- probe.go
- promql.go
- promql_http.go
- provider.go
- reduce.go
- resources.go
- services.go
- settings.go
- slo.go
- snooze.go
- store.go
- ts_read.go
- ts_write.go
- uptime.go
- value.go