Documentation
¶
Index ¶
- func CurlExecViaPod(ns, name, url string) (int, string, error)
- func ExpectHTTPStatusCode(url, bearerToken string, statusCodes ...int) error
- func ExpectPrometheusEndpoint(url string)
- func ExpectURLStatusCodeExecViaPod(ns, execPodName, url string, statusCodes ...int) error
- func FetchAlertingRules(promURL, bearerToken string) (map[string][]prometheusv1.AlertingRule, error)
- func ForEachAlertingRule(rules map[string][]prometheusv1.AlertingRule, ...) error
- func GetBearerTokenURLViaPod(oc *exutil.CLI, execPodName, url, bearer string) (string, error)
- func GetURLWithToken(url, bearerToken string) (string, error)
- func MustJoinUrlPath(base string, paths ...string) string
- func PrometheusRouteURL(ctx context.Context, oc *exutil.CLI) (string, error)
- func PrometheusServiceURL(ctx context.Context, oc *exutil.CLI) (string, error)
- func QueryURL(rawURL string, timeout time.Duration) error
- func RequestPrometheusServiceAccountAPIToken(ctx context.Context, oc *exutil.CLI) (string, error)
- func RunQueries(ctx context.Context, prometheusClient prometheusv1.API, ...) error
- func ThanosQuerierRouteURL(ctx context.Context, oc *exutil.CLI) (string, error)
- func ThanosQuerierServiceURL(ctx context.Context, oc *exutil.CLI) (string, error)
- func ValidateURL(rawURL string) error
- type PrometheusResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CurlExecViaPod ¶ added in v1.6.0
CurlExecViaPod attempts connection to url via exec pod and returns the HTTP status code and the error message reported by curl.
func ExpectHTTPStatusCode ¶
ExpectHTTPStatusCode sends a GET request to the URL and checks the expected status code. If bearerToken isn't empty, it will be used to authenticate against the endpoint. It returns an error if the request fails or the status return code is not equal to any of the statusCodes.
func ExpectPrometheusEndpoint ¶
func ExpectPrometheusEndpoint(url string)
ExpectPrometheusEndpoint attempts to connect to the metrics endpoint with delayed retries upon failure.
func ExpectURLStatusCodeExecViaPod ¶
ExpectURLStatusCodeExecViaPod attempts connection to url via exec pod and returns an error upon failure or if status return code is not equal to any of the statusCodes.
func FetchAlertingRules ¶
func FetchAlertingRules(promURL, bearerToken string) (map[string][]prometheusv1.AlertingRule, error)
FetchAlertingRules fetchs all alerting rules from the Prometheus at the given URL using the given bearer token. The results are returned as a map of group names to lists of alerting rules.
func ForEachAlertingRule ¶
func ForEachAlertingRule(rules map[string][]prometheusv1.AlertingRule, f func(a prometheusv1.AlertingRule) sets.String) error
ForEachAlertingRule takes a map of rule group names to a list of alerting rules, and for each rule in each group runs the given function. The function takes the alerting rule, and returns a set of violations, which maye be empty or nil. If after all rules are checked, there are any violations, an error is returned.
func GetBearerTokenURLViaPod ¶
func GetURLWithToken ¶
GetURLWithToken makes an HTTP request with a bearer token.
func MustJoinUrlPath ¶
MustJoinUrlPath behaves like url.JoinPath but it will panic in case of error.
func PrometheusRouteURL ¶
PrometheusRouteURL returns the public url of the cluster prometheus service or an error if the route is not found.
func PrometheusServiceURL ¶
PrometheusServiceURL returns the url of the cluster prometheus service or an error if the service is not found.
func QueryURL ¶
QueryURL takes a URL as a string and a timeout. The URL is parsed, then fetched until a 200 response is received or the timeout is reached.
func RequestPrometheusServiceAccountAPIToken ¶
RequestPrometheusServiceAccountAPIToken returns a time-bound (24hr) API token for the prometheus service account.
func RunQueries ¶
func RunQueries(ctx context.Context, prometheusClient prometheusv1.API, promQueries map[string]bool, oc *exutil.CLI) error
RunQueries executes Prometheus queries and checks provided expected result.
func ThanosQuerierRouteURL ¶
ThanosQuerierRouteURL returns the public url of the thanos querier service or an error if the route is not found.
func ThanosQuerierServiceURL ¶
ThanosQuerierServiceURL returns the url of the thanos querier service or an error if the service is not found.
func ValidateURL ¶
Types ¶
type PrometheusResponse ¶
type PrometheusResponse struct {
Data prometheusResponseData `json:"data"`
}
PrometheusResponse is used to contain prometheus query results
func RunQuery ¶
func RunQuery(ctx context.Context, prometheusClient prometheusv1.API, query string) (*PrometheusResponse, error)
func RunQueryAtTime ¶
func RunQueryAtTime(ctx context.Context, prometheusClient prometheusv1.API, query string, evaluationTime time.Time) (*PrometheusResponse, error)