Skip to content

Commit

Permalink
Update setup.ilm.check_exists documentation (#37430)
Browse files Browse the repository at this point in the history
This commit updates the documentation from `setup.ilm.check_exists` in
our reference configuration files to better explain how it works and
align the wording with our public documentation.

---------

Co-authored-by: Shaunak Kashyap <[email protected]>
(cherry picked from commit 33ca67e)

# Conflicts:
#	libbeat/idxmgmt/lifecycle/config.go
  • Loading branch information
belimawr authored and mergify[bot] committed Feb 13, 2024
1 parent b7309bd commit 3c2428a
Show file tree
Hide file tree
Showing 16 changed files with 177 additions and 45 deletions.
6 changes: 3 additions & 3 deletions auditbeat/auditbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1281,9 +1281,9 @@ setup.template.settings:
# to load your own lifecycle policy.
#setup.ilm.policy_file:

# Disable the check for an existing lifecycle policy. The default is true. If
# you disable this check, set setup.ilm.overwrite: true so the lifecycle policy
# can be installed.
# Disable the check for an existing lifecycle policy. The default is true.
# If you set this option to false, lifecycle policy will not be installed,
# even if setup.ilm.overwrite is set to true.
#setup.ilm.check_exists: true

# Overwrite the lifecycle policy at startup. The default is false.
Expand Down
6 changes: 3 additions & 3 deletions filebeat/filebeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2305,9 +2305,9 @@ setup.template.settings:
# to load your own lifecycle policy.
#setup.ilm.policy_file:

# Disable the check for an existing lifecycle policy. The default is true. If
# you disable this check, set setup.ilm.overwrite: true so the lifecycle policy
# can be installed.
# Disable the check for an existing lifecycle policy. The default is true.
# If you set this option to false, lifecycle policy will not be installed,
# even if setup.ilm.overwrite is set to true.
#setup.ilm.check_exists: true

# Overwrite the lifecycle policy at startup. The default is false.
Expand Down
6 changes: 3 additions & 3 deletions heartbeat/heartbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1426,9 +1426,9 @@ setup.template.settings:
# to load your own lifecycle policy.
#setup.ilm.policy_file:

# Disable the check for an existing lifecycle policy. The default is true. If
# you disable this check, set setup.ilm.overwrite: true so the lifecycle policy
# can be installed.
# Disable the check for an existing lifecycle policy. The default is true.
# If you set this option to false, lifecycle policy will not be installed,
# even if setup.ilm.overwrite is set to true.
#setup.ilm.check_exists: true

# Overwrite the lifecycle policy at startup. The default is false.
Expand Down
6 changes: 3 additions & 3 deletions libbeat/_meta/config/setup.ilm.reference.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
# to load your own lifecycle policy.
#setup.ilm.policy_file:

# Disable the check for an existing lifecycle policy. The default is true. If
# you disable this check, set setup.ilm.overwrite: true so the lifecycle policy
# can be installed.
# Disable the check for an existing lifecycle policy. The default is true.
# If you set this option to false, lifecycle policy will not be installed,
# even if setup.ilm.overwrite is set to true.
#setup.ilm.check_exists: true

# Overwrite the lifecycle policy at startup. The default is false.
Expand Down
132 changes: 132 additions & 0 deletions libbeat/idxmgmt/lifecycle/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
// Licensed to Elasticsearch B.V. under one or more contributor

Check failure on line 1 in libbeat/idxmgmt/lifecycle/config.go

View workflow job for this annotation

GitHub Actions / lint (windows)

: # github.com/elastic/beats/v7/libbeat/idxmgmt/lifecycle

Check failure on line 1 in libbeat/idxmgmt/lifecycle/config.go

View workflow job for this annotation

GitHub Actions / lint (linux)

: # github.com/elastic/beats/v7/libbeat/idxmgmt/lifecycle

Check failure on line 1 in libbeat/idxmgmt/lifecycle/config.go

View workflow job for this annotation

GitHub Actions / lint (darwin)

: # github.com/elastic/beats/v7/libbeat/idxmgmt/lifecycle
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package lifecycle

import (
"github.com/elastic/beats/v7/libbeat/beat"
"github.com/elastic/beats/v7/libbeat/common/fmtstr"
"github.com/elastic/elastic-agent-libs/config"
"github.com/elastic/elastic-agent-libs/mapstr"
)

// Config is used for unpacking a config.C.
type Config struct {
Enabled bool `config:"enabled"`
// PolicyName, used by ILM
PolicyName fmtstr.EventFormatString `config:"policy_name"`
PolicyFile string `config:"policy_file"`
// used only for testing
policyRaw *Policy

Check failure on line 34 in libbeat/idxmgmt/lifecycle/config.go

View workflow job for this annotation

GitHub Actions / lint (windows)

undefined: Policy (typecheck)

Check failure on line 34 in libbeat/idxmgmt/lifecycle/config.go

View workflow job for this annotation

GitHub Actions / lint (linux)

undefined: Policy (typecheck)

Check failure on line 34 in libbeat/idxmgmt/lifecycle/config.go

View workflow job for this annotation

GitHub Actions / lint (darwin)

undefined: Policy (typecheck)

// CheckExists can disable the check for an existing policy. This check
// requires read_ilm privileges. If CheckExists is set to false, the policy
// will not be installed, even if Overwrite is enabled.
CheckExists bool `config:"check_exists"`

// Enable always overwrite policy mode. This required manage_ilm privileges.
Overwrite bool `config:"overwrite"`
}

// DSLNameConfig just stores the datastream name for the DSL policy
// as this is the only config value that differs between ILM and DSL
type DSLNameConfig struct {
DataStreamPattern fmtstr.EventFormatString `config:"data_stream_pattern"`
}

func DefaultDSLName() DSLNameConfig {
return DSLNameConfig{
DataStreamPattern: *fmtstr.MustCompileEvent("%{[beat.name]}-%{[beat.version]}"),
}
}

// LifecycleConfig maps all possible ILM/DSL config values present in a config
type LifecycleConfig struct {
ILM Config `config:"setup.ilm"`
DSL Config `config:"setup.dsl"`
}

// RawConfig half-unpacks the policy config, allowing us to tell if a user has explicitly
// enabled a given config value
type RawConfig struct {
ILM *config.C `config:"setup.ilm"`
DSL *config.C `config:"setup.dsl"`
TemplateName string `config:"setup.template.name"`
}

// DefaultILMPolicy defines the default policy to be used if no custom policy is
// configured.
// By default the policy contains not warm, cold, or delete phase.
// The index is configured to rollover every 50GB or after 30d.
var DefaultILMPolicy = mapstr.M{
"policy": mapstr.M{
"phases": mapstr.M{
"hot": mapstr.M{
"actions": mapstr.M{
"rollover": mapstr.M{
"max_primary_shard_size": "50gb",
"max_age": "30d",
},
},
},
},
},
}

// DefaultDSLPolicy defines the default policy to be used for DSL if
// no custom policy is configured
var DefaultDSLPolicy = mapstr.M{
"data_retention": "7d",
}

// Validate verifies that expected config options are given and valid
func (cfg *Config) Validate() error {
return nil
}

func DefaultILMConfig(info beat.Info) LifecycleConfig {
return LifecycleConfig{
ILM: Config{
Enabled: true,
PolicyName: *fmtstr.MustCompileEvent(info.Beat),
PolicyFile: "",
CheckExists: true,
},
DSL: Config{
Enabled: false,
PolicyName: *fmtstr.MustCompileEvent("%{[beat.name]}-%{[beat.version]}"),
CheckExists: true,
},
}
}

func DefaultDSLConfig(info beat.Info) LifecycleConfig {
return LifecycleConfig{
ILM: Config{
Enabled: false,
PolicyName: *fmtstr.MustCompileEvent(info.Beat),
PolicyFile: "",
CheckExists: true,
},
DSL: Config{
Enabled: true,
PolicyName: *fmtstr.MustCompileEvent("%{[beat.name]}-%{[beat.version]}"),
PolicyFile: "",
CheckExists: true,
},
}
}
6 changes: 3 additions & 3 deletions metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2093,9 +2093,9 @@ setup.template.settings:
# to load your own lifecycle policy.
#setup.ilm.policy_file:

# Disable the check for an existing lifecycle policy. The default is true. If
# you disable this check, set setup.ilm.overwrite: true so the lifecycle policy
# can be installed.
# Disable the check for an existing lifecycle policy. The default is true.
# If you set this option to false, lifecycle policy will not be installed,
# even if setup.ilm.overwrite is set to true.
#setup.ilm.check_exists: true

# Overwrite the lifecycle policy at startup. The default is false.
Expand Down
6 changes: 3 additions & 3 deletions packetbeat/packetbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1775,9 +1775,9 @@ setup.template.settings:
# to load your own lifecycle policy.
#setup.ilm.policy_file:

# Disable the check for an existing lifecycle policy. The default is true. If
# you disable this check, set setup.ilm.overwrite: true so the lifecycle policy
# can be installed.
# Disable the check for an existing lifecycle policy. The default is true.
# If you set this option to false, lifecycle policy will not be installed,
# even if setup.ilm.overwrite is set to true.
#setup.ilm.check_exists: true

# Overwrite the lifecycle policy at startup. The default is false.
Expand Down
6 changes: 3 additions & 3 deletions winlogbeat/winlogbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1211,9 +1211,9 @@ setup.template.settings:
# to load your own lifecycle policy.
#setup.ilm.policy_file:

# Disable the check for an existing lifecycle policy. The default is true. If
# you disable this check, set setup.ilm.overwrite: true so the lifecycle policy
# can be installed.
# Disable the check for an existing lifecycle policy. The default is true.
# If you set this option to false, lifecycle policy will not be installed,
# even if setup.ilm.overwrite is set to true.
#setup.ilm.check_exists: true

# Overwrite the lifecycle policy at startup. The default is false.
Expand Down
6 changes: 3 additions & 3 deletions x-pack/auditbeat/auditbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1337,9 +1337,9 @@ setup.template.settings:
# to load your own lifecycle policy.
#setup.ilm.policy_file:

# Disable the check for an existing lifecycle policy. The default is true. If
# you disable this check, set setup.ilm.overwrite: true so the lifecycle policy
# can be installed.
# Disable the check for an existing lifecycle policy. The default is true.
# If you set this option to false, lifecycle policy will not be installed,
# even if setup.ilm.overwrite is set to true.
#setup.ilm.check_exists: true

# Overwrite the lifecycle policy at startup. The default is false.
Expand Down
6 changes: 3 additions & 3 deletions x-pack/filebeat/filebeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4566,9 +4566,9 @@ setup.template.settings:
# to load your own lifecycle policy.
#setup.ilm.policy_file:

# Disable the check for an existing lifecycle policy. The default is true. If
# you disable this check, set setup.ilm.overwrite: true so the lifecycle policy
# can be installed.
# Disable the check for an existing lifecycle policy. The default is true.
# If you set this option to false, lifecycle policy will not be installed,
# even if setup.ilm.overwrite is set to true.
#setup.ilm.check_exists: true

# Overwrite the lifecycle policy at startup. The default is false.
Expand Down
6 changes: 3 additions & 3 deletions x-pack/functionbeat/functionbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1079,9 +1079,9 @@ setup.template.settings:
# to load your own lifecycle policy.
#setup.ilm.policy_file:

# Disable the check for an existing lifecycle policy. The default is true. If
# you disable this check, set setup.ilm.overwrite: true so the lifecycle policy
# can be installed.
# Disable the check for an existing lifecycle policy. The default is true.
# If you set this option to false, lifecycle policy will not be installed,
# even if setup.ilm.overwrite is set to true.
#setup.ilm.check_exists: true

# Overwrite the lifecycle policy at startup. The default is false.
Expand Down
6 changes: 3 additions & 3 deletions x-pack/heartbeat/heartbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1426,9 +1426,9 @@ setup.template.settings:
# to load your own lifecycle policy.
#setup.ilm.policy_file:

# Disable the check for an existing lifecycle policy. The default is true. If
# you disable this check, set setup.ilm.overwrite: true so the lifecycle policy
# can be installed.
# Disable the check for an existing lifecycle policy. The default is true.
# If you set this option to false, lifecycle policy will not be installed,
# even if setup.ilm.overwrite is set to true.
#setup.ilm.check_exists: true

# Overwrite the lifecycle policy at startup. The default is false.
Expand Down
6 changes: 3 additions & 3 deletions x-pack/metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2624,9 +2624,9 @@ setup.template.settings:
# to load your own lifecycle policy.
#setup.ilm.policy_file:

# Disable the check for an existing lifecycle policy. The default is true. If
# you disable this check, set setup.ilm.overwrite: true so the lifecycle policy
# can be installed.
# Disable the check for an existing lifecycle policy. The default is true.
# If you set this option to false, lifecycle policy will not be installed,
# even if setup.ilm.overwrite is set to true.
#setup.ilm.check_exists: true

# Overwrite the lifecycle policy at startup. The default is false.
Expand Down
6 changes: 3 additions & 3 deletions x-pack/osquerybeat/osquerybeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -798,9 +798,9 @@ setup.template.settings:
# to load your own lifecycle policy.
#setup.ilm.policy_file:

# Disable the check for an existing lifecycle policy. The default is true. If
# you disable this check, set setup.ilm.overwrite: true so the lifecycle policy
# can be installed.
# Disable the check for an existing lifecycle policy. The default is true.
# If you set this option to false, lifecycle policy will not be installed,
# even if setup.ilm.overwrite is set to true.
#setup.ilm.check_exists: true

# Overwrite the lifecycle policy at startup. The default is false.
Expand Down
6 changes: 3 additions & 3 deletions x-pack/packetbeat/packetbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1775,9 +1775,9 @@ setup.template.settings:
# to load your own lifecycle policy.
#setup.ilm.policy_file:

# Disable the check for an existing lifecycle policy. The default is true. If
# you disable this check, set setup.ilm.overwrite: true so the lifecycle policy
# can be installed.
# Disable the check for an existing lifecycle policy. The default is true.
# If you set this option to false, lifecycle policy will not be installed,
# even if setup.ilm.overwrite is set to true.
#setup.ilm.check_exists: true

# Overwrite the lifecycle policy at startup. The default is false.
Expand Down
6 changes: 3 additions & 3 deletions x-pack/winlogbeat/winlogbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1254,9 +1254,9 @@ setup.template.settings:
# to load your own lifecycle policy.
#setup.ilm.policy_file:

# Disable the check for an existing lifecycle policy. The default is true. If
# you disable this check, set setup.ilm.overwrite: true so the lifecycle policy
# can be installed.
# Disable the check for an existing lifecycle policy. The default is true.
# If you set this option to false, lifecycle policy will not be installed,
# even if setup.ilm.overwrite is set to true.
#setup.ilm.check_exists: true

# Overwrite the lifecycle policy at startup. The default is false.
Expand Down

0 comments on commit 3c2428a

Please sign in to comment.