handlers

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: UPL-1.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const AlertmanagerTemplatesConfigMapPath = "spec.alertmanager.templatesConfigMap"

AlertmanagerTemplatesConfigMapPath for Alert Manager configMap.

View Source
const K8sPublicIPAddressLabel = "node.info/external.ipaddress"

K8sPublicIPAddressLabel label name for IP address.

View Source
const Layout = "2006-01-02T15-04-05"

Layout format of time stamp.

View Source
const LevelAll = 0

LevelAll is all log level.

View Source
const LevelDebug = 1

LevelDebug is debug log level.

View Source
const LevelError = 3

LevelError is error log level.

View Source
const LevelFatal = 4

LevelFatal is fatal log level.

View Source
const LevelInfo = 2

LevelInfo is info log level.

View Source
const LevelMax = LevelFatal

LevelMax is maximum log level.

View Source
const LevelMin = LevelAll

LevelMin is minimum log level.

View Source
const MaxBackupFiles = 10

MaxBackupFiles is max number of files for backup.

View Source
const MaxBackupHours = 48

MaxBackupHours is max hours for backup.

View Source
const PrometheusConfigFileName = "prometheus.yml"

PrometheusConfigFileName file name of Prometheus config file.

View Source
const PrometheusConfigMapPath = "spec.prometheus.configMap"

PrometheusConfigMapPath path for Prometheus configMap.

View Source
const PrometheusRulesConfigMapPath = "spec.prometheus.rulesConfigMap"

PrometheusRulesConfigMapPath path for Prometheus rules configMap.

View Source
const PrometheusRulesVersionsConfigMapPath = "spec.prometheus.rulesVersionsConfigMap"

PrometheusRulesVersionsConfigMapPath path for Prometheus rules versions configMap.

View Source
const PrometheusVersionsConfigMapPath = "spec.prometheus.versionsConfigMap"

PrometheusVersionsConfigMapPath path for Prometheus versions configMap.

View Source
const VMIGroup = "verrazzano.io"

VMIGroup group name for an instance resource.

View Source
const VMIMetadataNamePath = "metadata.name"

VMIMetadataNamePath path for metadata name.

View Source
const VMIPlural = "verrazzanomonitoringinstances"

VMIPlural plural name for an instance resource.

View Source
const VMIVersion = "v1"

VMIVersion version of instance resource.

Variables

View Source
var EndpointBackoffSchedule = wait.Backoff{
	Steps:    10,
	Duration: 3 * time.Second,
	Factor:   2.0,
	Jitter:   0.0,
}

EndpointBackoffSchedule is the schedule used for endpoint polling.

View Source
var ListenURL string

ListenURL Cirith listener URL

Functions

func Close

func Close(c io.Closer)

Close calls close on the given Closer, and catches and logs any errors. Useful to call deferred

func GetConfig

func GetConfig() *restgo.Config

GetConfig returns the config for the monitoring instance API

func GetHealthCheck

func GetHealthCheck(w http.ResponseWriter, r *http.Request)

GetHealthCheck is the /healthcheck router function.

func Retry

func Retry(schedule wait.Backoff, fn wait.ConditionFunc) error

Retry executes the provided function repeatedly, retrying until the function returns done = true, or exceeds the given timeout.

func Usage

func Usage(w http.ResponseWriter, _ *http.Request)

Usage returns the usage for the API.

func ValidateConfigMapKeyName

func ValidateConfigMapKeyName(keyName string) error

ValidateConfigMapKeyName validates a given configmap key.

func ValidatePrometheusRuleElements

func ValidatePrometheusRuleElements(g *gabs.Container) (bool, error)

ValidatePrometheusRuleElements does some basic validation on the rule file.

func ValidateVMIPrometheusElements

func ValidateVMIPrometheusElements(g *gabs.Container) (bool, error)

ValidateVMIPrometheusElements validates the Prometheus configuration.

func WaitForEndpointAvailable

func WaitForEndpointAvailable(action, myURL, host string, headers map[string]string, payload string, reqUserName string, reqPassword string) error

WaitForEndpointAvailable waits for the given endpoint to become available.

Types

type K8s

type K8s struct {
	RestClient restgo.Interface
	ClientSet  k8sgo.Interface
	Config     *restgo.Config
}

K8s struct representing kubernetes rest client & clientset

func NewK8s

func NewK8s(cfg *restgo.Config) (*K8s, error)

NewK8s returns a new K8s struct

func (*K8s) DeleteAlertmanagerTemplate

func (k *K8s) DeleteAlertmanagerTemplate(w http.ResponseWriter, r *http.Request)

DeleteAlertmanagerTemplate deletes a requested Alert Manager template file.

func (*K8s) DeletePrometheusRules

func (k *K8s) DeletePrometheusRules(w http.ResponseWriter, r *http.Request)

DeletePrometheusRules removes the requested current Alert Rules file. If the optional flag is included, delete all the rules saved backups too.

func (*K8s) GetAlertmanagerTemplate

func (k *K8s) GetAlertmanagerTemplate(w http.ResponseWriter, r *http.Request)

GetAlertmanagerTemplate returns a requested Alert Manager template file.

func (*K8s) GetAllAlertmanagerTemplatesFileNames

func (k *K8s) GetAllAlertmanagerTemplatesFileNames(w http.ResponseWriter, r *http.Request)

GetAllAlertmanagerTemplatesFileNames returns all Alert Manager template files.

func (*K8s) GetPrometheusConfig

func (k *K8s) GetPrometheusConfig(w http.ResponseWriter, r *http.Request)

GetPrometheusConfig returns the Prometheus configuration.

func (*K8s) GetPrometheusRuleNames

func (k *K8s) GetPrometheusRuleNames(w http.ResponseWriter, r *http.Request)

GetPrometheusRuleNames returns a JSON with names of all current Prometheus rules files.

func (*K8s) GetPrometheusRuleVersions

func (k *K8s) GetPrometheusRuleVersions(w http.ResponseWriter, r *http.Request)

GetPrometheusRuleVersions takes the user-provided rule file name and returns a JSON with all available versions of that file.

func (*K8s) GetPrometheusRules

func (k *K8s) GetPrometheusRules(w http.ResponseWriter, r *http.Request)

GetPrometheusRules returns the contents of the requested Alert Rules file. All rules files must end in suffix ".rules" so we can differentiate requests for current vs. saved versions.

func (*K8s) GetPrometheusVersions

func (k *K8s) GetPrometheusVersions(w http.ResponseWriter, r *http.Request)

GetPrometheusVersions returns the Prometheus version.

func (*K8s) NewRouter

func (k *K8s) NewRouter(config *restgo.Config) *mux.Router

NewRouter returns a new router instance.

func (*K8s) PutAlertmanagerTemplate

func (k *K8s) PutAlertmanagerTemplate(w http.ResponseWriter, r *http.Request)

PutAlertmanagerTemplate adds a requested Alert Manager template file.

func (*K8s) PutPrometheusConfig

func (k *K8s) PutPrometheusConfig(w http.ResponseWriter, r *http.Request)

PutPrometheusConfig saves the Prometheus configuration.

func (*K8s) PutPrometheusRules

func (k *K8s) PutPrometheusRules(w http.ResponseWriter, r *http.Request)

PutPrometheusRules updates the requested Alert Rules file with the provided body. If not a new rule, save a backup copy of the current rule.

func (*K8s) PutPrometheusUnnamedRules

func (k *K8s) PutPrometheusUnnamedRules(w http.ResponseWriter, r *http.Request)

PutPrometheusUnnamedRules PUT /prometheus/rules has been deprecated. Return a friendly error message instead.

func (*K8s) RestartPodsByLabel

func (k *K8s) RestartPodsByLabel(label string, waitTime time.Duration, skipValidation string) error

RestartPodsByLabel simulates a restart by (1) deleting all pods (sequentially) that have the given label, then (2) waiting up to waitTime for at least one *new* pod to be created and reach the READY status (PodPhase == PodRunning && [*]ContainerStatus.Ready == true). Note that even through we are ensure that the containers and pod are running, we cannot ensure the pod is actually ready to service requests. See docs for more information: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/

Jump to

Keyboard shortcuts

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