Documentation
¶
Index ¶
- Constants
- Variables
- func AllErrorsFor(collection QueryErrorCollection) []error
- func AnyToLabels(a interface{}) (map[string]string, error)
- func DataFieldFormatErr(query string) error
- func DataPointFormatErr(query string) error
- func IsClientID(cli prometheus.Client, id string) bool
- func IsCommError(err error) bool
- func IsErrorCollection(err error) bool
- func IsNoDataError(err error) bool
- func IsNoStoreAPIWarning(warning string) bool
- func IsPrometheus(cli prometheus.Client) bool
- func IsThanos(cli prometheus.Client) bool
- func KubeAnnotationsToLabels(labels map[string]string) ([]string, []string)
- func KubeLabelsToLabels(labels map[string]string) ([]string, []string)
- func KubePrependQualifierToLabels(m map[string]string, qualifier string) ([]string, []string)
- func LabelNamesFrom(labels map[string]string) []string
- func LogPrometheusClientState(client prometheus.Client)
- func LogQueryRequest(l *golog.Logger, req *http.Request, queueTime time.Duration, ...)
- func MapToLabels(m interface{}) map[string]string
- func MetricFieldDoesNotExistErr(query string) error
- func MetricFieldFormatErr(query string) error
- func NewPrometheusClient(address string, config *PrometheusClientConfig) (prometheus.Client, error)
- func NewRateLimitedClient(id string, client prometheus.Client, maxConcurrency int, auth *ClientAuth, ...) (prometheus.Client, error)
- func NoDataErr(query string) error
- func PromUnexpectedResponseErr(query string) error
- func QueryResultNilErr(query string) error
- func ResultFieldDoesNotExistErr(query string) error
- func ResultFieldFormatErr(query string) error
- func ResultFormatErr(query string) error
- func SanitizeLabelName(s string) string
- func SanitizeLabels(labels map[string]string) map[string]string
- func ScrapeIntervalFor(client prometheus.Client, jobName string) (time.Duration, error)
- func ValueFieldDoesNotExistErr(query string) error
- func ValueFieldFormatErr(query string) error
- func WrapError(err error, msg string) error
- type ClientAuth
- type CommError
- type Context
- func (ctx *Context) ErrorCollection() error
- func (ctx *Context) Errors() []*QueryError
- func (ctx *Context) HasErrors() bool
- func (ctx *Context) HasWarnings() bool
- func (ctx *Context) ProfileQuery(query string, profileLabel string) QueryResultsChan
- func (ctx *Context) ProfileQueryAll(queries ...string) []QueryResultsChan
- func (ctx *Context) ProfileQueryRange(query string, start, end time.Time, step time.Duration, profileLabel string) QueryResultsChan
- func (ctx *Context) Query(query string) QueryResultsChan
- func (ctx *Context) QueryAll(queries ...string) []QueryResultsChan
- func (ctx *Context) QueryAtTime(query string, t time.Time) QueryResultsChan
- func (ctx *Context) QueryRange(query string, start, end time.Time, step time.Duration) QueryResultsChan
- func (ctx *Context) QueryRangeSync(query string, start, end time.Time, step time.Duration) ([]*QueryResult, v1.Warnings, error)
- func (ctx *Context) QueryRangeURL() *url.URL
- func (ctx *Context) QuerySync(query string) ([]*QueryResult, v1.Warnings, error)
- func (ctx *Context) QueryURL() *url.URL
- func (ctx *Context) RawQuery(query string, t time.Time) ([]byte, error)
- func (ctx *Context) RawQueryRange(query string, start, end time.Time, step time.Duration) ([]byte, error)
- func (ctx *Context) Warnings() []*QueryWarning
- type ErrorsAndWarningStrings
- type NoDataError
- type PrometheusClientConfig
- type PrometheusConfig
- type PrometheusDiagnostic
- type PrometheusDiagnostics
- type PrometheusMetadata
- type PrometheusQueueState
- type QueryError
- type QueryErrorCollection
- type QueryErrorCollector
- func (ec *QueryErrorCollector) As(target interface{}) bool
- func (ec *QueryErrorCollector) Error() string
- func (ec *QueryErrorCollector) Errors() []*QueryError
- func (ec *QueryErrorCollector) IsError() bool
- func (ec *QueryErrorCollector) IsWarning() bool
- func (ec *QueryErrorCollector) Report(query string, warnings []string, requestError error, parseError error)
- func (ec *QueryErrorCollector) ToErrorAndWarningStrings() (errors []string, warnings []string)
- func (ec *QueryErrorCollector) Warnings() []*QueryWarning
- type QueryParamsDecorator
- type QueryResult
- type QueryResults
- type QueryResultsChan
- type QueryWarning
- type QueuedPromRequest
- type RateLimitResponseStatus
- type RateLimitRetryOpts
- type RateLimitedPrometheusClient
- func (rlpc *RateLimitedPrometheusClient) Do(ctx context.Context, req *http.Request) (*http.Response, []byte, error)
- func (rlpc *RateLimitedPrometheusClient) ID() string
- func (rlpc *RateLimitedPrometheusClient) TotalOutboundRequests() int
- func (rlpc *RateLimitedPrometheusClient) TotalQueuedRequests() int
- func (rlpc *RateLimitedPrometheusClient) URL(ep string, args map[string]string) *url.URL
- type RateLimitedResponseError
- type ScrapeConfig
Constants ¶
const ( // AllocationContextName is the name we assign the allocation query context [metadata] AllocationContextName = "allocation" // ClusterContextName is the name we assign the cluster query context [metadata] ClusterContextName = "cluster" // ClusterContextName is the name we assign the optional cluster query context [metadata] ClusterOptionalContextName = "cluster-optional" // ComputeCostDataContextName is the name we assign the compute cost data query context [metadata] ComputeCostDataContextName = "compute-cost-data" // ComputeCostDataContextName is the name we assign the compute cost data range query context [metadata] ComputeCostDataRangeContextName = "compute-cost-data-range" // ClusterMapContextName is the name we assign the cluster map query context [metadata] ClusterMapContextName = "cluster-map" // FrontendContextName is the name we assign queries proxied from the frontend [metadata] FrontendContextName = "frontend" // DiagnosticContextName is the name we assign queries that check the state of the prometheus connection DiagnosticContextName = "diagnostic" // ContainerStatsContextName is the name we assign queries that build // container stats aggregations. ContainerStatsContextName = "container-stats" )
const ( // CAdvisorDiagnosticMetricID is the identifier of the metric used to determine if cAdvisor is being scraped. CAdvisorDiagnosticMetricID = "cadvisorMetric" // CAdvisorLabelDiagnosticMetricID is the identifier of the metric used to determine if cAdvisor labels are correct. CAdvisorLabelDiagnosticMetricID = "cadvisorLabel" // KSMDiagnosticMetricID is the identifier for the metric used to determine if KSM metrics are being scraped. KSMDiagnosticMetricID = "ksmMetric" // KSMVersionDiagnosticMetricID is the identifier for the metric used to determine if KSM version is correct. KSMVersionDiagnosticMetricID = "ksmVersion" // KubecostDiagnosticMetricID is the identifier for the metric used to determine if Kubecost metrics are being scraped. KubecostDiagnosticMetricID = "kubecostMetric" // NodeExporterDiagnosticMetricID is the identifier for the metric used to determine if NodeExporter metrics are being scraped. NodeExporterDiagnosticMetricID = "neMetric" // ScrapeIntervalDiagnosticMetricID is the identifier for the metric used to determine if prometheus has its own self-scraped // metrics. ScrapeIntervalDiagnosticMetricID = "scrapeInterval" // CPUThrottlingDiagnosticMetricID is the identifier for the metric used to determine if CPU throttling is being applied to the // cost-model container. CPUThrottlingDiagnosticMetricID = "cpuThrottling" // KubecostRecordingRuleCPUUsageID is the identifier for the query used to // determine of the CPU usage recording rule is set up correctly. KubecostRecordingRuleCPUUsageID = "kubecostRecordingRuleCPUUsage" // CAdvisorWorkingSetBytesMetricID is the identifier for the query used to determine // if cAdvisor working set bytes data is being scraped CAdvisorWorkingSetBytesMetricID = "cadvisorWorkingSetBytesMetric" // KSMCPUCapacityMetricID is the identifier for the query used to determine if // KSM CPU capacity data is being scraped KSMCPUCapacityMetricID = "ksmCpuCapacityMetric" // KSMAllocatableCPUCoresMetricID is the identifier for the query used to determine // if KSM allocatable CPU core data is being scraped KSMAllocatableCPUCoresMetricID = "ksmAllocatableCpuCoresMetric" )
Prometheus Metric Diagnostic IDs
const ( // PrometheusClientID is the identifier used when creating the client that // targets prometheus. This can be used to check a specific client instance // by calling prom.IsClientID(client, prom.PrometheusClientID) PrometheusClientID string = "Prometheus" // ThanosClientID is the identifier used when creating the client that // targets thanos. This can be used to check a specific client instance // by calling prom.IsClientID(client, prom.ThanosClientID) ThanosClientID string = "Thanos" )
const DocumentationBaseURL = "https://github.com/kubecost/docs/blob/master/diagnostics.md"
const HeaderXScopeOrgId = "X-Scope-OrgID"
Default header key for Mimir/Cortex-Tenant API requests
const MaxRetryAfterDuration = 10 * time.Second
MaxRetryAfterDuration is the maximum amount of time we should ever wait during a retry. This is to prevent starvation on the request threads
const NoStoreAPIWarning string = "No StoreAPIs matched for this query"
NoStoreAPIWarning is a warning that we would consider an error. It returns partial data relating only to the store apis which were reachable. In order to ensure integrity of data across all clusters, we'll need to identify this warning and convert it to an error.
const PrometheusTroubleshootingURL = "http://docs.kubecost.com/custom-prom#troubleshoot"
Variables ¶
var ( // Static Warnings for data point parsing InfWarning warning = newWarning("Found Inf value parsing vector data point for metric") NaNWarning warning = newWarning("Found NaN value parsing vector data point for metric") )
var UserAgent = fmt.Sprintf("Opencost/%s", version.Version)
Functions ¶
func AllErrorsFor ¶
func AllErrorsFor(collection QueryErrorCollection) []error
func AnyToLabels ¶
AnyToLabels will create prometheus labels based on the fields of the interface passed. Note that this method is quite expensive and should only be used when absolutely necessary.
func DataFieldFormatErr ¶
func DataPointFormatErr ¶
func IsClientID ¶
func IsClientID(cli prometheus.Client, id string) bool
IsClientID returns true if the client has an identifier of the specific type.
func IsCommError ¶
IsCommError returns true if the given error is a CommError
func IsErrorCollection ¶
IsErrorCollection returns true if the provided error is an ErrorCollection
func IsNoDataError ¶
IsNoDataError returns true if the given error is a NoDataError
func IsNoStoreAPIWarning ¶
IsNoStoreAPIWarning checks a warning to determine if it is equivalent to a no store API query.
func IsPrometheus ¶
func IsPrometheus(cli prometheus.Client) bool
IsPrometheus returns true if the client provided is used to target prometheus
func IsThanos ¶
func IsThanos(cli prometheus.Client) bool
IsThanos returns true if the client provided is used to target thanos
func KubeAnnotationsToLabels ¶
Converts kubernetes annotations into prometheus labels.
func KubeLabelsToLabels ¶
Converts kubernetes labels into prometheus labels.
func KubePrependQualifierToLabels ¶
Prepends a qualifier string to the keys provided in the m map and returns the new keys and values.
func LabelNamesFrom ¶
LabelNamesFrom accepts a mapping of labels to values and returns the label names.
func LogPrometheusClientState ¶
func LogPrometheusClientState(client prometheus.Client)
LogPrometheusClientState logs the current state, with respect to outbound requests, if that information is available.
func LogQueryRequest ¶
func LogQueryRequest(l *golog.Logger, req *http.Request, queueTime time.Duration, sendTime time.Duration)
LogQueryRequest logs the query that was send to prom/thanos with the time in queue and total time after being sent
func MapToLabels ¶
MapToLabels accepts a map type, and will return a new map containing all the nested fields separated by _ with string versions of the values.
func MetricFieldFormatErr ¶
func NewPrometheusClient ¶
func NewPrometheusClient(address string, config *PrometheusClientConfig) (prometheus.Client, error)
NewPrometheusClient creates a new rate limited client which limits by outbound concurrent requests.
func NewRateLimitedClient ¶
func NewRateLimitedClient( id string, client prometheus.Client, maxConcurrency int, auth *ClientAuth, decorator QueryParamsDecorator, rateLimitRetryOpts *RateLimitRetryOpts, queryLogFile string, headerXScopeOrgId string) (prometheus.Client, error)
NewRateLimitedClient creates a prometheus client which limits the number of concurrent outbound prometheus requests.
func QueryResultNilErr ¶
func ResultFieldFormatErr ¶
func ResultFormatErr ¶
func SanitizeLabelName ¶
Replaces all illegal prometheus label characters with _
func SanitizeLabels ¶ added in v1.106.0
SanitizeLabels sanitizes all label names in the given map. This may cause collisions, which is intentional as collisions that are not caught prior to attempted emission will cause fatal errors. In the case of a collision, the last value seen will be set, and all previous values will be overwritten.
func ScrapeIntervalFor ¶
ScrapeIntervalFor uses the provided prometheus client to locate a scrape interval for a specific job name
func ValueFieldFormatErr ¶
Types ¶
type ClientAuth ¶
ClientAuth is used to authenticate outgoing client requests.
func (*ClientAuth) Apply ¶
func (auth *ClientAuth) Apply(req *http.Request)
Apply Applies the authentication data to the request headers
type CommError ¶
type CommError struct {
// contains filtered or unexported fields
}
CommError describes an error communicating with Prometheus
func CommErrorf ¶
CommErrorf creates a new CommError using a string formatter
func NewCommError ¶
NewCommError creates a new CommError
type Context ¶
type Context struct { Client prometheus.Client // contains filtered or unexported fields }
Context wraps a Prometheus client and provides methods for querying and parsing query responses and errors.
func NewContext ¶
func NewContext(client prometheus.Client) *Context
NewContext creates a new Prometheus querying context from the given client
func NewNamedContext ¶
func NewNamedContext(client prometheus.Client, name string) *Context
NewNamedContext creates a new named Prometheus querying context from the given client
func (*Context) ErrorCollection ¶
ErrorCollection returns the aggregation of errors if there exists errors. Otherwise, nil is returned
func (*Context) Errors ¶
func (ctx *Context) Errors() []*QueryError
Errors returns the errors collected from the Context's ErrorCollector.
func (*Context) HasWarnings ¶
HasWarnings returns true if the ErrorCollector has warnings.
func (*Context) ProfileQuery ¶
func (ctx *Context) ProfileQuery(query string, profileLabel string) QueryResultsChan
ProfileQuery returns a QueryResultsChan, then runs the given query with a profile label and sends the results on the provided channel. Receiver is responsible for closing the channel, preferably using the Read method.
func (*Context) ProfileQueryAll ¶
func (ctx *Context) ProfileQueryAll(queries ...string) []QueryResultsChan
ProfileQueryAll returns one QueryResultsChan for each query provided, then runs each ProfileQuery concurrently and returns results on each channel, respectively, in the order they were provided; i.e. the response to queries[1] will be sent on channel resChs[1].
func (*Context) ProfileQueryRange ¶
func (*Context) Query ¶
func (ctx *Context) Query(query string) QueryResultsChan
Query returns a QueryResultsChan, then runs the given query and sends the results on the provided channel. Receiver is responsible for closing the channel, preferably using the Read method.
func (*Context) QueryAll ¶
func (ctx *Context) QueryAll(queries ...string) []QueryResultsChan
QueryAll returns one QueryResultsChan for each query provided, then runs each query concurrently and returns results on each channel, respectively, in the order they were provided; i.e. the response to queries[1] will be sent on channel resChs[1].
func (*Context) QueryAtTime ¶
func (ctx *Context) QueryAtTime(query string, t time.Time) QueryResultsChan
QueryAtTime returns a QueryResultsChan, then runs the given query at the given time (see time parameter here: https://prometheus.io/docs/prometheus/latest/querying/api/#instant-queries) and sends the results on the provided channel. Receiver is responsible for closing the channel, preferably using the Read method.
func (*Context) QueryRange ¶
func (*Context) QueryRangeSync ¶
func (*Context) QueryRangeURL ¶
QueryRangeURL returns the URL used to query_range Prometheus
func (*Context) RawQuery ¶
RawQuery is a direct query to the prometheus client and returns the body of the response
func (*Context) RawQueryRange ¶
func (ctx *Context) RawQueryRange(query string, start, end time.Time, step time.Duration) ([]byte, error)
RawQuery is a direct query to the prometheus client and returns the body of the response
func (*Context) Warnings ¶
func (ctx *Context) Warnings() []*QueryWarning
Warnings returns the warnings collected from the Context's ErrorCollector
type ErrorsAndWarningStrings ¶
ErrorsAndWarningStrings is a container struct for string representation storage/caching
type NoDataError ¶
type NoDataError struct {
// contains filtered or unexported fields
}
NoDataError indicates that no data was returned by Prometheus. This should be treated like an EOF error, in that it may be expected.
func NewNoDataError ¶
func NewNoDataError(messages ...string) NoDataError
NewNoDataError creates a new NoDataError
func (NoDataError) Wrap ¶
func (nde NoDataError) Wrap(message string) NoDataError
Wrap wraps the error with the given message, but persists the error type.
type PrometheusClientConfig ¶
type PrometheusClientConfig struct { Timeout time.Duration KeepAlive time.Duration TLSHandshakeTimeout time.Duration TLSInsecureSkipVerify bool RateLimitRetryOpts *RateLimitRetryOpts Auth *ClientAuth QueryConcurrency int QueryLogFile string HeaderXScopeOrgId string }
PrometheusClientConfig contains all configurable options for creating a new prometheus client
type PrometheusConfig ¶
type PrometheusConfig struct {
ScrapeConfigs []ScrapeConfig `yaml:"scrape_configs,omitempty"`
}
PrometheusConfig is the minimalized view of a prometheus configuration
func GetPrometheusConfig ¶
func GetPrometheusConfig(pcfg string) (PrometheusConfig, error)
GetPrometheusConfig uses the provided yaml string to parse the minimalized prometheus config
type PrometheusDiagnostic ¶
type PrometheusDiagnostic struct { ID string `json:"id"` Query string `json:"query"` Label string `json:"label"` Description string `json:"description"` DocLink string `json:"docLink"` Result []*QueryResult `json:"result"` Passed bool `json:"passed"` }
PrometheusDiagnostic holds information about a metric and the query to ensure it is functional
type PrometheusDiagnostics ¶
type PrometheusDiagnostics []*PrometheusDiagnostic
PrometheusDiagnostics is a PrometheusDiagnostic container with helper methods.
func GetPrometheusMetrics ¶
func GetPrometheusMetrics(client prometheus.Client, offset string) PrometheusDiagnostics
GetPrometheusMetrics returns a list of the state of Prometheus metric used by kubecost using the provided client
func GetPrometheusMetricsByID ¶
func GetPrometheusMetricsByID(ids []string, client prometheus.Client, offset string) PrometheusDiagnostics
GetPrometheusMetricsByID returns a list of the state of specific Prometheus metrics by identifier.
func (PrometheusDiagnostics) HasFailure ¶
func (pd PrometheusDiagnostics) HasFailure() bool
HasFailure returns true if any of the diagnostic tests didn't pass.
type PrometheusMetadata ¶
type PrometheusMetadata struct { Running bool `json:"running"` KubecostDataExists bool `json:"kubecostDataExists"` }
PrometheusMetadata represents a validation result for prometheus/thanos running kubecost.
func Validate ¶
func Validate(cli prometheus.Client) (*PrometheusMetadata, error)
Validate tells the model what data prometheus has on it.
type PrometheusQueueState ¶
type PrometheusQueueState struct { QueuedRequests []*QueuedPromRequest `json:"queuedRequests"` OutboundRequests int `json:"outboundRequests"` TotalRequests int `json:"totalRequests"` MaxQueryConcurrency int `json:"maxQueryConcurrency"` }
PrometheusQueueState contains diagnostic information concerning the state of the prometheus request queue
func GetPrometheusQueueState ¶
func GetPrometheusQueueState(client prometheus.Client) (*PrometheusQueueState, error)
GetPrometheusQueueState is a diagnostic function that probes the prometheus request queue and gathers query, context, and queue statistics.
type QueryError ¶
type QueryError struct { Query string `json:"query"` Error error `json:"error"` ParseError error `json:"parseError"` }
func (*QueryError) String ¶
func (qe *QueryError) String() string
String returns a string representation of the QueryError
type QueryErrorCollection ¶
type QueryErrorCollection interface { // Warnings is a slice of the QueryWarning instances Warnings() []*QueryWarning // Errors is a slice of the QueryError instances Errors() []*QueryError // ToErrorAndWarningStrings returns the errors and warnings in the collection // as two string slices. ToErrorAndWarningStrings() (errors []string, warnings []string) }
QueryErrorCollection represents a collection of query errors and warnings made via context.
type QueryErrorCollector ¶
type QueryErrorCollector struct {
// contains filtered or unexported fields
}
QueryErrorCollector is used to collect prometheus query errors and warnings, and also meets the Error interface
func (*QueryErrorCollector) As ¶
func (ec *QueryErrorCollector) As(target interface{}) bool
As is a special method that implicitly works with the `errors.As()` go helper to locate the _first_ instance of the provided target type in the collection.
func (*QueryErrorCollector) Error ¶
func (ec *QueryErrorCollector) Error() string
Implement the error interface to allow returning as an aggregated error
func (*QueryErrorCollector) Errors ¶
func (ec *QueryErrorCollector) Errors() []*QueryError
Errors caught by the collector
func (*QueryErrorCollector) IsError ¶
func (ec *QueryErrorCollector) IsError() bool
Whether or not the collector caught errors
func (*QueryErrorCollector) IsWarning ¶
func (ec *QueryErrorCollector) IsWarning() bool
Whether or not the collector caught any warnings
func (*QueryErrorCollector) Report ¶
func (ec *QueryErrorCollector) Report(query string, warnings []string, requestError error, parseError error)
Reports an error to the collector. Ignores if the error is nil and the warnings are empty
func (*QueryErrorCollector) ToErrorAndWarningStrings ¶
func (ec *QueryErrorCollector) ToErrorAndWarningStrings() (errors []string, warnings []string)
ToErrorAndWarningStrings returns the errors and warnings in the collection as two string slices.
func (*QueryErrorCollector) Warnings ¶
func (ec *QueryErrorCollector) Warnings() []*QueryWarning
Warnings caught by the collector
type QueryParamsDecorator ¶
QueryParamsDecorator is used to decorate and return query parameters for outgoing requests
type QueryResult ¶
type QueryResult struct { Metric map[string]interface{} `json:"metric"` Values []*util.Vector `json:"values"` }
QueryResult contains a single result from a prometheus query. It's common to refer to query results as a slice of QueryResult
func (*QueryResult) GetAnnotations ¶
func (qr *QueryResult) GetAnnotations() map[string]string
GetAnnotations returns all annotations and their values from the query result
func (*QueryResult) GetLabels ¶
func (qr *QueryResult) GetLabels() map[string]string
GetLabels returns all labels and their values from the query result
func (*QueryResult) GetString ¶
func (qr *QueryResult) GetString(field string) (string, error)
GetString returns the requested field, or an error if it does not exist
func (*QueryResult) GetStrings ¶
func (qr *QueryResult) GetStrings(fields ...string) (map[string]string, error)
GetStrings returns the requested fields, or an error if it does not exist
type QueryResults ¶
type QueryResults struct { Query string Error error Results []*QueryResult }
QueryResults contains all of the query results and the source query string.
func NewQueryResults ¶
func NewQueryResults(query string, queryResult interface{}) *QueryResults
NewQueryResults accepts the raw prometheus query result and returns an array of QueryResult objects
type QueryResultsChan ¶
type QueryResultsChan chan *QueryResults
QueryResultsChan is a channel of query results
func (QueryResultsChan) Await ¶
func (qrc QueryResultsChan) Await() ([]*QueryResult, error)
Await returns query results, blocking until they are made available, and deferring the closure of the underlying channel
type QueryWarning ¶
func (*QueryWarning) String ¶
func (qw *QueryWarning) String() string
String returns a string representation of the QueryWarning
type QueuedPromRequest ¶
type QueuedPromRequest struct { Context string `json:"context"` Query string `json:"query"` QueueTime int64 `json:"queueTime"` }
QueuedPromRequest is a representation of a request waiting to be sent by the prometheus client.
type RateLimitResponseStatus ¶
RateLimitResponseStatus contains the status of the rate limited retries
func (*RateLimitResponseStatus) String ¶
func (rtrs *RateLimitResponseStatus) String() string
String creates a string representation of the rate limit status
type RateLimitRetryOpts ¶
RateLimitRetryOpts contains retry options
type RateLimitedPrometheusClient ¶
type RateLimitedPrometheusClient struct {
// contains filtered or unexported fields
}
RateLimitedPrometheusClient is a prometheus client which limits the total number of concurrent outbound requests allowed at a given moment.
func (*RateLimitedPrometheusClient) Do ¶
func (rlpc *RateLimitedPrometheusClient) Do(ctx context.Context, req *http.Request) (*http.Response, []byte, error)
Rate limit and passthrough to prometheus client API
func (*RateLimitedPrometheusClient) ID ¶
func (rlpc *RateLimitedPrometheusClient) ID() string
ID is used to identify the type of client
func (*RateLimitedPrometheusClient) TotalOutboundRequests ¶
func (rlpc *RateLimitedPrometheusClient) TotalOutboundRequests() int
TotalOutboundRequests returns the total number of concurrent outbound requests, which have been sent to the server and are awaiting response.
func (*RateLimitedPrometheusClient) TotalQueuedRequests ¶
func (rlpc *RateLimitedPrometheusClient) TotalQueuedRequests() int
TotalRequests returns the total number of requests that are either waiting to be sent and/or are currently outbound.
type RateLimitedResponseError ¶
type RateLimitedResponseError struct {
RateLimitStatus []*RateLimitResponseStatus
}
RateLimitedError contains a list of retry statuses that occurred during retries on a rate limited response
func (*RateLimitedResponseError) Error ¶
func (rlre *RateLimitedResponseError) Error() string
Error returns a string representation of the error, including the rate limit status reports
type ScrapeConfig ¶
type ScrapeConfig struct { JobName string `yaml:"job_name,omitempty"` ScrapeInterval string `yaml:"scrape_interval,omitempty"` }
ScrapeConfig is the minimalized view of a prometheus scrape configuration