Documentation
¶
Overview ¶
Package models defines different models used in stats
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdminUser ¶
type AdminUser struct {
User
}
AdminUser table. We use same struct as `User` and where ever we need to use `AdminUser` struct, we must simply use `User` struct. The struct is defined here only for consistency across structs to DB table names.
type Allocation ¶
type Allocation = Generic
Allocation is a type alias to Generic that stores allocation data of compute units.
type CLIConfig ¶
type CLIConfig struct {
Path string `yaml:"path"`
EnvVars map[string]string `yaml:"environment_variables"`
}
CLIConfig contains the configuration of CLI client.
type Cluster ¶
type Cluster struct {
ID string `json:"id" sql:"cluster_id" yaml:"id"`
Manager string `json:"manager" sql:"resource_manager" yaml:"manager"`
Web WebConfig `json:"-" yaml:"web"`
CLI CLIConfig `json:"-" yaml:"cli"`
Updaters []string `json:"-" yaml:"updaters"`
Extra yaml.Node `json:"-" yaml:"extra_config"`
}
Cluster contains the configuration of the given resource manager.
type ClusterProjects ¶
ClusterProjects is the container for the projects for a given cluster.
type ClusterUnits ¶
ClusterUnits is the container for the units and config of a given cluster.
type ClusterUsers ¶
ClusterUsers is the container for the users for a given cluster.
type DailyUsage ¶
type DailyUsage struct {
Usage
}
DailyUsage statistics of each project/tenant/namespace.
func (DailyUsage) TableName ¶
func (DailyUsage) TableName() string
TableName returns the table which usage stats are stored into.
type Generic ¶
Generic is map to store any mixed data types. Only string and int are supported. Any number will be converted into int64. Ref: https://go.dev/play/p/89ra6QgcZba, https://husobee.github.io/golang/database/2015/06/12/scanner-valuer.html, https://gist.github.com/jmoiron/6979540
type JSONFloat ¶
type JSONFloat float64
JSONFloat is a custom float64 that can handle Inf and NaN during JSON (un)marshalling.
func (JSONFloat) MarshalJSON ¶
MarshalJSON marshals JSONFloat into byte array The custom marshal interface will truncate the float64 to 8 decimals as storing all decimals will bring a very low added value and high DB storage.
func (*JSONFloat) UnmarshalJSON ¶
UnmarshalJSON unmarshals byte array into JSONFloat.
type Key ¶
type Key struct {
Name string `json:"name" sql:"name" sqlitetype:"text"` // Name of the metric key
}
Key represents arbritrary keys used in metric maps.
type List ¶
type List []any
List is a generic type to store slices. Only string and int slices are supported. Any number will be converted into int64.
type MetricMap ¶
MetricMap is a type alias to Generic that stores arbritrary metrics as a map.
type Project ¶
type Project struct {
ID int64 `example:"1" json:"-" sql:"id" sqlitetype:"integer not null primary key"`
UID string `example:"1000" json:"uid,omitempty" sql:"uid" sqlitetype:"text"` // Unique identifier of the project provided by cluster
ClusterID string `example:"slurm-0" json:"cluster_id" sql:"cluster_id" sqlitetype:"text"` // Identifier of the resource manager that owns project. It is used to differentiate multiple clusters of same resource manager.
ResourceManager string `example:"slurm" json:"resource_manager" sql:"resource_manager" sqlitetype:"text"` // Name of the resource manager that owns project. Eg slurm, openstack, kubernetes, etc
Name string `example:"prj1" json:"name" sql:"name" sqlitetype:"text"` // Name of the project
Users List `` // List of users of the project
/* 135-byte string literal not displayed */
Tags List `` // List of meta data tags of the project
/* 135-byte string literal not displayed */
LastUpdatedAt string `json:"-" sql:"last_updated_at" sqlitetype:"text"` // Last Updated time
}
Project is the container for a given account/tenant/namespace of cluster.
type Stat ¶
type Stat struct {
ClusterID string `example:"slurm-0" json:"cluster_id" sql:"cluster_id" sqlitetype:"text"` // Identifier of the resource manager that owns compute unit. It is used to differentiate multiple clusters of same resource manager.
ResourceManager string `example:"slurm" json:"resource_manager" sql:"resource_manager" sqlitetype:"text"` // Name of the resource manager that owns project. Eg slurm, openstack, kubernetes, etc
NumUnits int64 `example:"1000" json:"num_units" sql:"num_units" sqlitetype:"integer"` // Number of active and terminated units
NumInActiveUnits int64 `example:"200" json:"num_inactive_units" sql:"num_inactive_units" sqlitetype:"integer"` // Number of inactive units that are in terminated/cancelled/error state
NumActiveUnits int64 `example:"800" json:"num_active_units" sql:"num_active_units" sqlitetype:"integer"` // Number of active units that are in running state
NumProjects int64 `example:"200" json:"num_projects" sql:"num_projects" sqlitetype:"integer"` // Number of projects
NumUsers int64 `example:"500" json:"num_users" sql:"num_users" sqlitetype:"integer"` // Number of users
}
Stat represents high level statistics of each cluster.
type Unit ¶
type Unit struct {
ID int64 `` /* 187-byte string literal not displayed */
ClusterID string `` // Identifier of the resource manager that owns compute unit. It is used to differentiate multiple clusters of same resource manager.
/* 205-byte string literal not displayed */
ResourceManager string `` // Name of the resource manager that owns compute unit. Eg slurm, openstack, kubernetes, etc
/* 205-byte string literal not displayed */
UUID string `` // Unique identifier of unit. It can be Job ID for batch jobs, UUID for pods in k8s or VMs in Openstack
/* 205-byte string literal not displayed */
Name string `` // Name of compute unit
/* 205-byte string literal not displayed */
Project string `` // Account in batch systems, Tenant in Openstack, Namespace in k8s
/* 205-byte string literal not displayed */
Group string `` // User group
/* 205-byte string literal not displayed */
User string `` // Username
/* 205-byte string literal not displayed */
CreatedAt string `` // Creation time
/* 205-byte string literal not displayed */
StartedAt string `` // Start time
/* 205-byte string literal not displayed */
EndedAt string `` // End time
/* 205-byte string literal not displayed */
CreatedAtTS int64 `` // Creation timestamp
/* 208-byte string literal not displayed */
StartedAtTS int64 `` // Start timestamp
/* 208-byte string literal not displayed */
EndedAtTS int64 `` // End timestamp
/* 208-byte string literal not displayed */
Elapsed string `` // Human readable total elapsed time string
/* 205-byte string literal not displayed */
State string `` // Current state of unit
/* 205-byte string literal not displayed */
Allocation Allocation `` // Allocation map of unit. Only string and int64 values are supported in map
/* 236-byte string literal not displayed */
TotalTime MetricMap `` // Different types of times in seconds consumed by the unit. This map contains at minimum `walltime`, `alloc_cputime`, `alloc_cpumemtime`, `alloc_gputime` and `alloc_gpumem_time` keys.
/* 236-byte string literal not displayed */
AveCPUUsage MetricMap `` // Average CPU usage(s) during lifetime of unit
/* 236-byte string literal not displayed */
AveCPUMemUsage MetricMap `` // Average CPU memory usage(s) during lifetime of unit
/* 236-byte string literal not displayed */
TotalCPUEnergyUsage MetricMap `` // Total CPU energy usage(s) in kWh during lifetime of unit
/* 236-byte string literal not displayed */
TotalCPUEmissions MetricMap `` // Total CPU emissions from source(s) in grams during lifetime of unit
/* 236-byte string literal not displayed */
AveGPUUsage MetricMap `` // Average GPU usage(s) during lifetime of unit
/* 236-byte string literal not displayed */
AveGPUMemUsage MetricMap `` // Average GPU memory usage(s) during lifetime of unit
/* 236-byte string literal not displayed */
TotalGPUEnergyUsage MetricMap `` // Total GPU energy usage(s) in kWh during lifetime of unit
/* 236-byte string literal not displayed */
TotalGPUEmissions MetricMap `` // Total GPU emissions from source(s) in grams during lifetime of unit
/* 236-byte string literal not displayed */
TotalIOWriteStats MetricMap `` // Total IO write statistics during lifetime of unit
/* 236-byte string literal not displayed */
TotalIOReadStats MetricMap `` // Total IO read statistics during lifetime of unit
/* 236-byte string literal not displayed */
TotalIngressStats MetricMap `` // Total Ingress statistics of unit
/* 236-byte string literal not displayed */
TotalEgressStats MetricMap `` // Total Outgress statistics of unit
/* 236-byte string literal not displayed */
Tags Tag `` // A map to store generic info. String and int64 are valid value types of map
/* 236-byte string literal not displayed */
Ignore int `` // Whether to ignore unit
/* 166-byte string literal not displayed */
NumUpdates int64 `` // Number of updates. This is used internally to update aggregate metrics
/* 166-byte string literal not displayed */
LastUpdatedAt string `` // Last updated time. It can be used to clean up DB
/* 163-byte string literal not displayed */
}
Unit is an abstract compute unit that can mean Job (batchjobs), VM (cloud) or Pod (k8s).
type Usage ¶
type Usage struct {
ID int64 `` /* 187-byte string literal not displayed */
ClusterID string `` // Identifier of the resource manager that owns compute unit. It is used to differentiate multiple clusters of same resource manager.
/* 205-byte string literal not displayed */
ResourceManager string `` // Name of the resource manager that owns project. Eg slurm, openstack, kubernetes, etc
/* 205-byte string literal not displayed */
NumUnits int64 `` // Number of consumed units
/* 208-byte string literal not displayed */
Project string `` // Account in batch systems, Tenant in Openstack, Namespace in k8s
/* 205-byte string literal not displayed */
Group string `` // User group
/* 205-byte string literal not displayed */
User string `` // Username
/* 205-byte string literal not displayed */
LastUpdatedAt string `` // Last updated time. It can be used to clean up DB
/* 163-byte string literal not displayed */
TotalTime MetricMap `` // Different times in seconds consumed by the unit. This map must contain `walltime`, `alloc_cputime`, `alloc_cpumemtime`, `alloc_gputime` and `alloc_gpumem_time` keys.
/* 236-byte string literal not displayed */
AveCPUUsage MetricMap `` // Average CPU usage(s) during lifetime of project
/* 236-byte string literal not displayed */
AveCPUMemUsage MetricMap `` // Average CPU memory usage(s) during lifetime of project
/* 236-byte string literal not displayed */
TotalCPUEnergyUsage MetricMap `` // Total CPU energy usage(s) in kWh during lifetime of project
/* 236-byte string literal not displayed */
TotalCPUEmissions MetricMap `` // Total CPU emissions from source(s) in grams during lifetime of project
/* 236-byte string literal not displayed */
AveGPUUsage MetricMap `` // Average GPU usage(s) during lifetime of project
/* 236-byte string literal not displayed */
AveGPUMemUsage MetricMap `` // Average GPU memory usage(s) during lifetime of project
/* 236-byte string literal not displayed */
TotalGPUEnergyUsage MetricMap `` // Total GPU energy usage(s) in kWh during lifetime of project
/* 236-byte string literal not displayed */
TotalGPUEmissions MetricMap `` // Total GPU emissions from source(s) in grams during lifetime of project
/* 236-byte string literal not displayed */
TotalIOWriteStats MetricMap `` // Total IO write statistics during lifetime of unit
/* 236-byte string literal not displayed */
TotalIOReadStats MetricMap `` // Total IO read statistics during lifetime of unit
/* 236-byte string literal not displayed */
TotalIngressStats MetricMap `` // Total Ingress statistics of unit
/* 236-byte string literal not displayed */
TotalEgressStats MetricMap `` // Total Egress statistics of unit
/* 236-byte string literal not displayed */
NumUpdates int64 `` // Number of updates. This is used internally to update aggregate metrics
/* 163-byte string literal not displayed */
}
Usage statistics of each project/tenant/namespace.
type User ¶
type User struct {
ID int64 `example:"1" json:"-" sql:"id" sqlitetype:"integer not null primary key"`
UID string `example:"1000" json:"uid,omitempty" sql:"uid" sqlitetype:"text"` // Unique identifier of the user provided by cluster
ClusterID string `example:"slurm-0" json:"cluster_id" sql:"cluster_id" sqlitetype:"text"` // Identifier of the resource manager that owns user. It is used to differentiate multiple clusters of same resource manager.
ResourceManager string `example:"slurm" json:"resource_manager,omitempty" sql:"resource_manager" sqlitetype:"text"` // Name of the resource manager that owns user. Eg slurm, openstack, kubernetes, etc
Name string `example:"usr1" json:"name" sql:"name" sqlitetype:"text"` // Name of the user
Projects List `` // List of projects of the user
/* 145-byte string literal not displayed */
Tags List `` // List of meta data tags of the user
/* 145-byte string literal not displayed */
LastUpdatedAt string `json:"-" sql:"last_updated_at" sqlitetype:"text"` // Last Updated time
}
User is the container for a given user of cluster.
type WebConfig ¶
type WebConfig struct {
URL string `yaml:"url"`
HTTPClientConfig config.HTTPClientConfig `yaml:",inline"`
}
WebConfig contains the client related configuration of a REST API server.
func (*WebConfig) SetDirectory ¶
SetDirectory joins any relative file paths with dir.