monitoring

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 14, 2025 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvMonitoringEnabled = envPrefix + "ENABLED"

	// EnvPrometheusEndpoint is the Prometheus endpoint to use
	EnvPrometheusEndpoint = envPrefix + "PROMETHEUS_ENDPOINT"

	// EnvPollingInterval is the polling interval to run the GPU metrics poller
	EnvPollingInterval = envPrefix + "POLLING_INTERVAL"
)

Environment variable keys.

View Source
const (
	MetricsComponentName = "KaiwoResourceMonitor"
)

Variables

This section is empty.

Functions

func GetKaiwoWorkload

func GetKaiwoWorkload(ctx context.Context, k8sClient client.Client, name string, namespace string, workloadType string) (common.KaiwoWorkload, error)

func GetKaiwoWorkloadFromPod

func GetKaiwoWorkloadFromPod(ctx context.Context, k8sClient client.Client, namespace string, podName string) (common.KaiwoWorkload, error)

func IsMetricsMonitoringEnabled

func IsMetricsMonitoringEnabled() bool

Types

type MetricsWatcher

type MetricsWatcher struct {
	// contains filtered or unexported fields
}

MetricsWatcher polls Prometheus and updates Kaiwo statuses.

func NewMetricsWatcher

func NewMetricsWatcher(
	endpoint string,
	pollInterval time.Duration,
	k8sClient client.Client,
	scheme *runtime.Scheme,
	recorder record.EventRecorder,
) (*MetricsWatcher, error)

NewMetricsWatcher creates a watcher; check template.Err on parse.

func NewMetricsWatcherFromEnv

func NewMetricsWatcherFromEnv(
	k8sClient client.Client,
	scheme *runtime.Scheme,
	recorder record.EventRecorder,
) (*MetricsWatcher, error)

NewMetricsWatcherFromEnv constructs a MetricsWatcher from environment variables.

func (*MetricsWatcher) Start

func (m *MetricsWatcher) Start(ctx context.Context) error

Start runs the periodic poll loop until ctx.Done().

type PrometheusResponse

type PrometheusResponse struct {
	Status string `json:"status"`
	Data   struct {
		ResultType string             `json:"resultType"`
		Result     []PrometheusResult `json:"result"`
	} `json:"data"`
}

func QueryPrometheusMetrics

func QueryPrometheusMetrics(ctx context.Context, endpoint string, query string) (*PrometheusResponse, error)

type PrometheusResult

type PrometheusResult struct {
	Metric map[string]string `json:"metric"`
	Value  []interface{}     `json:"value"`
}

Jump to

Keyboard shortcuts

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