Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(operator): Add support for Loki OTLP limits config #13446

Merged
merged 19 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions operator/apis/loki/v1/lokistack_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,112 @@ type IngestionLimitSpec struct {
PerStreamRateLimitBurst int32 `json:"perStreamRateLimitBurst,omitempty"`
}

// OTLPAttributeAction defines the action to executed when indexing
// OTLP resource attributes. Resource attributes can be either added
// to the index, the chunk structured metadata or enterily dropped.
periklis marked this conversation as resolved.
Show resolved Hide resolved
//
// +kubebuilder:validation:Enum=index_label;structured_metadata;drop
periklis marked this conversation as resolved.
Show resolved Hide resolved
type OTLPAttributeAction string

const (
// IndexLabelAction stores a Resource Attribute as a label in index to identify streams.
IndexLabelAction OTLPAttributeAction = "index_label"
// StructuredMetadataAction stores an Attribute as Structured Metadata with each log entry.
StructuredMetadataAction OTLPAttributeAction = "structured_metadata"
// DropAction drops Attributes for which the Attribute name does match the regex.
DropAction OTLPAttributeAction = "drop"
periklis marked this conversation as resolved.
Show resolved Hide resolved
)

// OTLPAttributesSpec contains the configuration for a set of attributes
// to store them as index labels or Structured Metadata or drop them altogether.
periklis marked this conversation as resolved.
Show resolved Hide resolved
type OTLPAttributesSpec struct {
// Action defines the indexing action for the selected attributes.
//
// +optional
// +kubebuilder:validation:Optional
periklis marked this conversation as resolved.
Show resolved Hide resolved
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Action"
Action OTLPAttributeAction `json:"action,omitempty"`
periklis marked this conversation as resolved.
Show resolved Hide resolved

// Attributes is the list of attributes to configure indexing or drop them
// altogether.
periklis marked this conversation as resolved.
Show resolved Hide resolved
//
// +optional
// +kubebuilder:validation:Optional
periklis marked this conversation as resolved.
Show resolved Hide resolved
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Attributes"
periklis marked this conversation as resolved.
Show resolved Hide resolved
Attributes []string `json:"attributes,omitempty"`

// Regex to choose attributes to configure indexing or drop them
// altogether.
periklis marked this conversation as resolved.
Show resolved Hide resolved
//
// +optional
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Regex"
periklis marked this conversation as resolved.
Show resolved Hide resolved
Regex string `json:"regex,omitempty"`
}

// OTLPResourceAttributesSpec contains the configuration for resource attributes
// to store them as index labels or Structured Metadata or drop them altogether.
periklis marked this conversation as resolved.
Show resolved Hide resolved
type OTLPResourceAttributesSpec struct {
// IgnoreDefaults whether to ignore the default global list of resource attributes
// indexed as labels.
periklis marked this conversation as resolved.
Show resolved Hide resolved
//
// +optional
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch",displayName="Ignore Global Defaults"
IgnoreDefaults bool `json:"ignoreDefaults,omitempty"`

// Attributes contains the configuration for resource attributes
// to store them as index labels or Structured Metadata or drop them altogether.
periklis marked this conversation as resolved.
Show resolved Hide resolved
//
// +optional
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Attributes"
Attributes []OTLPAttributesSpec `json:"attributes,omitempty"`
}

// GlobalOTLPSpec defines which resource, scope and log attributes to
// be stored as index or structured metadata or drop altogether for all
// tenants.
type GlobalOTLPSpec struct {
// IndexedResourceAttributes contains the global configuration for resource attributes
// to store them as index labels or Structured Metadata or drop them altogether.
periklis marked this conversation as resolved.
Show resolved Hide resolved
//
// +optional
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Action"
periklis marked this conversation as resolved.
Show resolved Hide resolved
IndexedResourceAttributes []string `json:"indexedResourceAttributes,omitempty"`

OTLPSpec `json:",omitempty"`
}

// OTLPSpec defines which resource, scope and log attributes to
// be stored as index or structured metadata or drop altogether
type OTLPSpec struct {
// ResourceAttributes contains the configuration for resource attributes
// to store them as index labels or Structured Metadata or drop them altogether.
periklis marked this conversation as resolved.
Show resolved Hide resolved
//
// +optional
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Resource Attributes"
ResourceAttributes OTLPResourceAttributesSpec `json:"resourceAttributes,omitempty"`
periklis marked this conversation as resolved.
Show resolved Hide resolved

// ScopeAttributes contains the configuration for scope attributes
// to store them as index labels or Structured Metadata or drop them altogether.
periklis marked this conversation as resolved.
Show resolved Hide resolved
//
// +optional
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Scope Attributes"
ScopeAttributes []OTLPAttributesSpec `json:"scopeAttributes,omitempty"`

// LogAttributes contains the configuration for log attributes
// to store them as index labels or Structured Metadata or drop them altogether.
periklis marked this conversation as resolved.
Show resolved Hide resolved
//
// +optional
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Log Attributes"
LogAttributes []OTLPAttributesSpec `json:"logAttributes,omitempty"`
}

// RetentionStreamSpec defines a log stream with separate retention time.
type RetentionStreamSpec struct {
// Days contains the number of days logs are kept.
Expand Down Expand Up @@ -844,6 +950,14 @@ type LimitsTemplateSpec struct {
// +kubebuilder:validation:Optional
QueryLimits *QueryLimitSpec `json:"queries,omitempty"`

// OTLP to configure which resource, scope and log attributes
// to store as labels or structured metadata or drop them altogether
// for all tenants.
//
// +optional
// +kubebuilder:validation:Optional
OTLP *GlobalOTLPSpec `json:"otlp,omitempty"`

// Retention defines how long logs are kept in storage.
//
// +optional
Expand All @@ -865,6 +979,14 @@ type PerTenantLimitsTemplateSpec struct {
// +kubebuilder:validation:Optional
QueryLimits *PerTenantQueryLimitSpec `json:"queries,omitempty"`

// OTLP to configure which resource, scope and log attributes
// to store as labels or structured metadata or drop them altogether
// for a single tenants.
//
// +optional
// +kubebuilder:validation:Optional
OTLP *OTLPSpec `json:"otlp,omitempty"`

// Retention defines how long logs are kept in storage.
//
// +optional
Expand Down
103 changes: 103 additions & 0 deletions operator/apis/loki/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading