metrics

package
v0.0.0-...-8ce2061 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpenshiftPtpInterfaceRole = "openshift_ptp_interface_role"
	OpenshiftPtpClockState    = "openshift_ptp_clock_state"
	OpenshiftPtpOffsetNs      = "openshift_ptp_offset_ns"
	OpenshiftPtpThreshold     = "openshift_ptp_threshold"

	MaxOffsetDefaultNs = 100
	MinOffsetDefaultNs = -100
)
View Source
const (
	MetricRolePassiveString = "PASSIVE"
	MetricRoleSlaveString   = "SLAVE"
	MetricRoleMasterString  = "MASTER"
	MetricRoleFaultyString  = "FAULTY"
	MetricRoleUnknownString = "UNKNOWN"
)
View Source
const (
	MetricClockStateFreeRunString  = "FREERUN"
	MetricClockStateLockedString   = "LOCKED"
	MetricClockStateHoldOverString = "HOLDOVER"
)
View Source
const (
	PrometheusQueryRetries       = 10
	PrometheusQueryRetryInterval = 1 * time.Second
)

Variables

View Source
var MaxOffsetNs int
View Source
var MinOffsetNs int

Functions

func CheckClockRole

func CheckClockRole(role MetricRole, aIf string, nodeName *string) (err error)

This method checks the state of the clock with specified interface

func CheckClockRoleAndOffset

func CheckClockRoleAndOffset(ptpConfig *ptpv1.PtpConfig, label, nodeName *string) (err error)

Checks the accuracy of the clock defined by the ptpconfig passsed as a parameter: - checks the ptp offset to be less than MaxOffsetDefaultNs or any value passed by the user - check that the role of each interfaces in the ptpconfig matches the metric

func CheckClockState

func CheckClockState(state MetricClockState, aIf string, nodeName *string) (err error)

func GetCadvisorScrapeInterval

func GetCadvisorScrapeInterval() (int, error)

GetCadvisorScrapeInterval returns the current scrape internval (in secs) of cadvisor target configured in kubelet's prometheus ServiceMonitor.

func GetPrometheusPod

func GetPrometheusPod() (*corev1.Pod, error)

GetPrometheusPod is a helper function that returns the first pod of the prometheus statefulset.

func GetPrometheusResultFloatValue

func GetPrometheusResultFloatValue(promValue []interface{}) (value float64, tsMillis int64, err error)

GetPrometheusResultFloatValue returns the float value and timestamp from a prometheus value vector. The value is a vector with [ float, string ], where the timestamp is the float datum (in seconds) and the strings hold the actual, like in: [ 1674137739.625, "0.0015089738179757707" ]

func GetPtpOffeset

func GetPtpOffeset(aIf string, nodeName *string) (metric int, err error)

func InitEnvIntParamConfig

func InitEnvIntParamConfig(envString string, defaultInt int, param *int) error

gets the user configured maximum offset in nanoseconds

func RunPrometheusQuery

func RunPrometheusQuery(prometheusPod *corev1.Pod, query string, response *PrometheusQueryResponse) error

RunPrometheusQuery runs a prometheus query in a prometheus pod and unmarshals the response in a given struct. Fails if the curl command failed, the prometheus response is not a "success" or it cannot be unmarshaled.

func RunPrometheusQueryWithRetries

func RunPrometheusQueryWithRetries(prometheusPod *corev1.Pod, query string, rateTimeWindow time.Duration, retries int, retryInterval time.Duration, response *PrometheusQueryResponse,
	checkerFunc func(response *PrometheusQueryResponse) bool) error

RunPrometheusQueryWithRetries runs RunPrometheusQuery but retries in case of failure, waiting retryInterval perdiod before the next attempt.

Types

type MetricClockState

type MetricClockState int

type and display for OpenshiftPtpClockState metric. Values: 0 = FREERUN, 1 = LOCKED, 2 = HOLDOVER

const (
	MetricClockStateFreeRun MetricClockState = iota
	MetricClockStateLocked
	MetricClockStateHoldOver
)

func (MetricClockState) String

func (role MetricClockState) String() string

Stringer for MetricClockState

type MetricRole

type MetricRole int

type and display for OpenshiftPtpInterfaceRole metric. Values: 0 = PASSIVE, 1 = SLAVE, 2 = MASTER, 3 = FAULTY, 4 = UNKNOWN

const (
	MetricRolePassive MetricRole = iota
	MetricRoleSlave
	MetricRoleMaster
	MetricRoleFaulty
	MetricRoleUnknown
)

func (MetricRole) String

func (role MetricRole) String() string

Stringer for MetricRole

type PrometheusQueryResponse

type PrometheusQueryResponse struct {
	Status string `json:"status"`
	Error  string `json:"error"`
	Data   struct {
		ResultType string      `json:"resultType"`
		Result     interface{} `json:"result"`
	} `json:"data"`
}

type PrometheusVectorResult

type PrometheusVectorResult []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