Skip to content

Commit

Permalink
Remove deprecated ruler_remote_write_headers
Browse files Browse the repository at this point in the history
  • Loading branch information
shantanualsi committed Nov 16, 2023
1 parent 95af9dc commit f68cffa
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 37 deletions.
5 changes: 0 additions & 5 deletions docs/sources/configure/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2793,11 +2793,6 @@ The `limits_config` block configures global and per-tenant limits in Loki.
# Disable recording rules remote-write.
[ruler_remote_write_disabled: <boolean>]

# Deprecated: Use 'ruler_remote_write_config' instead. Custom HTTP headers to be
# sent along with each remote write request. Be aware that headers that are set
# by Loki itself can't be overwritten.
[ruler_remote_write_headers: <headers>]

# Configures global and per-tenant limits for remote write clients. A map with
# remote client id as key.
ruler_remote_write_config:
Expand Down
1 change: 0 additions & 1 deletion pkg/ruler/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ type RulesLimits interface {
ruler.RulesLimits

RulerRemoteWriteDisabled(userID string) bool
RulerRemoteWriteHeaders(userID string) map[string]string
RulerRemoteWriteConfig(userID string, id string) *config.RemoteWriteConfig

RulerRemoteEvaluationTimeout(userID string) time.Duration
Expand Down
5 changes: 0 additions & 5 deletions pkg/ruler/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,6 @@ func (r *walRegistry) getTenantRemoteWriteConfig(tenant string, base RemoteWrite
// metadata is only used by prometheus scrape configs
clt.MetadataConfig = config.MetadataConfig{Send: false}

// overwrite, do not merge
if v := r.overrides.RulerRemoteWriteHeaders(tenant); v != nil {
clt.Headers = v
}

if v := r.overrides.RulerRemoteWriteConfig(tenant, id); v != nil {
// overwrite, do not merge
if v.Headers != nil {
Expand Down
10 changes: 0 additions & 10 deletions pkg/validation/limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,11 @@ type Limits struct {
RulerTenantShardSize int `yaml:"ruler_tenant_shard_size" json:"ruler_tenant_shard_size"`

// TODO(dannyk): add HTTP client overrides (basic auth / tls config, etc)
// Ruler remote-write limits.

// this field is the inversion of the general remote_write.enabled because the zero value of a boolean is false,
// and if it were ruler_remote_write_enabled, it would be impossible to know if the value was explicitly set or default
RulerRemoteWriteDisabled bool `yaml:"ruler_remote_write_disabled" json:"ruler_remote_write_disabled" doc:"description=Disable recording rules remote-write."`

// deprecated use RulerRemoteWriteConfig instead
RulerRemoteWriteHeaders OverwriteMarshalingStringMap `yaml:"ruler_remote_write_headers" json:"ruler_remote_write_headers" doc:"deprecated|description=Use 'ruler_remote_write_config' instead. Custom HTTP headers to be sent along with each remote write request. Be aware that headers that are set by Loki itself can't be overwritten."`

RulerRemoteWriteConfig map[string]config.RemoteWriteConfig `yaml:"ruler_remote_write_config,omitempty" json:"ruler_remote_write_config,omitempty" doc:"description=Configures global and per-tenant limits for remote write clients. A map with remote client id as key."`

// TODO(dannyk): possible enhancement is to align this with rule group interval
Expand Down Expand Up @@ -586,12 +582,6 @@ func (o *Overrides) RulerRemoteWriteDisabled(userID string) bool {
return o.getOverridesForUser(userID).RulerRemoteWriteDisabled
}

// Deprecated: use RulerRemoteWriteConfig instead
// RulerRemoteWriteHeaders returns the headers to use in a remote-write for a given user.
func (o *Overrides) RulerRemoteWriteHeaders(userID string) map[string]string {
return o.getOverridesForUser(userID).RulerRemoteWriteHeaders.Map()
}

// RulerRemoteWriteConfig returns the remote-write configurations to use for a given user and a given remote client.
func (o *Overrides) RulerRemoteWriteConfig(userID string, id string) *config.RemoteWriteConfig {
if c, ok := o.getOverridesForUser(userID).RulerRemoteWriteConfig[id]; ok {
Expand Down
104 changes: 94 additions & 10 deletions pkg/validation/limits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package validation

import (
"encoding/json"
"net/url"
"reflect"
"testing"
"time"

"github.com/pkg/errors"
promConfig "github.com/prometheus/common/config"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -168,10 +171,17 @@ func TestLimitsDoesNotMutate(t *testing.T) {
defer func() {
defaultLimits = initialDefault
}()

var remoteURL, _ = url.Parse("http://remote-write")
// Set new defaults with non-nil values for non-scalar types
newDefaults := Limits{
RulerRemoteWriteHeaders: OverwriteMarshalingStringMap{map[string]string{"a": "b"}},
RulerRemoteWriteConfig: map[string]config.RemoteWriteConfig{
"default": {
URL: &promConfig.URL{URL: remoteURL},
Headers: map[string]string{"a": "b"},
RemoteTimeout: model.Duration(30 * time.Second),
QueueConfig: defaultQueueConfig(),
},
},
StreamRetention: []StreamRetention{
{
Period: model.Duration(24 * time.Hour),
Expand All @@ -189,11 +199,30 @@ func TestLimitsDoesNotMutate(t *testing.T) {
{
desc: "map",
yaml: `
ruler_remote_write_headers:
foo: "bar"
ruler_remote_write_config:
tenant:
url: "http://remote-write"
headers:
foo: bar
`,
exp: Limits{
RulerRemoteWriteHeaders: OverwriteMarshalingStringMap{map[string]string{"foo": "bar"}},
RulerRemoteWriteConfig: map[string]config.RemoteWriteConfig{
"default": {
URL: &promConfig.URL{URL: remoteURL},
Headers: map[string]string{"a": "b"},
QueueConfig: config.DefaultQueueConfig,
MetadataConfig: config.DefaultMetadataConfig,
RemoteTimeout: model.Duration(30000000000),
},
"tenant": {
URL: &promConfig.URL{URL: remoteURL},
HTTPClientConfig: promConfig.DefaultHTTPClientConfig,
Headers: map[string]string{"foo": "bar"},
QueueConfig: config.DefaultQueueConfig,
MetadataConfig: config.DefaultMetadataConfig,
RemoteTimeout: model.Duration(30000000000),
},
},

// Rest from new defaults
StreamRetention: []StreamRetention{
Expand All @@ -207,10 +236,28 @@ ruler_remote_write_headers:
{
desc: "empty map overrides defaults",
yaml: `
ruler_remote_write_headers:
ruler_remote_write_config:
tenant:
url: "http://remote-write"
headers:
`,
exp: Limits{

RulerRemoteWriteConfig: map[string]config.RemoteWriteConfig{
"default": {
URL: &promConfig.URL{URL: remoteURL},
Headers: map[string]string{"a": "b"},
QueueConfig: config.DefaultQueueConfig,
MetadataConfig: config.DefaultMetadataConfig,
RemoteTimeout: model.Duration(30000000000),
},
"tenant": {
URL: &promConfig.URL{URL: remoteURL},
HTTPClientConfig: promConfig.DefaultHTTPClientConfig,
QueueConfig: config.DefaultQueueConfig,
MetadataConfig: config.DefaultMetadataConfig,
RemoteTimeout: model.Duration(30000000000),
},
},
// Rest from new defaults
StreamRetention: []StreamRetention{
{
Expand All @@ -236,7 +283,15 @@ retention_stream:
},

// Rest from new defaults
RulerRemoteWriteHeaders: OverwriteMarshalingStringMap{map[string]string{"a": "b"}},
RulerRemoteWriteConfig: map[string]config.RemoteWriteConfig{
"default": {
URL: &promConfig.URL{URL: remoteURL},
Headers: map[string]string{"a": "b"},
QueueConfig: config.DefaultQueueConfig,
MetadataConfig: config.DefaultMetadataConfig,
RemoteTimeout: model.Duration(30000000000),
},
},
},
},
{
Expand All @@ -248,7 +303,15 @@ reject_old_samples: true
RejectOldSamples: true,

// Rest from new defaults
RulerRemoteWriteHeaders: OverwriteMarshalingStringMap{map[string]string{"a": "b"}},
RulerRemoteWriteConfig: map[string]config.RemoteWriteConfig{
"default": {
URL: &promConfig.URL{URL: remoteURL},
Headers: map[string]string{"a": "b"},
QueueConfig: config.DefaultQueueConfig,
MetadataConfig: config.DefaultMetadataConfig,
RemoteTimeout: model.Duration(30000000000),
},
},
StreamRetention: []StreamRetention{
{
Period: model.Duration(24 * time.Hour),
Expand All @@ -266,7 +329,15 @@ query_timeout: 5m
QueryTimeout: model.Duration(5 * time.Minute),

// Rest from new defaults.
RulerRemoteWriteHeaders: OverwriteMarshalingStringMap{map[string]string{"a": "b"}},
RulerRemoteWriteConfig: map[string]config.RemoteWriteConfig{
"default": {
URL: &promConfig.URL{URL: remoteURL},
Headers: map[string]string{"a": "b"},
QueueConfig: config.DefaultQueueConfig,
MetadataConfig: config.DefaultMetadataConfig,
RemoteTimeout: model.Duration(30000000000),
},
},
StreamRetention: []StreamRetention{
{
Period: model.Duration(24 * time.Hour),
Expand Down Expand Up @@ -299,3 +370,16 @@ func TestLimitsValidation(t *testing.T) {
require.True(t, errors.Is(limits.Validate(), tc.expected))
}
}

func defaultQueueConfig() config.QueueConfig {
return config.QueueConfig{
Capacity: 10000,
MaxShards: 50,
MinShards: 1,
MaxSamplesPerSend: 2000,
BatchSendDeadline: model.Duration(5 * time.Second),
MinBackoff: model.Duration(30 * time.Millisecond),
MaxBackoff: model.Duration(5 * time.Second),
RetryOnRateLimit: false,
}
}
3 changes: 0 additions & 3 deletions tools/deprecated-config-checker/checker/checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ var (
"storage_config.aws.dynamodb",
"chunk_store_config.write_dedupe_cache_config",
"limits_config.unordered_writes",
"limits_config.ruler_remote_write_headers",
"limits_config.per_tenant_override_config",
"limits_config.per_tenant_override_period",
"limits_config.allow_deletes",
Expand Down Expand Up @@ -79,12 +78,10 @@ var (

expectedRuntimeConfigDeprecates = []string{
"overrides.foo.unordered_writes",
"overrides.foo.ruler_remote_write_headers",
"overrides.foo.per_tenant_override_config",
"overrides.foo.per_tenant_override_period",
"overrides.foo.allow_deletes",
"overrides.bar.unordered_writes",
"overrides.bar.ruler_remote_write_headers",
"overrides.bar.per_tenant_override_config",
"overrides.bar.per_tenant_override_period",
"overrides.bar.allow_deletes",
Expand Down
1 change: 0 additions & 1 deletion tools/deprecated-config-checker/deprecated-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ chunk_store_config:
## NOTE: This will also be used to validate per-tenant overrides.
limits_config:
unordered_writes: "Will be eventually removed."
ruler_remote_write_headers: "Use ruler_remote_write_config instead."
per_tenant_override_config: "Feature renamed to 'runtime configuration', flag deprecated in favor of runtime_config.file"
per_tenant_override_period: "Feature renamed to 'runtime configuration', flag deprecated in favor of runtime_config.period"
allow_deletes: "Use deletion_mode per tenant configuration instead."
1 change: 0 additions & 1 deletion tools/deprecated-config-checker/test-fixtures/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ limits_config:
unordered_writes: true # DEPRECATED
enforce_metric_name: true # DELETED
ruler_evaluation_delay_duration: 1m # DELETED
ruler_remote_write_headers: ["foo", "bar"] # DEPRECATED
per_tenant_override_config: ./overrides.yaml # DEPRECATED
per_tenant_override_period: 5s # DEPRECATED
allow_deletes: true # DEPRECATED
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ overrides:
unordered_writes: true # DEPRECATED
enforce_metric_name: true # DELETED
ruler_evaluation_delay_duration: 1m # DELETED
ruler_remote_write_headers: [ "foo", "bar" ] # DEPRECATED
per_tenant_override_config: ./overrides.yaml # DEPRECATED
per_tenant_override_period: 5s # DEPRECATED
allow_deletes: true # DEPRECATED
Expand Down

0 comments on commit f68cffa

Please sign in to comment.