Documentation
¶
Index ¶
- Constants
- Variables
- func NewLegacyCloudLoggingListLogTask(taskId taskid.TaskImplementationID[[]*log.Log], readableQueryName string, ...) coretask.Task[[]*log.Log]
- func NewListLogEntriesTask(taskSetting ListLogEntriesTaskSetting) coretask.Task[[]*log.Log]
- type DefaultResourceNamesGenerator
- type GCPAccessLogFieldSet
- type GCPAccessLogFieldSetReader
- type GCPAuditLogFieldSet
- func (g *GCPAuditLogFieldSet) Ending() bool
- func (g *GCPAuditLogFieldSet) ImmediateOperation() bool
- func (g *GCPAuditLogFieldSet) Kind() string
- func (g *GCPAuditLogFieldSet) OperationPath(pathToParent resourcepath.ResourcePath) resourcepath.ResourcePath
- func (g *GCPAuditLogFieldSet) RequestString() (string, error)
- func (g *GCPAuditLogFieldSet) ResponseString() (string, error)
- func (g *GCPAuditLogFieldSet) Starting() bool
- type GCPOperationAuditLogFieldSetReader
- type ListLogEntriesTaskDescription
- type ListLogEntriesTaskSetting
- type LocationFetcher
- type LogFetchProgress
- type LogFetcher
- type ProgressReportableLogFetcher
- type ProjectIDDefaultResourceNamesGenerator
- type QueryGeneratorFunc
- type QueryResourceNames
- type ResourceNamesInput
- type StandardProgressReportableLogFetcher
- type TimePartitioningProgressReportableLogFetcher
Constants ¶
const ( // FormBasePriority is the base priority for Google Cloud common forms. FormBasePriority = 100000 // PriorityForQueryTimeGroup is the priority for the query time group. PriorityForQueryTimeGroup = FormBasePriority + 50000 // PriorityForResourceIdentifierGroup is the priority for the resource identifier group. PriorityForResourceIdentifierGroup = FormBasePriority + 40000 // PriorityForK8sResourceFilterGroup is the priority for the k8s resource filter group. PriorityForK8sResourceFilterGroup = FormBasePriority + 30000 )
Variables ¶
var APICallOptionsInjectorContextKey = typedmap.NewTypedKey[*[]googlecloud.CallOptionInjectorOption]("api-call-option-injector-options")
APICallOptionsInjectorContextKey is the key to retrieve the list of googlecloud.CallOptionInjectorOption from task context. The value is injected on the task server during the initialization.
var APIClientCallOptionsInjectorTaskID = taskid.NewDefaultImplementationID[*googlecloud.CallOptionInjector](GoogleCloudCommonTaskIDPrefix + "api-client-option-injector")
APIClientCallOptionsInjectorTaskID is the task ID to inject CallOptionInjector reference.
var APIClientFactoryOptionsContextKey = typedmap.NewTypedKey[*[]googlecloud.ClientFactoryOption]("api-client-factory-options")
APIClientFactoryOptionsContextKey is the key to retrieve googlecloud.ClientFactoryOption from task context. The value is injected on the task server during the initialization.
var APIClientFactoryOptionsTaskID = taskid.NewDefaultImplementationID[[]googlecloud.ClientFactoryOption](GoogleCloudCommonTaskIDPrefix + "api-client-factory-options")
APIClientFactoryOptionsTaskID is the task ID to generate options list for the ClientFactory. This can be overridden with the selection priority label defined in the coretask package.
var APIClientFactoryTaskID = taskid.NewDefaultImplementationID[*googlecloud.ClientFactory](GoogleCloudCommonTaskIDPrefix + "api-client-factory")
APIClientFactoryTaskID is the task ID to generate the ClientFactory. This factory is instantiated with the options generated from the task with APIClientFactoryOptionsTaskID.
var AutocompleteLocationTaskID taskid.TaskImplementationID[[]string] = taskid.NewDefaultImplementationID[[]string](GoogleCloudCommonTaskIDPrefix + "autocomplete-location")
AutocompleteLocationTaskID is the task ID for the location autocomplete.
var DefaultAPIClientOptionTasksPriority = 1000
DefaultAPIClientOptionTasksPriority is the selection priority of the default implementation for APIClientFactoryOptionsTaskID and APICallOptionsInjectorTask. Users can define another task for the task ID with higher priority to override the options.
var GoogleCloudCommonTaskIDPrefix = "cloud.google.com/common/"
GoogleCloudCommonTaskIDPrefix is the prefix for Google Cloud common task IDs.
var InputDurationTaskID = taskid.NewDefaultImplementationID[time.Duration](GoogleCloudCommonTaskIDPrefix + "input-duration")
InputDurationTaskID is the task ID for the duration of the log query.
var InputEndTimeTaskID = taskid.NewDefaultImplementationID[time.Time](GoogleCloudCommonTaskIDPrefix + "input-end-time")
InputEndTimeTaskID is the task ID for the end time of the log query.
var InputLocationsTaskID = taskid.NewDefaultImplementationID[string](GoogleCloudCommonTaskIDPrefix + "input-location")
InputLocationsTaskID is the task ID for the locations of the target resource.
var InputLoggingFilterResourceNameTaskID = taskid.NewDefaultImplementationID[*ResourceNamesInput](GoogleCloudCommonTaskIDPrefix + "input-logging-filter-resource-name")
InputLoggingFilterResourceNameTaskID is the task ID to get log query target resource names.
var InputProjectIdTaskID = taskid.NewDefaultImplementationID[string](GoogleCloudCommonTaskIDPrefix + "input-project-id")
InputProjectIdTaskID is the task ID for the Google Cloud project ID.
var InputStartTimeTaskID = taskid.NewDefaultImplementationID[time.Time](GoogleCloudCommonTaskIDPrefix + "input-start-time")
InputStartTimeTaskID is the task ID for the start time of the log query. This is computed from InputDurationTask and InputEndTimeTask.
var LocationFetcherTaskID = taskid.NewDefaultImplementationID[LocationFetcher](GoogleCloudCommonTaskIDPrefix + "location-fetcher")
LocationFetcherTaskID is the task ID to inject the instance of LocationFetcher.
var LoggingFetcherTaskID = taskid.NewDefaultImplementationID[LogFetcher](GoogleCloudCommonTaskIDPrefix + "log-fetcher")
LoggingFetcherTaskID is the task ID to inject the instance of LogFetcher.
var RequestOptionalInputResourceNameTaskLabel = typedmap.NewTypedKey[string]("request-optional-input-resource-name")
RequestOptionalInputResourceNameTaskLabel is a label assigned to a task that requests the Cloud Logging resource name optionally. The value is the query ID.
Functions ¶
func NewLegacyCloudLoggingListLogTask ¶
func NewLegacyCloudLoggingListLogTask(taskId taskid.TaskImplementationID[[]*log.Log], readableQueryName string, logType enum.LogType, dependencies []taskid.UntypedTaskReference, resourceNamesGenerator DefaultResourceNamesGenerator, generator QueryGeneratorFunc, sampleQuery string) coretask.Task[[]*log.Log]
NewLegacyCloudLoggingListLogTask creates a new task that lists log entries from Cloud Logging.
func NewListLogEntriesTask ¶
func NewListLogEntriesTask(taskSetting ListLogEntriesTaskSetting) coretask.Task[[]*log.Log]
NewListLogEntriesTask creates a new task that lists log entries from Cloud Logging based on the provided settings.
Types ¶
type DefaultResourceNamesGenerator ¶
type DefaultResourceNamesGenerator interface {
// GetDependentTasks returns the list of task references needed for generating resource names.
GetDependentTasks() []taskid.UntypedTaskReference
// GenerateResourceNames returns the list of resource names.
GenerateResourceNames(ctx context.Context) ([]string, error)
}
DefaultResourceNamesGenerator is an interface for generating the default resource names used for querying Cloud Logging.
type GCPAccessLogFieldSet ¶
type GCPAccessLogFieldSet struct {
Method string
RequestURL string
RequestSize int64
Status int
ResponseSize int64
UserAgent string
RemoteIP string
ServerIP string
Referer string
Latency string
Protocol string
}
func (*GCPAccessLogFieldSet) Kind ¶
func (g *GCPAccessLogFieldSet) Kind() string
Kind implements log.FieldSet.
type GCPAccessLogFieldSetReader ¶
type GCPAccessLogFieldSetReader struct {
}
func (*GCPAccessLogFieldSetReader) FieldSetKind ¶
func (g *GCPAccessLogFieldSetReader) FieldSetKind() string
FieldSetKind implements log.FieldSetReader.
func (*GCPAccessLogFieldSetReader) Read ¶
func (g *GCPAccessLogFieldSetReader) Read(reader *structured.NodeReader) (log.FieldSet, error)
Read implements log.FieldSetReader.
type GCPAuditLogFieldSet ¶
type GCPAuditLogFieldSet struct {
OperationID string
OperationFirst bool
OperationLast bool
MethodName string
ResourceName string
PrincipalEmail string
Status int
Request *structured.NodeReader
Response *structured.NodeReader
}
func (*GCPAuditLogFieldSet) Ending ¶
func (g *GCPAuditLogFieldSet) Ending() bool
Ending returns true when the operation is long running operation and the log entry is for the ending timing.
func (*GCPAuditLogFieldSet) ImmediateOperation ¶
func (g *GCPAuditLogFieldSet) ImmediateOperation() bool
ImmediateOperation returns true when the log represents an operation completes immediately.
func (*GCPAuditLogFieldSet) Kind ¶
func (g *GCPAuditLogFieldSet) Kind() string
Kind implements log.FieldSet.
func (*GCPAuditLogFieldSet) OperationPath ¶
func (g *GCPAuditLogFieldSet) OperationPath(pathToParent resourcepath.ResourcePath) resourcepath.ResourcePath
OperationPath returns the resource path for the operation.
func (*GCPAuditLogFieldSet) RequestString ¶
func (g *GCPAuditLogFieldSet) RequestString() (string, error)
RequestString returns the request body as a YAML string.
func (*GCPAuditLogFieldSet) ResponseString ¶
func (g *GCPAuditLogFieldSet) ResponseString() (string, error)
ResponseString returns the response body as a YAML string.
func (*GCPAuditLogFieldSet) Starting ¶
func (g *GCPAuditLogFieldSet) Starting() bool
Starting returns true when the operation is long running operation and the log entry is for the starting timing.
type GCPOperationAuditLogFieldSetReader ¶
type GCPOperationAuditLogFieldSetReader struct {
}
func (*GCPOperationAuditLogFieldSetReader) FieldSetKind ¶
func (g *GCPOperationAuditLogFieldSetReader) FieldSetKind() string
FieldSetKind implements log.FieldSetReader.
func (*GCPOperationAuditLogFieldSetReader) Read ¶
func (g *GCPOperationAuditLogFieldSetReader) Read(reader *structured.NodeReader) (log.FieldSet, error)
Read implements log.FieldSetReader.
type ListLogEntriesTaskDescription ¶
type ListLogEntriesTaskDescription struct {
DefaultLogType enum.LogType
QueryName string
ExampleQuery string
}
ListLogEntriesTaskDescription holds descriptive information for a task to list log entries from CloudLogging.
type ListLogEntriesTaskSetting ¶
type ListLogEntriesTaskSetting interface {
// TaskID returns the task ID for the Cloud Logging list log entries task.
TaskID() taskid.TaskImplementationID[[]*log.Log]
// Dependencies returns the list of dependencies for the Cloud Logging list log entries task.
// Return the dependency task reference IDs when the result is used in DefaultResourceNames(), LogFilters() or TimePartitionCount().
Dependencies() []taskid.UntypedTaskReference
// DefaultResourceNames returns the list of resource names for the Cloud Logging list log entries task.
// This is just a default value for the resource name. Users can override this value with the form field.
// Return the list of resource names. ref: https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/list
DefaultResourceNames(ctx context.Context) ([]string, error)
// LogFilters returns the list of log filters for the Cloud Logging list log entries task.
// When generated logging filter can exceed the 20,000 character maximum limit in Cloud Logging, return multiple subset query.
// Result includes the logs for all log filters.
LogFilters(ctx context.Context, taskMode inspectioncore_contract.InspectionTaskModeType) ([]string, error)
// TimePartitionCount returns the number of time partitions for the Cloud Logging list log entries task.
// ListLogEntriesTask split the duration into the number of partition count to gather logs in parallel.
// Return 1 - 16 values depending on the expected log volume by the log filter.
TimePartitionCount(ctx context.Context) (int, error)
// Description returns the description for the Cloud Logging filter task.
Description() *ListLogEntriesTaskDescription
}
ListLogEntriesTaskSetting defines the settings for a Cloud Logging list log entries task.
type LocationFetcher ¶
type LocationFetcher interface {
FetchRegions(ctx context.Context, projectId string) ([]string, error)
}
func NewLocationFetcher ¶
func NewLocationFetcher(client *compute.RegionsClient, callOptionInjector *googlecloud.CallOptionInjector) LocationFetcher
type LogFetchProgress ¶
type LogFetchProgress struct {
// LogCount is the total number of logs fetched so far.
LogCount int
// Progress indicates the completion status, ranging from 0.0 to 1.0.
Progress float32
}
LogFetchProgress represents the progress of a log fetching operation.
type LogFetcher ¶
type LogFetcher interface {
FetchLogs(dest chan<- *loggingpb.LogEntry, ctx context.Context, filter string, container googlecloud.ResourceContainer, resourceContainers []string) error
}
LogFetcher is an interface for fetching logs from Cloud Logging with a given filter and sending them to a specified channel. The implementation must close the destination channel after the query is done.
func NewLogFetcher ¶
func NewLogFetcher(clientFactory *googlecloud.ClientFactory, callOptionInjector *googlecloud.CallOptionInjector, pageSize int32) LogFetcher
NewLogFetcher returns the instance of LogFetcher initialized with the given *googlecloud.ClientFactory.
type ProgressReportableLogFetcher ¶
type ProgressReportableLogFetcher interface {
// FetchLogsWithProgress fetches logs while periodically reporting its progress through a separate channel.
// Implementations must close both the dest and progress channels upon completion.
FetchLogsWithProgress(dest chan<- *loggingpb.LogEntry, progress chan<- LogFetchProgress, ctx context.Context, beginTime, endTime time.Time, filterWithoutTimeRange string, container googlecloud.ResourceContainer, resourceContainers []string) error
}
type ProjectIDDefaultResourceNamesGenerator ¶
type ProjectIDDefaultResourceNamesGenerator struct{}
ProjectIDDefaultResourceNamesGenerator generates resource names from the project ID.
func (*ProjectIDDefaultResourceNamesGenerator) GenerateResourceNames ¶
func (p *ProjectIDDefaultResourceNamesGenerator) GenerateResourceNames(ctx context.Context) ([]string, error)
GenerateResourceNames implements DefaultResourceNamesGenerator.
func (*ProjectIDDefaultResourceNamesGenerator) GetDependentTasks ¶
func (p *ProjectIDDefaultResourceNamesGenerator) GetDependentTasks() []taskid.UntypedTaskReference
GetDependentTasks implements DefaultResourceNamesGenerator.
type QueryGeneratorFunc ¶
type QueryGeneratorFunc = func(context.Context, inspectioncore_contract.InspectionTaskModeType) ([]string, error)
QueryGeneratorFunc is a function type that generates Cloud Logging queries. A query task may return multiple logging filters because a logging filter has a maximum length, and some query tasks need to split a long filter into multiple smaller ones.
type QueryResourceNames ¶
type QueryResourceNames struct {
QueryID string
DefaultResourceNames []string
CurrentResourceNames []string
}
QueryResourceNames holds the resource names for a specific query.
func (*QueryResourceNames) GetInputID ¶
func (q *QueryResourceNames) GetInputID() string
GetInputID returns the form input ID for the query.
type ResourceNamesInput ¶
type ResourceNamesInput struct {
// contains filtered or unexported fields
}
ResourceNamesInput is a container for resource names used in log queries.
func NewResourceNamesInput ¶
func NewResourceNamesInput() *ResourceNamesInput
NewResourceNamesInput creates a new ResourceNamesInput.
func (*ResourceNamesInput) GetResourceNamesForQuery ¶
func (r *ResourceNamesInput) GetResourceNamesForQuery(ctx context.Context, queryID string) *QueryResourceNames
GetResourceNamesForQuery returns the resource names for a given query ID.
func (*ResourceNamesInput) UpdateDefaultResourceNamesForQuery ¶
func (r *ResourceNamesInput) UpdateDefaultResourceNamesForQuery(queryID string, defaultResourceNames []string)
UpdateDefaultResourceNamesForQuery updates the default resource names for a given query ID.
type StandardProgressReportableLogFetcher ¶
type StandardProgressReportableLogFetcher struct {
// contains filtered or unexported fields
}
StandardProgressReportableLogFetcher is a decorator for a LogFetcher that adds the ability to report the progress of log fetching.
func NewStandardProgressReportableLogFetcher ¶
func NewStandardProgressReportableLogFetcher(fetcher LogFetcher, interval time.Duration) *StandardProgressReportableLogFetcher
NewProgressReportableLogFetcher creates a new instance of ProgressReportableLogFetcher.
func (*StandardProgressReportableLogFetcher) FetchLogsWithProgress ¶
func (s *StandardProgressReportableLogFetcher) FetchLogsWithProgress(dest chan<- *loggingpb.LogEntry, progress chan<- LogFetchProgress, ctx context.Context, beginTime, endTime time.Time, filterWithoutTimeRange string, container googlecloud.ResourceContainer, resourceContainers []string) error
FetchLogsWithProgress implements FetchLogsWithProgress.
type TimePartitioningProgressReportableLogFetcher ¶
type TimePartitioningProgressReportableLogFetcher struct {
// contains filtered or unexported fields
}
func NewTimePartitioningProgressReportableLogFetcher ¶
func NewTimePartitioningProgressReportableLogFetcher(fetcher LogFetcher, interval time.Duration, partitionCount int, maxParallelism int) *TimePartitioningProgressReportableLogFetcher
func (*TimePartitioningProgressReportableLogFetcher) FetchLogsWithProgress ¶
func (t *TimePartitioningProgressReportableLogFetcher) FetchLogsWithProgress(logChan chan<- *loggingpb.LogEntry, progressChan chan<- LogFetchProgress, ctx context.Context, beginTime time.Time, endTime time.Time, filterWithoutTimeRange string, container googlecloud.ResourceContainer, resourceContainers []string) error
FetchLogsWithProgress implements ProgressReportableLogFetcher.