googlecloudlogcsm_impl

package
v0.58.4 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Copyright 2026 Google LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var CSMClusterIdentifierTask = coretask.NewTask(
	googlecloudlogcsm_contract.CSMClusterIdentifierTaskID,
	[]taskid.UntypedTaskReference{googlecloudk8scommon_contract.NEGToBackendServiceInventoryTaskID.Ref()},
	func(ctx context.Context) ([]string, error) {
		inventory := coretask.GetTaskResult(ctx, googlecloudk8scommon_contract.NEGToBackendServiceInventoryTaskID.Ref())

		uniqueIds := make(map[string]struct{})

		for _, bsName := range inventory {
			if strings.HasPrefix(bsName, "gsmrsvd-") {

				parts := strings.Split(bsName, "-")
				if len(parts) >= 3 {
					uniqueIds[parts[1]] = struct{}{}
				}
			}
		}

		result := make([]string, 0, len(uniqueIds))
		for id := range uniqueIds {
			result = append(result, id)
		}
		return result, nil
	},
)

CSMClusterIdentifierTask extracts the unique cluster identifier(s) from BackendService names. CSM BackendService names follow the pattern: gsmrsvd-(cluster-identifier)-(neg-id).

View Source
var CSMTrafficDirectorLogGrouperTask = inspectiontaskbase.NewLogGrouperTask(
	googlecloudlogcsm_contract.CSMTrafficDirectorLogGrouperTaskID,
	googlecloudlogcsm_contract.ListCSMTrafficDirectorLogEntriesTaskID.Ref(),
	func(ctx context.Context, l *log.Log) string {
		audit, err := googlecloudcommon_contract.ExtractGCPAuditLog(l.NodeReader)
		if err != nil {
			return "unknown"
		}
		return audit.ResourceName
	},
)

CSMTrafficDirectorLogGrouperTask is a task that groups CSM Traffic Director logs by their resource name.

CSMTrafficDirectorLogIngesterTask is a task that ingests CSM Traffic Director logs.

View Source
var CSMTrafficDirectorLogToTimelineMapperTask = inspectiontaskbase.NewLogToTimelineMapperTask(
	googlecloudlogcsm_contract.CSMTrafficDirectorLogToTimelineMapperTaskID,
	&CSMTrafficDirectorLogToTimelineMapper{},
	inspectioncore_contract.FeatureTaskLabel(
		"CSM Resource Audit Logs",
		"Gather audit logs for Traffic Director resources created by the TD-based CSM to map them to timelines alongside associated Kubernetes resource logs.",
		10100,
		false,
	),
)

CSMTrafficDirectorLogToTimelineMapperTask maps CSM Traffic Director logs to timelines.

View Source
var InputCSMResponseFlagsTask = formtask.NewSetFormTaskBuilder(googlecloudlogcsm_contract.InputCSMResponseFlagsTaskID, priorityForCSMGroup+1000, "Envoy response flags").
	WithDefaultValueConstant([]string{"@any", "-OK"}, true).
	WithAllowAddAll(false).
	WithAllowRemoveAll(false).
	WithAllowCustomValue(true).
	WithDescription("Response flags used for filtering CSM traffic logs. Note '-' in response flags is corresponded to 'OK' in this form.").
	WithOptionsFunc(func(ctx context.Context, previousValues []string) ([]inspectionmetadata.SetParameterFormFieldOptionItem, error) {
		result := []inspectionmetadata.SetParameterFormFieldOptionItem{
			{ID: "@any", Description: "[Alias] Matches any response flag"},
		}
		ids := make([]string, 0, len(logutil.EnvoyResponseFlagDescriptions))
		for flag := range logutil.EnvoyResponseFlagDescriptions {
			ids = append(ids, string(flag))
		}
		sort.Strings(ids)
		for _, id := range ids {
			message := logutil.EnvoyResponseFlagDescriptions[logutil.EnvoyResponseFlag(id)]
			if id == "-" {
				id = "OK"
				message = "It's '-' in the response flag field because '-' means subtracting operator in this form."
			}
			result = append(result, inspectionmetadata.SetParameterFormFieldOptionItem{ID: id, Description: message})
		}
		return result, nil
	}).
	WithValidator(func(ctx context.Context, value []string) (string, error) {
		strFilter := strings.Join(value, " ")
		result, err := gcpqueryutil.ParseSetFilter(strFilter, inputCSMAliasMap, true, true, true)
		if err != nil {
			return "", err
		}
		if result.ValidationError == "" {
			err = verifyResponseFlags(convertInputOnlyResponseFlagToActualFlag(result.Additives))
			if err != nil {
				return err.Error(), nil
			}
			err = verifyResponseFlags(convertInputOnlyResponseFlagToActualFlag(result.Subtractives))
			if err != nil {
				return err.Error(), nil
			}
		}
		return result.ValidationError, nil
	}).
	WithConverter(func(ctx context.Context, value []string) (*gcpqueryutil.SetFilterParseResult, error) {
		strFilter := strings.Join(value, " ")
		result, err := gcpqueryutil.ParseSetFilter(strFilter, inputCSMAliasMap, true, true, true)
		if err != nil {
			return nil, err
		}
		result.Additives = convertInputOnlyResponseFlagToActualFlag(result.Additives)
		result.Subtractives = convertInputOnlyResponseFlagToActualFlag(result.Subtractives)
		return result, nil
	}).
	Build()
View Source
var InputFleetProjectIDTask = formtask.NewTextFormTaskBuilder(googlecloudlogcsm_contract.InputFleetProjectIDTaskID, priorityForCSMGroup+500, "Fleet project ID").
	WithDependencies([]taskid.UntypedTaskReference{
		googlecloudlogcsm_contract.ClusterIdentityTaskID.Ref(),
	}).
	WithDescription("The project ID where the Fleet is hosted and CSM control plane logs are stored. Default is the cluster's project ID.").
	WithDefaultValueFunc(func(ctx context.Context, previousValues []string) (string, error) {
		if len(previousValues) > 0 {
			return previousValues[0], nil
		}
		cluster := coretask.GetTaskResult(ctx, googlecloudlogcsm_contract.ClusterIdentityTaskID.Ref())
		return cluster.ProjectID, nil
	}).
	Build()
View Source
var LogGrouperTask = inspectiontaskbase.NewLogGrouperTask(googlecloudlogcsm_contract.LogGrouperTaskID, googlecloudlogcsm_contract.ListLogEntriesTaskID.Ref(),
	func(ctx context.Context, l *log.Log) string {
		istioAccessLogFieldSet, err := googlecloudlogcsm_contract.ExtractIstioAccessLog(l.NodeReader)
		if err != nil {
			return "unknown"
		}
		return fmt.Sprintf("%s-%s", istioAccessLogFieldSet.ReporterPodNamespace, istioAccessLogFieldSet.ReporterPodName)
	},
)

LogGrouperTask groups CSM traffic logs by their reporter pod.

LogIngesterTask is the task that executes CSMTrafficLogLogIngester.

View Source
var LogToTimelineMapperTask = inspectiontaskbase.NewLogToTimelineMapperTask(
	googlecloudlogcsm_contract.LogToTimelineMapperTaskID,
	&CSMTrafficLogLogToTimelineMapper{},
	inspectioncore_contract.FeatureTaskLabel(
		"CSM Traffic Logs",
		"Gather CSM traffic logs to visualize network traffic flows and latency under client or server Pod timelines.",
		10000,
		false,
	),
)

LogToTimelineMapperTask maps CSM traffic logs to timelines.

Functions

func GenerateCSMTrafficDirectorQuery added in v0.58.2

func GenerateCSMTrafficDirectorQuery(fleetProjectID string, clusterIdentifiers []string, isDryRun bool) string

GenerateCSMTrafficDirectorQuery generates a query for CSM Traffic Director logs.

func GenerateCSMTrafficDirectorStructuredQuery added in v0.58.2

func GenerateCSMTrafficDirectorStructuredQuery(fleetProjectID string, clusterIdentifiers []string, isDryRun bool) *logestimator.StructuredLogQuery

GenerateCSMTrafficDirectorStructuredQuery generates a structured query for CSM Traffic Director logs.

func GenerateCSMTrafficLogsQuery added in v0.58.2

func GenerateCSMTrafficLogsQuery(cluster googlecloudk8scommon_contract.GoogleCloudClusterIdentity, responseFlagsSetFilter *gcpqueryutil.SetFilterParseResult, namespaceSetFilter *gcpqueryutil.SetFilterParseResult) string

GenerateCSMTrafficLogsQuery generates a query for CSM Traffic logs.

func GenerateCSMTrafficLogsStructuredQuery added in v0.58.2

func GenerateCSMTrafficLogsStructuredQuery(cluster googlecloudk8scommon_contract.GoogleCloudClusterIdentity, responseFlagsSetFilter *gcpqueryutil.SetFilterParseResult, namespaceSetFilter *gcpqueryutil.SetFilterParseResult) *logestimator.StructuredLogQuery

GenerateCSMTrafficLogsStructuredQuery generates a structured query for CSM Traffic logs.

func Register

func Register(registry coreinspection.InspectionTaskRegistry) error
graph TD
 subgraph "CSM Traffic Log"
   direction LR
   InputCSMResponseFlagsTask(Input CSM Response Flags)
   ListLogEntriesTask(List Log Entries)
   LogIngesterTask(Log Serializer)
   LogGrouperTask(Log Grouper)
   LogToTimelineMapperTask(TimelineMapper)

   ListLogEntriesTask --> LogGrouperTask
   ListLogEntriesTask --> LogIngesterTask
   LogGrouperTask --> LogToTimelineMapperTask
   LogIngesterTask --> LogToTimelineMapperTask
   InputCSMResponseFlagsTask --> ListLogEntriesTask
 end

Register registers all googlecloudlogcsm inspection tasks to the registry.

Types

type CSMTrafficDirectorListLogEntryTaskSetting added in v0.54.0

type CSMTrafficDirectorListLogEntryTaskSetting struct{}

func (*CSMTrafficDirectorListLogEntryTaskSetting) DefaultResourceNames added in v0.54.0

func (s *CSMTrafficDirectorListLogEntryTaskSetting) DefaultResourceNames(ctx context.Context) ([]string, error)

DefaultResourceNames implements googlecloudcommon_contract.StructuredListLogEntriesTaskSetting.

func (*CSMTrafficDirectorListLogEntryTaskSetting) Dependencies added in v0.54.0

Dependencies implements googlecloudcommon_contract.StructuredListLogEntriesTaskSetting.

func (*CSMTrafficDirectorListLogEntryTaskSetting) Queries added in v0.58.2

Queries implements googlecloudcommon_contract.StructuredListLogEntriesTaskSetting.

func (*CSMTrafficDirectorListLogEntryTaskSetting) QueryName added in v0.58.2

QueryName implements googlecloudcommon_contract.StructuredListLogEntriesTaskSetting.

func (*CSMTrafficDirectorListLogEntryTaskSetting) TaskID added in v0.54.0

TaskID implements googlecloudcommon_contract.StructuredListLogEntriesTaskSetting.

func (*CSMTrafficDirectorListLogEntryTaskSetting) TimePartitionCount added in v0.54.0

func (s *CSMTrafficDirectorListLogEntryTaskSetting) TimePartitionCount(ctx context.Context) (int, error)

TimePartitionCount implements googlecloudcommon_contract.StructuredListLogEntriesTaskSetting.

type CSMTrafficDirectorLogToTimelineMapper added in v0.56.0

type CSMTrafficDirectorLogToTimelineMapper struct {
	inspectiontaskbase.SinglePassMapperBase[*googlecloudcommon_contract.GCPOperationTracker]
}

CSMTrafficDirectorLogToTimelineMapper maps CSM Traffic Director logs to resource timelines.

func (*CSMTrafficDirectorLogToTimelineMapper) Dependencies added in v0.56.0

Dependencies returns additional task dependencies.

func (*CSMTrafficDirectorLogToTimelineMapper) GroupedLogTask added in v0.56.0

GroupedLogTask returns a reference to the task that provides the grouped logs.

func (*CSMTrafficDirectorLogToTimelineMapper) LogIngesterTask added in v0.56.0

func (m *CSMTrafficDirectorLogToTimelineMapper) LogIngesterTask() taskid.TaskReference[struct{}]

LogIngesterTask returns a reference to the task that provides ingested logs.

func (*CSMTrafficDirectorLogToTimelineMapper) ProcessLogByGroup added in v0.56.0

ProcessLogByGroup maps each log inside a group to one or more timeline events or revisions.

type CSMTrafficLogListLogEntryTaskSetting added in v0.57.4

type CSMTrafficLogListLogEntryTaskSetting struct{}

func (*CSMTrafficLogListLogEntryTaskSetting) DefaultResourceNames added in v0.57.4

func (c *CSMTrafficLogListLogEntryTaskSetting) DefaultResourceNames(ctx context.Context) ([]string, error)

DefaultResourceNames implements googlecloudcommon_contract.StructuredListLogEntriesTaskSetting.

func (*CSMTrafficLogListLogEntryTaskSetting) Dependencies added in v0.57.4

Dependencies implements googlecloudcommon_contract.StructuredListLogEntriesTaskSetting.

func (*CSMTrafficLogListLogEntryTaskSetting) Queries added in v0.58.2

Queries implements googlecloudcommon_contract.StructuredListLogEntriesTaskSetting.

func (*CSMTrafficLogListLogEntryTaskSetting) QueryName added in v0.58.2

QueryName implements googlecloudcommon_contract.StructuredListLogEntriesTaskSetting.

func (*CSMTrafficLogListLogEntryTaskSetting) TaskID added in v0.57.4

TaskID implements googlecloudcommon_contract.StructuredListLogEntriesTaskSetting.

func (*CSMTrafficLogListLogEntryTaskSetting) TimePartitionCount added in v0.57.4

func (c *CSMTrafficLogListLogEntryTaskSetting) TimePartitionCount(ctx context.Context) (int, error)

TimePartitionCount implements googlecloudcommon_contract.StructuredListLogEntriesTaskSetting.

type CSMTrafficLogLogIngester added in v0.57.4

type CSMTrafficLogLogIngester struct{}

CSMTrafficLogLogIngester ingests CSM traffic logs.

func (*CSMTrafficLogLogIngester) Dependencies added in v0.57.4

Dependencies returns the task dependencies.

func (*CSMTrafficLogLogIngester) ProcessLog added in v0.57.4

ProcessLog parses raw log entry and populates the LogChangeSet.

func (*CSMTrafficLogLogIngester) RawLogTask added in v0.57.4

func (i *CSMTrafficLogLogIngester) RawLogTask() taskid.TaskReference[[]*log.Log]

RawLogTask returns the task reference that provides raw logs.

type CSMTrafficLogLogToTimelineMapper added in v0.57.4

type CSMTrafficLogLogToTimelineMapper struct {
	inspectiontaskbase.StatelessMapperBase
}

CSMTrafficLogLogToTimelineMapper maps CSM traffic logs to resource timelines.

func (*CSMTrafficLogLogToTimelineMapper) Dependencies added in v0.57.4

Dependencies returns additional task dependencies.

func (*CSMTrafficLogLogToTimelineMapper) GroupedLogTask added in v0.57.4

GroupedLogTask returns a reference to the task that provides the grouped logs.

func (*CSMTrafficLogLogToTimelineMapper) LogIngesterTask added in v0.57.4

func (m *CSMTrafficLogLogToTimelineMapper) LogIngesterTask() taskid.TaskReference[struct{}]

LogIngesterTask returns a reference to the task that provides ingested logs.

func (*CSMTrafficLogLogToTimelineMapper) ProcessLogByGroup added in v0.57.4

func (m *CSMTrafficLogLogToTimelineMapper) ProcessLogByGroup(ctx context.Context, l *log.Log, _ struct{}) (*khifilev6.TimelineChangeSet, struct{}, error)

ProcessLogByGroup maps each log inside a group to one or more timeline events.

Jump to

Keyboard shortcuts

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