gcp

package
v2.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GcpScopeMonitoringRead = "https://www.googleapis.com/auth/monitoring.read"

	ErrGoogleApplicationCrendentialsNotFound = errors.New("google application credentials not found")
)

Functions

func GetGCPOAuth2HTTPTransport

func GetGCPOAuth2HTTPTransport(config *scalersconfig.ScalerConfig, base http.RoundTripper, scopes ...string) (http.RoundTripper, error)

func NewStackdriverAggregator

func NewStackdriverAggregator(period int64, aligner string, reducer string) (*monitoringpb.Aggregation, error)

Types

type AuthorizationMetadata

type AuthorizationMetadata struct {
	GoogleApplicationCredentials     string
	GoogleApplicationCredentialsFile string
	PodIdentityProviderEnabled       bool
}

func GetGCPAuthorization

func GetGCPAuthorization(config *scalersconfig.ScalerConfig) (*AuthorizationMetadata, error)

type GoogleApplicationCredentials

type GoogleApplicationCredentials struct {
	Type                string `json:"type"`
	ProjectID           string `json:"project_id"`
	PrivateKeyID        string `json:"private_key_id"`
	PrivateKey          string `json:"private_key"`
	ClientEmail         string `json:"client_email"`
	ClientID            string `json:"client_id"`
	AuthURI             string `json:"auth_uri"`
	TokenURI            string `json:"token_uri"`
	AuthProviderCertURL string `json:"auth_provider_x509_cert_url"`
	ClientX509CertURL   string `json:"client_x509_cert_url"`
}

GoogleApplicationCredentials is a struct representing the format of a service account credentials file

type StackDriverClient

type StackDriverClient struct {
	// contains filtered or unexported fields
}

StackDriverClient is a generic client to fetch metrics from Stackdriver. Can be used for a stackdriver scaler in the future

func NewStackDriverClient

func NewStackDriverClient(ctx context.Context, credentials string) (*StackDriverClient, error)

NewStackDriverClient creates a new stackdriver client with the credentials that are passed

func NewStackDriverClientPodIdentity

func NewStackDriverClientPodIdentity(ctx context.Context) (*StackDriverClient, error)

NewStackDriverClientPodIdentity creates a new stackdriver client with the credentials underlying

func (StackDriverClient) BuildMQLQuery

func (s StackDriverClient) BuildMQLQuery(projectID, resourceType, metric, resourceName, aggregation string) (string, error)

BuildMQLQuery builds a Monitoring Query Language (MQL) query for the last minute (five for aggregations), given a resource type, metric, resource name, and an optional aggregation

example: fetch pubsub_topic | metric 'pubsub.googleapis.com/topic/message_sizes' | filter (resource.project_id == 'myproject' && resource.topic_id == 'mytopic') | within 5m | align delta(3m) | every 3m | group_by [], count(value)

func (*StackDriverClient) Close added in v2.13.1

func (s *StackDriverClient) Close() error

func (StackDriverClient) GetMetrics

func (s StackDriverClient) GetMetrics(
	ctx context.Context,
	filter string,
	projectID string,
	aggregation *monitoringpb.Aggregation,
	valueIfNull *float64) (float64, error)

GetMetrics fetches metrics from stackdriver for a specific filter for the last minute

func (StackDriverClient) QueryMetrics

func (s StackDriverClient) QueryMetrics(ctx context.Context, projectID, query string) (float64, error)

QueryMetrics fetches metrics from the Cloud Monitoring API for a specific Monitoring Query Language (MQL) query

MQL provides a more expressive query language than the current filtering options of GetMetrics

Jump to

Keyboard shortcuts

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