commons

package
v1.17.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	METRIC_LABEL_CLUSTER_NAME   = "cluster_name"
	METRIC_LABEL_SERVICE        = "service"
	METRIC_LABEL_NS             = "ns"
	METRIC_LABEL_SET            = "set"
	METRIC_LABEL_LE             = "le"
	METRIC_LABEL_DC_NAME        = "dc"
	METRIC_LABEL_INDEX          = "index"
	METRIC_LABEL_SINDEX         = "sindex"
	METRIC_LABEL_STORAGE_ENGINE = "storage_engine"
	METRIC_LABEL_USER           = "user"
)

below constant represent the labels we send along with metrics to Prometheus or something

View Source
const (
	STORAGE_ENGINE = "storage-engine"
	INDEX_TYPE     = "index-type"
	SINDEX_TYPE    = "sindex-type"
)

constants used to identify type of metrics

View Source
const (
	METRIC_LABEL_DEVICE      = "device"
	METRIC_LABEL_MAJOR       = "major_version"
	METRIC_LABEL_MINOR       = "minor_version"
	METRIC_LABEL_SERIAL      = "serial"
	METRIC_LABEL_MOUNT_POINT = "mountpoint"
	METRIC_LABEL_FSTYPE      = "fstype"
	METRIC_LABEL_CPU         = "cpu"
	METRIC_LABEL_CPU_MODE    = "mode"
)
View Source
const (
	TESTS_DEFAULT_CONFIG_FILE     = "tests_data/default_ape.toml"
	TESTS_USERS_CONFIG_FILE       = "tests_data/users_ape.toml"
	TESTS_MOCK_CONFIG_FILE        = "tests_data/mock_ape.toml"
	TESTS_DEFAULT_GAUGE_LIST_FILE = "configs/gauge_stats_list.toml"
)

Variables

View Source
var (
	PROC_PATH         = procfs.DefaultMountPoint
	SYS_PATH          = "/sys"
	ROOTFS_PATH       = "/"
	UDEV_DATA_PATH    = "/run/udev/data"
	NET_STAT_PATH     = "net/netstat"
	NET_DEV_STAT_PATH = "/proc/net/dev"
)
View Source
var ProcessExit chan bool

OS Signal handling logic

Functions

func GetConfigfileLocation

func GetConfigfileLocation(filename string) string

func GetDefaultGaugeListFilename

func GetDefaultGaugeListFilename() string

func GetExecutorsConfigFile

func GetExecutorsConfigFile(filename string) string

func GetExporterBaseFolder

func GetExporterBaseFolder() string

func GetFullHost

func GetFullHost() string

func GetPromMockResultsFile

func GetPromMockResultsFile(filename string) string

func GetSecret

func GetSecret(secretConfig string) ([]byte, error)

Get secret secretConfig can be one of the following, 1. "<secret>" (secret directly) 2. "file:<file-that-contains-secret>" (file containing secret) 3. "env:<environment-variable-that-contains-secret>" (environment variable containing secret) 4. "env-b64:<environment-variable-that-contains-base64-encoded-secret>" (environment variable containing base64 encoded secret) 5. "b64:<base64-encoded-secret>" (base64 encoded secret)

func GetValueFromBase64

func GetValueFromBase64(b64Value string) ([]byte, error)

Get decoded base64 value

func GetValueFromBase64EnvVar

func GetValueFromBase64EnvVar(envVar string) ([]byte, error)

Get decoded base64 value from environment variable

func GetWatchersConfigFile

func GetWatchersConfigFile(filename string) string

func GetWatchersMockResultsFile

func GetWatchersMockResultsFile(filename string) string

func HandleSignals

func HandleSignals()

func InitConfigurations

func InitConfigurations(config_filename string)

func LoadCACert

func LoadCACert(certConfig string) (*x509.CertPool, error)

loadCACert returns CA set of certificates (cert pool) reads CA certificate based on the certConfig and adds it to the pool

func LoadServerCertAndKey

func LoadServerCertAndKey(certConfig, keyConfig, keyPassConfig string) ([]tls.Certificate, error)

loadServerCertAndKey reads server certificate and associated key file based on certConfig and keyConfig returns parsed server certificate if the private key is encrypted, it will be decrypted using key file passphrase

func LoadServerOrClientCertificates

func LoadServerOrClientCertificates() (*x509.CertPool, []tls.Certificate)

func ParseStats

func ParseStats(s, sep string) map[string]string

Utility functions

func SanitizeUTF8

func SanitizeUTF8(lv string) string

func TryConvert

func TryConvert(s string) (float64, error)

func ValidateBasicAuth

func ValidateBasicAuth(r *http.Request, username string, password string) bool

Check HTTP Basic Authentication. Validate username, password from the http request against the configured values.

Types

type ContextType

type ContextType string

used to define context of stat types (like namespace, set, xdr etc.,)

const (
	CTX_USERS      ContextType = "users"
	CTX_NAMESPACE  ContextType = "namespace"
	CTX_NODE_STATS ContextType = "node_stats"
	CTX_SETS       ContextType = "sets"
	CTX_SINDEX     ContextType = "sindex"
	CTX_XDR        ContextType = "xdr"
	CTX_LATENCIES  ContextType = "latencies"
)
const (
	CTX_SYSINFO_MEMORY_STATS     ContextType = "sysinfo_memory_stats"
	CTX_SYSINFO_DISK_STATS       ContextType = "sysinfo_disk_stats"
	CTX_SYSINFO_FILESYSTEM_STATS ContextType = "sysinfo_filesystem_stats"
	CTX_SYSINFO_CPU_STATS        ContextType = "sysinfo_cpu"
	CTX_SYSINFO_NET_STATS        ContextType = "sysinfo_netstat"
	CTX_SYSINFO_NET_DEV_STATS    ContextType = "sysinfo_net_dev"
	CTX_SYSINFO_NETWORK_STATS    ContextType = "sysinfo_network"
	CTX_SYSINFO_FILEFD_STATS     ContextType = "sysinfo_filefd"
	CTX_SYSINFO_VM_STATS         ContextType = "sysinfo_vmstat"
)

type MetricType

type MetricType byte
const (
	MetricTypeGauge   MetricType = 'G'
	MetricTypeCounter MetricType = 'C'
)

Jump to

Keyboard shortcuts

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