prometheus

package
v2.0.0-...-6831f71 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 31 Imported by: 2

Documentation

Index

Constants

View Source
const TypeNotSupportedErr = errors.Sentinel("type is not supported")

Variables

View Source
var ClientError = errors.Sentinel("clientError")
View Source
var ClientErrorUnauthorized = errors.Sentinel("clientError: Unauthorized")
View Source
var ServerError = errors.Sentinel("serverError")

Functions

func GenerateCACertPool

func GenerateCACertPool(files ...string) (*tls.Config, error)

func GetAuthToken

func GetAuthToken(apiTokenPath string) (token string, returnErr error)

func GetAuthTokenForKubeAdm

func GetAuthTokenForKubeAdm() (token string, returnErr error)

func NewSecureClient

func NewSecureClient(config *PrometheusSecureClientConfig) (api.Client, error)

func NewSecureClientFromCert

func NewSecureClientFromCert(config *PrometheusSecureClientConfig) (api.Client, error)

func WithBasicAuth

func WithBasicAuth(rt http.RoundTripper, username, password string) http.RoundTripper

func WithBearerAuth

func WithBearerAuth(rt http.RoundTripper, token string) http.RoundTripper

func WithHeader

func WithHeader(rt http.RoundTripper) withHeader

Types

type MeterDefinitionQuery

type MeterDefinitionQuery struct {
	Start, End time.Time
	Step       time.Duration
}

func (*MeterDefinitionQuery) Print

func (q *MeterDefinitionQuery) Print() (string, error)

type PromQuery

type PromQuery struct {
	*PromQueryArgs
}

func NewPromQuery

func NewPromQuery(
	args *PromQueryArgs,
) *PromQuery

func NewPromQueryFromLabels

func NewPromQueryFromLabels(
	meterDefLabels *common.MeterDefPrometheusLabels,
	start, end time.Time,
) *PromQuery

func PromQueryFromLabels

func PromQueryFromLabels(
	meterDefLabels *common.MeterDefPrometheusLabels,
	start, end time.Time,
) *PromQuery

func (*PromQuery) GetQueryArgs

func (q *PromQuery) GetQueryArgs() ResultQueryArgs

func (*PromQuery) Print

func (q *PromQuery) Print() (string, error)

type PromQueryArgs

type PromQueryArgs struct {
	Type               common.WorkloadType
	MeterDef           types.NamespacedName
	Metric             string
	Query              string
	Start, End         time.Time
	Step               time.Duration
	AggregateFunc      string
	LabelReplacePrefix string
	LabelReplaceSuffix string
	MetricType         common.MetricType
	GroupBy            []string
	Without            []string
	// contains filtered or unexported fields
}

type PrometheusAPI

type PrometheusAPI struct {
	v1.API
}

func NewPromAPI

func NewPromAPI(
	promService *corev1.Service,
	targetPort *corev1.ServicePort,
	caCert *[]byte,
	token string,
) (*PrometheusAPI, error)

func NewPrometheusAPIForReporter

func NewPrometheusAPIForReporter(
	setup *PrometheusAPISetup,
) (*PrometheusAPI, error)

func NewThanosAPI

func NewThanosAPI(
	promService *corev1.Service,
	caCert *[]byte,
	token string,
) (*PrometheusAPI, error)

func ProvidePrometheusAPI

func ProvidePrometheusAPI(
	context context.Context,
	client client.Client,
	deployedNamespace string,
	apiType PrometheusAPIType) (*PrometheusAPI, error)

func (*PrometheusAPI) MeterDefLabelValues

func (p *PrometheusAPI) MeterDefLabelValues(matches []string) (model.LabelValues, v1.Warnings, error)

return LabelValues/MeterDefinition names seen in the last hour

func (*PrometheusAPI) QueryMeterDefinitions

func (p *PrometheusAPI) QueryMeterDefinitions(query *MeterDefinitionQuery) (model.Value, v1.Warnings, error)

func (*PrometheusAPI) ReportQuery

func (p *PrometheusAPI) ReportQuery(query *PromQuery) (model.Value, v1.Warnings, error)

type PrometheusAPIBuilder

type PrometheusAPIBuilder struct {
	Cfg    *config.OperatorConfig
	Client client.Client
	// contains filtered or unexported fields
}

func (*PrometheusAPIBuilder) Get

func (*PrometheusAPIBuilder) GetAPITypeFromFlag

func (p *PrometheusAPIBuilder) GetAPITypeFromFlag(userWorkloadMonitoringEnabled bool) PrometheusAPIType

type PrometheusAPISetup

type PrometheusAPISetup struct {
	Report        *v1alpha1.MeterReport
	PromService   *corev1.Service
	PromPort      *corev1.ServicePort
	CertFilePath  string
	TokenFilePath string
	RunLocal      bool
}

type PrometheusAPIType

type PrometheusAPIType string
const RHMWorkload PrometheusAPIType = "RHMWorkload"
const UserWorkload PrometheusAPIType = "UserWorkload"

type PrometheusSecureClientConfig

type PrometheusSecureClientConfig struct {
	Address string

	Token string

	UserAuth *UserAuth

	ServerCertFile string

	CaCert *[]byte
}

type ResultQueryArgs

type ResultQueryArgs struct {
	MeterName, Query, AggregateFunc, LabelReplacePrefix, LabelReplaceSuffix string
	QueryFilters, GroupBy, Without                                          []string
	DefaultWithout, DefaultGroupBy                                          []string
}

type ServiceAccountClient

type ServiceAccountClient struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewServiceAccountClient

func NewServiceAccountClient(
	namespace string,
	kubernetesInterface kubernetes.Interface,
	log logr.Logger,
) *ServiceAccountClient

func (*ServiceAccountClient) GetToken

func (s *ServiceAccountClient) GetToken(targetServiceAccountName string, audience string, expireSecs int64) (string, error)

type Token

type Token struct {
	AuthToken           *string
	ExpirationTimestamp metav1.Time
}

type UserAuth

type UserAuth struct {
	Username, Password string
}

Jump to

Keyboard shortcuts

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