Documentation ¶
Index ¶
- Constants
- func EnforceQueryTenancy(tenantLabel string, tenant string, query string) (string, error)
- func GetTenantFromGRPCMetadata(ctx context.Context) (string, bool)
- func GetTenantFromHTTP(r *http.Request, tenantHeader string, defaultTenantID string, ...) (string, error)
- func InternalTenancyConversionTripper(customTenantHeader, certTenantField string, next http.RoundTripper) http.RoundTripper
- func IsTenantValid(tenant string) error
- func RewriteLabelMatchers(ctx context.Context, r *http.Request, tenantHeader string, ...) ([][]*labels.Matcher, context.Context, error)
- func RewritePromQL(ctx context.Context, r *http.Request, tenantHeader string, ...) (string, string, context.Context, error)
Constants ¶
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" )
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 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 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.