tenancy

package
v0.34.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultTenantHeader is the default header used to designate the tenant making a request.
	DefaultTenantHeader = "THANOS-TENANT"
	// DefaultTenant is the default value used for when no tenant is passed via the tenant header.
	DefaultTenant = "default-tenant"
	// DefaultTenantLabel is the default label-name with which the tenant is announced in stored metrics.
	DefaultTenantLabel = "tenant_id"
	// This key is used to pass tenant information using Context.
	TenantKey contextKey = 0
	// MetricLabel is the label name used for adding tenant information to exported metrics.
	MetricLabel = "tenant"
)
View Source
const (
	CertificateFieldOrganization       = "organization"
	CertificateFieldOrganizationalUnit = "organizationalUnit"
	CertificateFieldCommonName         = "commonName"
)

Allowed fields in client certificates.

Variables

This section is empty.

Functions

func EnforceQueryTenancy added in v0.34.0

func EnforceQueryTenancy(tenantLabel string, tenant string, query string) (string, error)

func GetTenantFromGRPCMetadata

func GetTenantFromGRPCMetadata(ctx context.Context) (string, bool)

func GetTenantFromHTTP

func GetTenantFromHTTP(r *http.Request, tenantHeader string, defaultTenantID string, certTenantField string) (string, error)

GetTenantFromHTTP extracts the tenant from a http.Request object.

func InternalTenancyConversionTripper added in v0.34.0

func InternalTenancyConversionTripper(customTenantHeader, certTenantField string, next http.RoundTripper) http.RoundTripper

InternalTenancyConversionTripper is a tripperware that rewrites the configurable tenancy header in the request into the hardcoded tenancy header that is used for internal communication in Thanos components. If any custom tenant header is configured and present in the request, it will be stripped out.

func IsTenantValid

func IsTenantValid(tenant string) error

func RewriteLabelMatchers added in v0.34.0

func RewriteLabelMatchers(ctx context.Context, r *http.Request, tenantHeader string, defaultTenantID string, certTenantField string, enforceTenancy bool, tenantLabel string, formMatchers []string) ([][]*labels.Matcher, context.Context, error)

This function will: - Get tenant from HTTP header and add it to context. - Parse all labels matchers provided. - If tenancy is enforced, make sure a tenant matcher is present.

func RewritePromQL added in v0.34.0

func RewritePromQL(ctx context.Context, r *http.Request, tenantHeader string, defaultTenantID string, certTenantField string, enforceTenancy bool, tenantLabel string, queryStr string) (string, string, context.Context, error)

This function will: - Get tenant from HTTP header and add it to context. - if tenancy is enforced, add a tenant matcher to the promQL expression.

Types

This section is empty.

Jump to

Keyboard shortcuts

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