healthchecks

package
v0.0.0-...-5849371 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceDisabled              = "SERVICE_DISABLED"
	AccessTokenScopeInsufficient = "ACCESS_TOKEN_SCOPE_INSUFFICIENT"
	IamPermissionDenied          = "IAM_PERMISSION_DENIED"
	MaxMonitoringPingRetries     = 1
)
View Source
const (
	Api        = "API"
	Connection = "CONNECTION"
	Generic    = "GENERIC"
	Port       = "PORT"
	Permission = "PERMISSION"
	Runtime    = "RUNTIME"
)

Error classification

View Source
const MaxRequestElapsedTime = 30 * time.Second

Variables

View Source
var (
	FbMetricsPortErr = HealthCheckError{
		Code:         "FbMetricsPortErr",
		Class:        Port,
		Message:      "Port 20202 needed for Ops Agent self metrics is unavailable.",
		Action:       "Verify that port 20202 is open.",
		ResourceLink: "https://cloud.google.com/logging/docs/agent/ops-agent/troubleshooting",
		IsFatal:      true,
	}
	OtelMetricsPortErr = HealthCheckError{
		Code:         "OtelMetricsPortErr",
		Class:        Port,
		Message:      "Port 20201 needed for Ops Agent self metrics is unavailable.",
		Action:       "Verify that port 20201 is open.",
		ResourceLink: "https://cloud.google.com/monitoring/agent/ops-agent/troubleshooting",
		IsFatal:      true,
	}
	LogApiConnErr = HealthCheckError{
		Code:         "LogApiConnErr",
		Class:        Connection,
		Message:      "Request to Logging API failed.",
		Action:       "Check your internet connection and firewall rules.",
		ResourceLink: "https://cloud.google.com/logging/docs/agent/ops-agent/troubleshooting",
		IsFatal:      true,
	}
	MonApiConnErr = HealthCheckError{
		Code:         "MonApiConnErr",
		Class:        Connection,
		Message:      "Request to Monitoring API failed.",
		Action:       "Check your internet connection and firewall rules.",
		ResourceLink: "https://cloud.google.com/monitoring/agent/ops-agent/troubleshooting",
		IsFatal:      true,
	}
	PacApiConnErr = HealthCheckError{
		Code:         "PacApiConnErr",
		Class:        Connection,
		Message:      "Request to packages.cloud.google.com failed.",
		Action:       "Check your internet connection and firewall rules.",
		ResourceLink: "https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/troubleshoot-run-ingest#network-issues",
		IsFatal:      false,
	}
	DLApiConnErr = HealthCheckError{
		Code:         "DLApiConnErr",
		Class:        Connection,
		Message:      "Request to dl.google.com failed",
		Action:       "Check your internet connection and firewall rules.",
		ResourceLink: "https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/troubleshoot-run-ingest#network-issues",
		IsFatal:      false,
	}
	MetaApiConnErr = HealthCheckError{
		Code:         "MetaApiConnErr",
		Class:        Connection,
		Message:      "Request to GCE Metadata server failed",
		Action:       "Check your internet connection and firewall rules.",
		ResourceLink: "https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/troubleshoot-run-ingest#network-issues",
		IsFatal:      true,
	}
	LogApiScopeErr = HealthCheckError{
		Code:         "LogApiScopeErr",
		Class:        Permission,
		Message:      "VM is missing the https://www.googleapis.com/auth/logging.write scope.",
		Action:       "Add the https://www.googleapis.com/auth/logging.write scope to the Compute Engine VM.",
		ResourceLink: "https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/authorization",
		IsFatal:      true,
	}
	MonApiScopeErr = HealthCheckError{
		Code:         "MonApiScopeErr",
		Class:        Permission,
		Message:      "VM is missing the https://www.googleapis.com/auth/monitoring.write scope.",
		Action:       "Add the https://www.googleapis.com/auth/monitoring.write scope to the Compute Engine VM.",
		ResourceLink: "https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/authorization",
		IsFatal:      true,
	}
	LogApiPermissionErr = HealthCheckError{
		Code:         "LogApiPermissionErr",
		Class:        Permission,
		Message:      "Service account is missing the roles/logging.logWriter role.",
		Action:       "Add the roles/logging.logWriter role to the Google Cloud service account.",
		ResourceLink: "https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/authorization#create-service-account",
		IsFatal:      true,
	}
	MonApiPermissionErr = HealthCheckError{
		Code:         "MonApiPermissionErr",
		Class:        Permission,
		Message:      "Service account is missing the roles/monitoring.metricWriter role.",
		Action:       "Add the roles/monitoring.metricWriter role to the Google Cloud service account.",
		ResourceLink: "https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/authorization#create-service-account",
		IsFatal:      true,
	}
	LogApiDisabledErr = HealthCheckError{
		Code:         "LogApiDisabledErr",
		Class:        Api,
		Message:      "The Logging API is disabled in the current Google Cloud project.",
		Action:       "Enable Logging API in the current Google Cloud project.",
		ResourceLink: "https://cloud.google.com/logging/docs/api/enable-api",
		IsFatal:      true,
	}
	MonApiDisabledErr = HealthCheckError{
		Code:         "MonApiDisabledErr",
		Class:        Api,
		Message:      "The Monitoring API is disabled in the current Google Cloud project.",
		Action:       "Enable Monitoring API in the current Google Cloud project.",
		ResourceLink: "https://cloud.google.com/monitoring/api/enable-api",
		IsFatal:      true,
	}
	LogApiUnauthenticatedErr = HealthCheckError{
		Code:         "LogApiUnauthenticatedErr",
		Class:        Api,
		Message:      "The current VM couldn't authenticate to the Logging API.",
		Action:       "Verify that your credential files, VM access scopes and permissions are set up correctly.",
		ResourceLink: "https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/authorization",
		IsFatal:      true,
	}
	MonApiUnauthenticatedErr = HealthCheckError{
		Code:         "MonApiUnauthenticatedErr",
		Class:        Api,
		Message:      "The current VM couldn't authenticate to the Monitoring API.",
		Action:       "Verify that your credential files, VM access scopes and permissions are set up correctly.",
		ResourceLink: "https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/authorization",
		IsFatal:      true,
	}
	LogPipelineErr = HealthCheckError{
		Code:         "LogPipelineErr",
		Class:        Runtime,
		Message:      "Ops Agent logging pipeline failed",
		Action:       "Refer to provided documentation link.",
		ResourceLink: "https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/troubleshoot-find-info",
		IsFatal:      true,
	}
	LogParseErr = HealthCheckError{
		Code:         "LogParseErr",
		Class:        Runtime,
		Message:      "Ops Agent failed to parse logs",
		Action:       "Refer to provided documentation link.",
		ResourceLink: "https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/troubleshoot-find-info",
		IsFatal:      false,
	}
	HcFailureErr = HealthCheckError{
		Code:         "HcFailureErr",
		Class:        Generic,
		Message:      "The Health Check encountered an internal error.",
		Action:       "Submit a support case from Google Cloud console.",
		ResourceLink: "https://cloud.google.com/logging/docs/support",
		IsFatal:      false,
	}
)
View Source
var FluentBitSelfLogTranslationList = []SelfLogTranslationEntry{
	{
		RegexMatch: `\[error\]\s\[lib\]\sbackend\sfailed`,
		Message:    singleErrorResultMessage(LogPipelineErr, "Runtime Check"),
		Code:       LogPipelineErr.Code,
	},
	{
		RegexMatch: `\[error\]\s\[parser\]\scannot\sparse`,
		Message:    singleErrorResultMessage(LogParseErr, "Runtime Check"),
		Code:       LogParseErr.Code,
	},
}

Functions

func CreateHealthChecksLogger

func CreateHealthChecksLogger(logDir string) logs.StructuredLogger

func LogHealthCheckResults

func LogHealthCheckResults(healthCheckResults []HealthCheckResult, logger logs.StructuredLogger)

Types

type APICheck

type APICheck struct{}

func (APICheck) Name

func (c APICheck) Name() string

func (APICheck) RunCheck

func (c APICheck) RunCheck(logger logs.StructuredLogger) error

type HealthCheck

type HealthCheck interface {
	Name() string
	RunCheck(logger logs.StructuredLogger) error
}

type HealthCheckError

type HealthCheckError struct {
	Code         string
	Class        string
	Message      string
	Action       string
	ResourceLink string
	IsFatal      bool
}

func (HealthCheckError) Error

func (e HealthCheckError) Error() string

type HealthCheckRegistry

type HealthCheckRegistry []HealthCheck

func HealthCheckRegistryFactory

func HealthCheckRegistryFactory() HealthCheckRegistry

func (HealthCheckRegistry) RunAllHealthChecks

func (r HealthCheckRegistry) RunAllHealthChecks(logger logs.StructuredLogger) []HealthCheckResult

type HealthCheckResult

type HealthCheckResult struct {
	Name string
	Err  error
}

func (HealthCheckResult) ErrorSlice

func (r HealthCheckResult) ErrorSlice() []error

func (HealthCheckResult) LogResult

func (r HealthCheckResult) LogResult(logger logs.StructuredLogger)

type MultiWrappedError

type MultiWrappedError interface {
	Unwrap() []error
}

Interface used to verify if an error implements `Unwrap() []error`. The resulting error from `errors.Join(errs ...error)` implements this interface. This error features were added in Go 1.20 release (https://tip.golang.org/doc/go1.20).

type NetworkCheck

type NetworkCheck struct{}

func (NetworkCheck) Name

func (c NetworkCheck) Name() string

func (NetworkCheck) RunCheck

func (c NetworkCheck) RunCheck(logger logs.StructuredLogger) error

type PortsCheck

type PortsCheck struct{}

func (PortsCheck) Name

func (c PortsCheck) Name() string

func (PortsCheck) RunCheck

func (c PortsCheck) RunCheck(logger logs.StructuredLogger) error

type SelfLogTranslationEntry

type SelfLogTranslationEntry struct {
	RegexMatch string
	Message    string
	Code       string
}

Jump to

Keyboard shortcuts

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