localmetrics

package
v0.0.0-...-ea8c238 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MetricPagerDutyCreateFailure = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name:        "pagerduty_create_failure",
		Help:        "Metric for the failure of creating a cluster deployment.",
		ConstLabels: prometheus.Labels{"name": "pagerduty-operator"},
	}, []string{"clusterdeployment_name", "pagerdutyintegration_name"})

	MetricPagerDutyDeleteFailure = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name:        "pagerduty_delete_failure",
		Help:        "Metric for the failure of deleting a cluster deployment.",
		ConstLabels: prometheus.Labels{"name": "pagerduty-operator"},
	}, []string{"clusterdeployment_name", "pagerdutyintegration_name"})

	MetricPagerDutyHeartbeat = prometheus.NewSummary(prometheus.SummaryOpts{
		Name:        "pagerduty_heartbeat",
		Help:        "Metric for heartbeating of the Pager Duty api.",
		ConstLabels: prometheus.Labels{"name": "pagerduty-operator"},
	})

	ReconcileDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:        "pagerduty_operator_reconcile_duration_seconds",
		Help:        "Distribution of the number of seconds a Reconcile takes, broken down by controller",
		ConstLabels: prometheus.Labels{"name": "pagerduty-operator"},
		Buckets:     []float64{0.001, 0.01, 0.1, 1, 5, 10, 20},
	}, []string{"controller"})

	// apiCallDuration times API requests. Histogram also gives us a _count metric for free.
	ApiCallDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Name:        "pagerduty_operator_api_request_duration_seconds",
		Help:        "Distribution of the number of seconds an API request takes",
		ConstLabels: prometheus.Labels{"name": operatorName},

		Buckets: []float64{1},
	}, []string{"controller", "method", "resource", "status"})

	MetricPagerDutyIntegrationSecretLoaded = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name:        "pagerdutyintegration_secret_loaded",
		Help:        "Metric to track the ability to load the PagerDuty API key from the Secret specified in the PagerDutyIntegration",
		ConstLabels: prometheus.Labels{"name": "pagerduty-operator"},
	}, []string{"pagerdutyintegration_name"})

	MetricPagerDutyServiceOrchestrationFailure = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name:        "pagerduty_service_orchestration_failure",
		Help:        "Metric to indicate that the service orchestration config is failed on the managed clusters when it is enabled in PagerDutyIntegration",
		ConstLabels: prometheus.Labels{"name": operatorName},
	}, []string{"pagerdutyintegration_name"})

	MetricsList = []prometheus.Collector{
		MetricPagerDutyCreateFailure,
		MetricPagerDutyDeleteFailure,
		MetricPagerDutyHeartbeat,
		ApiCallDuration,
		ReconcileDuration,
		MetricPagerDutyIntegrationSecretLoaded,
		MetricPagerDutyServiceOrchestrationFailure,
	}
)

Functions

func AddAPICall

func AddAPICall(controller string, req *http.Request, resp *http.Response, duration float64)

AddAPICall observes metrics for a call to an external API - param controller: The name of the controller making the API call - param req: The HTTP Request structure - param resp: The HTTP Response structure - param duration: The number of seconds the call took.

func DeleteMetricPagerDutyIntegrationSecretLoaded

func DeleteMetricPagerDutyIntegrationSecretLoaded(pdiName string) bool

DeleteMetricPagerDutyIntegrationSecretLoaded deletes the metric for the PagerDutyIntegration name provided. This should be called when e.g. the PagerDutyIntegration is being deleted, so that there are no irrelevant metrics (which alerts could be firing on).

func SetReconcileDuration

func SetReconcileDuration(controller string, duration float64)

SetReconcileDuration Push the duration of the reconcile iteration

func UpdateAPIMetrics

func UpdateAPIMetrics(APIKey string, timer *prometheus.Timer)

UpdateAPIMetrics updates all API endpoint metrics every 5 minutes

func UpdateMetricPagerDutyCreateFailure

func UpdateMetricPagerDutyCreateFailure(x int, cd string, pdiName string)

UpdateMetricPagerDutyCreateFailure updates gauge to 1 when creation fails

func UpdateMetricPagerDutyDeleteFailure

func UpdateMetricPagerDutyDeleteFailure(x int, cd string, pdiName string)

UpdateMetricPagerDutyDeleteFailure updates gauge to 1 when deletion fails

func UpdateMetricPagerDutyHeartbeat

func UpdateMetricPagerDutyHeartbeat(APIKey string, timer *prometheus.Timer)

UpdateMetricPagerDutyHeartbeat curls the PD API, updates the gauge to 1 when successful.

func UpdateMetricPagerDutyIntegrationSecretLoaded

func UpdateMetricPagerDutyIntegrationSecretLoaded(x int, pdiName string)

UpdateMetricPagerDutyIntegrationSecretLoaded updates gauge to 1 when the PagerDuty API key can be loaded from the Secret specified in the PagerDutyIntegration, or to 0 if it fails

func UpdateMetricPagerDutyServiceOrchestrationFailure

func UpdateMetricPagerDutyServiceOrchestrationFailure(v int, pdiName string)

UpdateMetricPagerDutyServiceOrchestrationFailure updates the gauge value when service orchestration configure fails

Types

This section is empty.

Jump to

Keyboard shortcuts

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