Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ClusterIdentityAliasTask = coretask.NewAliasTask( googlecloudlogk8scontainer_contract.ClusterIdentityTaskID, googlecloudk8scommon_contract.ClusterIdentityTaskID.Ref(), )
var FieldSetReaderTask = inspectiontaskbase.NewFieldSetReadTask(googlecloudlogk8scontainer_contract.FieldSetReaderTaskID, googlecloudlogk8scontainer_contract.ListLogEntriesTaskID.Ref(), []log.FieldSetReader{ &googlecloudlogk8scontainer_contract.K8sContainerLogFieldSetReader{}, &googlecloudcommon_contract.GCPDefaultSeverityFieldSetReader{}, &googlecloudlogk8scontainer_contract.GCPContainerLogNodeNameLabelFieldSetReader{}, })
FieldSetReaderTask reads fields in parallel.
var InputContainerQueryNamespaceFilterTask = formtask.NewSetFormTaskBuilder(googlecloudlogk8scontainer_contract.InputContainerQueryNamespacesTaskID, priorityForContainerGroup+1000, "Namespaces(Container logs)"). WithDependencies([]taskid.UntypedTaskReference{googlecloudk8scommon_contract.AutocompleteNamespacesTaskID.Ref()}). WithDefaultValueConstant([]string{"@managed"}, true). WithAllowAddAll(false). WithAllowRemoveAll(false). WithAllowCustomValue(true). WithDescription(`Container logs tend to be a lot and take very long time to query. Specify the space splitted namespace lists to query container logs only in the specific namespaces.`). WithOptionsFunc(func(ctx context.Context, value []string) ([]inspectionmetadata.SetParameterFormFieldOptionItem, error) { result := []inspectionmetadata.SetParameterFormFieldOptionItem{} namespaces := coretask.GetTaskResult(ctx, googlecloudk8scommon_contract.AutocompleteNamespacesTaskID.Ref()) result = append(result, inspectionmetadata.SetParameterFormFieldOptionItem{ ID: "@managed", Description: "[Alias] An alias matches the managed namespaces(e.g kube-system,gke-system,...etc).", }, inspectionmetadata.SetParameterFormFieldOptionItem{ ID: "@any", Description: "[Alias] An alias matches any pod namespaces.", }) for i, namespace := range namespaces.Values { if i >= maxNamespaceFilterOptions { break } result = append(result, inspectionmetadata.SetParameterFormFieldOptionItem{ ID: namespace, }) } return result, nil }). WithHintFunc(func(ctx context.Context, value []string, convertedValue any) (string, inspectionmetadata.ParameterHintType, error) { namespaces := coretask.GetTaskResult(ctx, googlecloudk8scommon_contract.AutocompleteNamespacesTaskID.Ref()) if len(namespaces.Values) > maxNamespaceFilterOptions { return fmt.Sprintf("Some namespaces are not shown on the suggestion list because the number of namespaces is %d, which is more than %d.", len(namespaces.Values), maxNamespaceFilterOptions), inspectionmetadata.Warning, nil } return "", inspectionmetadata.None, nil }). WithValidator(func(ctx context.Context, value []string) (string, error) { setFilterStr := strings.Join(value, " ") result, err := gcpqueryutil.ParseSetFilter(setFilterStr, inputNamespacesAliasMap, true, true, true) if err != nil { return "", err } return result.ValidationError, nil }). WithConverter(func(ctx context.Context, value []string) (*gcpqueryutil.SetFilterParseResult, error) { setFilterStr := strings.Join(value, " ") result, err := gcpqueryutil.ParseSetFilter(setFilterStr, inputNamespacesAliasMap, true, true, true) if err != nil { return nil, err } return result, nil }). Build()
InputContainerQueryNamespaceFilterTask is a form task that allows users to specify which namespaces to query for container logs.
var InputContainerQueryPodNamesFilterMask = formtask.NewSetFormTaskBuilder(googlecloudlogk8scontainer_contract.InputContainerQueryPodNamesTaskID, priorityForContainerGroup+2000, "Pod names(Container logs)"). WithDependencies([]taskid.UntypedTaskReference{googlecloudk8scommon_contract.AutocompletePodNamesTaskID.Ref()}). WithDefaultValueConstant([]string{"@any"}, true). WithAllowAddAll(false). WithAllowRemoveAll(false). WithAllowCustomValue(true). WithDescription(`Container logs tend to be a lot and take very long time to query. Specify the space splitted pod names lists to query container logs only in the specific pods. This parameter is evaluated as the partial match not the perfect match. You can use the prefix of the pod names.`). WithOptionsFunc(func(ctx context.Context, value []string) ([]inspectionmetadata.SetParameterFormFieldOptionItem, error) { result := []inspectionmetadata.SetParameterFormFieldOptionItem{} podNames := coretask.GetTaskResult(ctx, googlecloudk8scommon_contract.AutocompletePodNamesTaskID.Ref()) result = append(result, inspectionmetadata.SetParameterFormFieldOptionItem{ ID: "@any", Description: "[Alias] An alias matches any pod names.", }) for i, podName := range podNames.Values { if i >= maxPodNameFilterOptions { break } result = append(result, inspectionmetadata.SetParameterFormFieldOptionItem{ ID: podName, }) } return result, nil }). WithHintFunc(func(ctx context.Context, value []string, convertedValue any) (string, inspectionmetadata.ParameterHintType, error) { podNames := coretask.GetTaskResult(ctx, googlecloudk8scommon_contract.AutocompletePodNamesTaskID.Ref()) if len(podNames.Values) > maxPodNameFilterOptions { return fmt.Sprintf("Some pod names are not shown on the suggestion list because the number of pod names is %d, which is more than %d.", len(podNames.Values), maxPodNameFilterOptions), inspectionmetadata.Warning, nil } return "", inspectionmetadata.None, nil }). WithValidator(func(ctx context.Context, value []string) (string, error) { setFilterStr := strings.Join(value, " ") result, err := gcpqueryutil.ParseSetFilter(setFilterStr, inputPodNamesAliasMap, true, true, true) if err != nil { return "", err } return result.ValidationError, nil }). WithConverter(func(ctx context.Context, value []string) (*gcpqueryutil.SetFilterParseResult, error) { setFilterStr := strings.Join(value, " ") result, err := gcpqueryutil.ParseSetFilter(setFilterStr, inputPodNamesAliasMap, true, true, true) if err != nil { return nil, err } return result, nil }). Build()
InputContainerQueryPodNamesFilterMask is a form task that allows users to specify which pod names to query for container logs.
var ListLogEntriesTask = googlecloudcommon_contract.NewListLogEntriesTask(&containerListLogEntriesTaskSetting{})
var LogGrouperTask = inspectiontaskbase.NewLogGrouperTask(googlecloudlogk8scontainer_contract.LogGrouperTaskID, googlecloudlogk8scontainer_contract.FieldSetReaderTaskID.Ref(), func(ctx context.Context, l *log.Log) string { containerFields, err := log.GetFieldSet(l, &googlecloudlogk8scontainer_contract.K8sContainerLogFieldSet{}) if err != nil { return "unknown" } return containerFields.GroupKey() })
LogGrouperTask groups logs by associated Pod path.
var LogIngesterTask = inspectiontaskbase.NewLogIngesterTask( googlecloudlogk8scontainer_contract.LogIngesterTaskID, &containerLogIngester{}, )
LogIngesterTask is the task that ingests log metadata into KHI v6 builder.
var LogToTimelineMapperTask = inspectiontaskbase.NewLogToTimelineMapperTask[struct{}]( googlecloudlogk8scontainer_contract.LogToTimelineMapperTaskID, &containerLogLogToTimelineMapper{}, )
LogToTimelineMapperTask creates a task that modifies the KHI v6 TimelineRegistry.
var PodPhaseTimelineMapperTask = inspectiontaskbase.NewLogToTimelineMapperTask[*containerLogPodPhaseMapperState]( googlecloudlogk8scontainer_contract.PodPhaseTimelineMapperTaskID, &containerLogPodPhaseTimelineMapper{}, )
PodPhaseTimelineMapperTask maps container logs to Pod phase timelines.
var TailTask = inspectiontaskbase.NewInspectionTask( googlecloudlogk8scontainer_contract.TailTaskID, []taskid.UntypedTaskReference{ googlecloudlogk8scontainer_contract.LogToTimelineMapperTaskID.Ref(), googlecloudlogk8scontainer_contract.PodPhaseTimelineMapperTaskID.Ref(), }, func(ctx context.Context, taskMode inspectioncore_contract.InspectionTaskModeType) (struct{}, error) { return struct{}{}, nil }, inspectioncore_contract.FeatureTaskLabel( "Kubernetes Container Logs", "Gather stdout/stderr logs of containers to visualize application runtime behaviors under associated Pod timelines. Note: The log volume can be very large if the cluster contains many Pods.", 4000, false, ), )
TailTask is a nop task that depends on all container log mappers.
Functions ¶
func GenerateK8sContainerQuery ¶
func GenerateK8sContainerQuery(cluster googlecloudk8scommon_contract.GoogleCloudClusterIdentity, namespacesFilter *gcpqueryutil.SetFilterParseResult, podNamesFilter *gcpqueryutil.SetFilterParseResult) string
GenerateK8sContainerQuery generates a Cloud Logging query for Kubernetes container logs.
func Register ¶
func Register(registry coreinspection.InspectionTaskRegistry) error
Register registers all googlecloudlogk8scontainer inspection tasks to the registry.
Types ¶
This section is empty.