Documentation
¶
Index ¶
- Constants
- Variables
- type ConfigProvider
- type Handler
- 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) CreateBucket(req *loggingpb.CreateBucketRequest) (*loggingpb.LogBucket, error)
- func (b *InMemoryBackend) CreateExclusion(req *loggingpb.CreateExclusionRequest) (*loggingpb.LogExclusion, error)
- func (b *InMemoryBackend) CreateLogMetric(req *loggingpb.CreateLogMetricRequest) (*loggingpb.LogMetric, error)
- func (b *InMemoryBackend) CreateSink(req *loggingpb.CreateSinkRequest) (*loggingpb.LogSink, error)
- func (b *InMemoryBackend) CreateView(req *loggingpb.CreateViewRequest) (*loggingpb.LogView, error)
- func (b *InMemoryBackend) DeleteBucket(name string) error
- func (b *InMemoryBackend) DeleteExclusion(name string) error
- func (b *InMemoryBackend) DeleteLog(logName string) error
- func (b *InMemoryBackend) DeleteLogMetric(name string) error
- func (b *InMemoryBackend) DeleteSink(name string) error
- func (b *InMemoryBackend) DeleteView(name string) error
- func (b *InMemoryBackend) GetBucket(name string) (*loggingpb.LogBucket, error)
- func (b *InMemoryBackend) GetCmekSettings(name string) (*loggingpb.CmekSettings, error)
- func (b *InMemoryBackend) GetExclusion(name string) (*loggingpb.LogExclusion, error)
- func (b *InMemoryBackend) GetLogMetric(name string) (*loggingpb.LogMetric, error)
- func (b *InMemoryBackend) GetSettings(name string) (*loggingpb.Settings, error)
- func (b *InMemoryBackend) GetSink(name string) (*loggingpb.LogSink, error)
- func (b *InMemoryBackend) GetView(name string) (*loggingpb.LogView, error)
- func (b *InMemoryBackend) ListBuckets(req *loggingpb.ListBucketsRequest) ([]*loggingpb.LogBucket, string, error)
- func (b *InMemoryBackend) ListExclusions(req *loggingpb.ListExclusionsRequest) ([]*loggingpb.LogExclusion, string, error)
- func (b *InMemoryBackend) ListLogEntries(req *loggingpb.ListLogEntriesRequest) ([]*loggingpb.LogEntry, string, error)
- func (b *InMemoryBackend) ListLogMetrics(req *loggingpb.ListLogMetricsRequest) ([]*loggingpb.LogMetric, string, error)
- func (b *InMemoryBackend) ListLogs(req *loggingpb.ListLogsRequest) ([]string, string, error)
- func (b *InMemoryBackend) ListMonitoredResourceDescriptors(token string, size int32) ([]*monitoredres.MonitoredResourceDescriptor, string, error)
- func (b *InMemoryBackend) ListSinks(req *loggingpb.ListSinksRequest) ([]*loggingpb.LogSink, string, error)
- func (b *InMemoryBackend) ListViews(req *loggingpb.ListViewsRequest) ([]*loggingpb.LogView, string, error)
- func (b *InMemoryBackend) MetricPoints(name string) ([]MetricPoint, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) SetObjectStore(s ObjectStore)
- func (b *InMemoryBackend) SetPublisher(p Publisher)
- func (b *InMemoryBackend) SetTableStore(s TableStore)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) Tail(stream loggingpb.LoggingServiceV2_TailLogEntriesServer, ...) error
- func (b *InMemoryBackend) UndeleteBucket(name string) error
- func (b *InMemoryBackend) UpdateBucket(req *loggingpb.UpdateBucketRequest) (*loggingpb.LogBucket, error)
- func (b *InMemoryBackend) UpdateCmekSettings(req *loggingpb.UpdateCmekSettingsRequest) (*loggingpb.CmekSettings, error)
- func (b *InMemoryBackend) UpdateExclusion(req *loggingpb.UpdateExclusionRequest) (*loggingpb.LogExclusion, error)
- func (b *InMemoryBackend) UpdateLogMetric(req *loggingpb.UpdateLogMetricRequest) (*loggingpb.LogMetric, error)
- func (b *InMemoryBackend) UpdateSettings(req *loggingpb.UpdateSettingsRequest) (*loggingpb.Settings, error)
- func (b *InMemoryBackend) UpdateSink(req *loggingpb.UpdateSinkRequest) (*loggingpb.LogSink, error)
- func (b *InMemoryBackend) UpdateView(req *loggingpb.UpdateViewRequest) (*loggingpb.LogView, error)
- func (b *InMemoryBackend) WriteLogEntries(ctx context.Context, req *loggingpb.WriteLogEntriesRequest) error
- type MetricPoint
- type ObjectStore
- type Provider
- type Publisher
- type Settings
- type TableStore
Constants ¶
const DefaultPort = 8131
DefaultPort is the dedicated gRPC listener's default TCP port.
Variables ¶
var ErrNilAppContext = errors.New("gcplogging: nil app context")
ErrNilAppContext is returned when Init is called with a nil AppContext.
var ErrObjectNotFound = errors.New("object not found")
ErrObjectNotFound is returned by an ObjectStore when a bucket or object does not exist.
Functions ¶
This section is empty.
Types ¶
type ConfigProvider ¶
type ConfigProvider interface {
GetGCPLoggingSettings() Settings
}
ConfigProvider extracts Cloud Logging configuration from the AppContext Config.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
Port int
// contains filtered or unexported fields
}
Handler serves the Cloud Logging 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) 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 Logging 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 Logging state under one lock.
func NewInMemoryBackend ¶
func NewInMemoryBackend() *InMemoryBackend
NewInMemoryBackend creates an empty backend.
func (*InMemoryBackend) CreateBucket ¶
func (b *InMemoryBackend) CreateBucket(req *loggingpb.CreateBucketRequest) (*loggingpb.LogBucket, error)
CreateBucket adds a user-defined log bucket.
func (*InMemoryBackend) CreateExclusion ¶
func (b *InMemoryBackend) CreateExclusion(req *loggingpb.CreateExclusionRequest) (*loggingpb.LogExclusion, error)
CreateExclusion adds a log exclusion under the parent.
func (*InMemoryBackend) CreateLogMetric ¶
func (b *InMemoryBackend) CreateLogMetric(req *loggingpb.CreateLogMetricRequest) (*loggingpb.LogMetric, error)
CreateLogMetric stores a log-based metric.
func (*InMemoryBackend) CreateSink ¶
func (b *InMemoryBackend) CreateSink(req *loggingpb.CreateSinkRequest) (*loggingpb.LogSink, error)
CreateSink adds a sink under the parent.
func (*InMemoryBackend) CreateView ¶
func (b *InMemoryBackend) CreateView(req *loggingpb.CreateViewRequest) (*loggingpb.LogView, error)
CreateView adds a view to a bucket.
func (*InMemoryBackend) DeleteBucket ¶
func (b *InMemoryBackend) DeleteBucket(name string) error
DeleteBucket marks a bucket DELETE_REQUESTED; it can be undeleted for seven days.
func (*InMemoryBackend) DeleteExclusion ¶
func (b *InMemoryBackend) DeleteExclusion(name string) error
DeleteExclusion removes an exclusion.
func (*InMemoryBackend) DeleteLog ¶
func (b *InMemoryBackend) DeleteLog(logName string) error
DeleteLog removes every entry of the log from all buckets of its parent.
func (*InMemoryBackend) DeleteLogMetric ¶
func (b *InMemoryBackend) DeleteLogMetric(name string) error
DeleteLogMetric removes a metric.
func (*InMemoryBackend) DeleteSink ¶
func (b *InMemoryBackend) DeleteSink(name string) error
DeleteSink removes a sink.
func (*InMemoryBackend) DeleteView ¶
func (b *InMemoryBackend) DeleteView(name string) error
DeleteView removes a view.
func (*InMemoryBackend) GetBucket ¶
func (b *InMemoryBackend) GetBucket(name string) (*loggingpb.LogBucket, error)
GetBucket returns one bucket.
func (*InMemoryBackend) GetCmekSettings ¶
func (b *InMemoryBackend) GetCmekSettings(name string) (*loggingpb.CmekSettings, error)
GetCmekSettings returns the stored CMEK settings, or empty defaults.
func (*InMemoryBackend) GetExclusion ¶
func (b *InMemoryBackend) GetExclusion(name string) (*loggingpb.LogExclusion, error)
GetExclusion returns one exclusion.
func (*InMemoryBackend) GetLogMetric ¶
func (b *InMemoryBackend) GetLogMetric(name string) (*loggingpb.LogMetric, error)
GetLogMetric returns one metric.
func (*InMemoryBackend) GetSettings ¶
func (b *InMemoryBackend) GetSettings(name string) (*loggingpb.Settings, error)
GetSettings returns the stored settings, or defaults.
func (*InMemoryBackend) GetSink ¶
func (b *InMemoryBackend) GetSink(name string) (*loggingpb.LogSink, error)
GetSink returns one sink.
func (*InMemoryBackend) GetView ¶
func (b *InMemoryBackend) GetView(name string) (*loggingpb.LogView, error)
GetView returns one view.
func (*InMemoryBackend) ListBuckets ¶
func (b *InMemoryBackend) ListBuckets(req *loggingpb.ListBucketsRequest) ([]*loggingpb.LogBucket, string, error)
ListBuckets returns the buckets of a location ("-" lists every location), ordered by name.
func (*InMemoryBackend) ListExclusions ¶
func (b *InMemoryBackend) ListExclusions( req *loggingpb.ListExclusionsRequest, ) ([]*loggingpb.LogExclusion, string, error)
ListExclusions returns the parent's exclusions ordered by name.
func (*InMemoryBackend) ListLogEntries ¶
func (b *InMemoryBackend) ListLogEntries(req *loggingpb.ListLogEntriesRequest) ([]*loggingpb.LogEntry, string, error)
ListLogEntries returns matching entries ordered by timestamp, paged.
func (*InMemoryBackend) ListLogMetrics ¶
func (b *InMemoryBackend) ListLogMetrics(req *loggingpb.ListLogMetricsRequest) ([]*loggingpb.LogMetric, string, error)
ListLogMetrics returns the parent's metrics ordered by name.
func (*InMemoryBackend) ListLogs ¶
func (b *InMemoryBackend) ListLogs(req *loggingpb.ListLogsRequest) ([]string, string, error)
ListLogs returns the names of logs that hold entries under the given resources.
func (*InMemoryBackend) ListMonitoredResourceDescriptors ¶
func (b *InMemoryBackend) ListMonitoredResourceDescriptors( token string, size int32, ) ([]*monitoredres.MonitoredResourceDescriptor, string, error)
ListMonitoredResourceDescriptors pages the static catalog of monitored resource types.
func (*InMemoryBackend) ListSinks ¶
func (b *InMemoryBackend) ListSinks(req *loggingpb.ListSinksRequest) ([]*loggingpb.LogSink, string, error)
ListSinks returns the parent's sinks ordered by name.
func (*InMemoryBackend) ListViews ¶
func (b *InMemoryBackend) ListViews(req *loggingpb.ListViewsRequest) ([]*loggingpb.LogView, string, error)
ListViews returns a bucket's views ordered by name.
func (*InMemoryBackend) MetricPoints ¶
func (b *InMemoryBackend) MetricPoints(name string) ([]MetricPoint, error)
MetricPoints returns the accumulated series of a log-based metric ([PARENT]/metrics/[ID]).
func (*InMemoryBackend) Reset ¶
func (b *InMemoryBackend) Reset()
Reset clears all state; exporter 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) SetObjectStore ¶
func (b *InMemoryBackend) SetObjectStore(s ObjectStore)
SetObjectStore wires Cloud Storage sink destinations.
func (*InMemoryBackend) SetPublisher ¶
func (b *InMemoryBackend) SetPublisher(p Publisher)
SetPublisher wires Pub/Sub sink destinations.
func (*InMemoryBackend) SetTableStore ¶
func (b *InMemoryBackend) SetTableStore(s TableStore)
SetTableStore wires BigQuery sink destinations.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises buckets with their entries, sinks, exclusions, views, metrics and settings.
func (*InMemoryBackend) Tail ¶
func (b *InMemoryBackend) Tail( stream loggingpb.LoggingServiceV2_TailLogEntriesServer, req *loggingpb.TailLogEntriesRequest, ) error
Tail streams new matching entries to send until the client goes away or the server stops.
func (*InMemoryBackend) UndeleteBucket ¶
func (b *InMemoryBackend) UndeleteBucket(name string) error
UndeleteBucket restores a bucket that is pending deletion.
func (*InMemoryBackend) UpdateBucket ¶
func (b *InMemoryBackend) UpdateBucket(req *loggingpb.UpdateBucketRequest) (*loggingpb.LogBucket, error)
UpdateBucket applies the masked fields to a bucket.
func (*InMemoryBackend) UpdateCmekSettings ¶
func (b *InMemoryBackend) UpdateCmekSettings( req *loggingpb.UpdateCmekSettingsRequest, ) (*loggingpb.CmekSettings, error)
UpdateCmekSettings stores the key used for new log buckets; the key is not validated against Cloud KMS.
func (*InMemoryBackend) UpdateExclusion ¶
func (b *InMemoryBackend) UpdateExclusion(req *loggingpb.UpdateExclusionRequest) (*loggingpb.LogExclusion, error)
UpdateExclusion applies the masked fields of the request exclusion.
func (*InMemoryBackend) UpdateLogMetric ¶
func (b *InMemoryBackend) UpdateLogMetric(req *loggingpb.UpdateLogMetricRequest) (*loggingpb.LogMetric, error)
UpdateLogMetric replaces a metric, creating it when it does not exist.
func (*InMemoryBackend) UpdateSettings ¶
func (b *InMemoryBackend) UpdateSettings(req *loggingpb.UpdateSettingsRequest) (*loggingpb.Settings, error)
UpdateSettings stores organization or folder defaults; disable_default_sink disables the _Default sink.
func (*InMemoryBackend) UpdateSink ¶
func (b *InMemoryBackend) UpdateSink(req *loggingpb.UpdateSinkRequest) (*loggingpb.LogSink, error)
UpdateSink applies the masked fields of the request sink.
func (*InMemoryBackend) UpdateView ¶
func (b *InMemoryBackend) UpdateView(req *loggingpb.UpdateViewRequest) (*loggingpb.LogView, error)
UpdateView applies the masked fields to a view.
func (*InMemoryBackend) WriteLogEntries ¶
func (b *InMemoryBackend) WriteLogEntries(ctx context.Context, req *loggingpb.WriteLogEntriesRequest) error
WriteLogEntries stores entries, routes them through sinks, updates log-based metrics and feeds tails.
type MetricPoint ¶
type MetricPoint struct {
Labels map[string]string
BucketCounts []int64
Count int64
Sum float64
SumSqDev float64
}
MetricPoint is the accumulated value of one label combination of a log-based metric.
type ObjectStore ¶
type ObjectStore interface {
// ReadObject returns the object content or an error wrapping ErrObjectNotFound.
ReadObject(bucket, name string) ([]byte, error)
WriteObject(bucket, name string, data []byte, contentType string) error
}
ObjectStore is the slice of Cloud Storage that sink export needs.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for Google Cloud Logging. 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 Settings ¶
type Settings struct {
Port int `` //nolint:lll // config struct tags are intentionally verbose
/* 182-byte string literal not displayed */
}
Settings holds service-level configuration, embedded in the root CLI command as CLI.GCPLogging.
func DefaultSettings ¶
func DefaultSettings() Settings
DefaultSettings returns the settings used when no ConfigProvider is available.
type TableStore ¶
type TableStore interface {
// EnsureTable creates the table with the schema when it does not exist.
EnsureTable(project, dataset, table string, schema []map[string]any) error
InsertRows(project, dataset, table string, rows []map[string]any) error
}
TableStore is the slice of BigQuery that sink export needs.
Source Files
¶
- account_settings.go
- bucket_ops.go
- buckets.go
- entries_read.go
- entries_write.go
- errors.go
- exclusions.go
- export.go
- export_bq.go
- filter_eval.go
- filter_lex.go
- filter_parse.go
- grpc_config.go
- grpc_logging.go
- grpc_metrics.go
- handler.go
- metrics.go
- metrics_eval.go
- names.go
- persistence.go
- provider.go
- resources.go
- route.go
- settings.go
- sinks.go
- store.go
- tail.go
- views.go