-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Register the add_formatted_index as a usable processor. (#33800)
* Register the add_formatted_index as a usage processor for the processors list. * Re-add removed file. * Add changelog entry. * Add missing return in String(). * Change implementation to use a boolean.
- Loading branch information
1 parent
f24756d
commit cb0eb64
Showing
6 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// 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 add_formatted_index | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/elastic/beats/v7/libbeat/common/fmtstr" | ||
) | ||
|
||
// configuration for AddFormattedIndex processor. | ||
type config struct { | ||
Index *fmtstr.TimestampFormatString `config:"index"` // Index formatted string value | ||
} | ||
|
||
// Validate ensures that the configuration is valid. | ||
func (c *config) Validate() error { | ||
// Validate type of ID generator | ||
if c.Index == nil { | ||
return errors.New("index field is required") | ||
} | ||
|
||
return nil | ||
} |
23 changes: 23 additions & 0 deletions
23
libbeat/processors/add_formatted_index/docs/add_formatted_index.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[[add-locale]] | ||
=== Add formatted index | ||
|
||
++++ | ||
<titleabbrev>add_formatted_index</titleabbrev> | ||
++++ | ||
|
||
The `add_formatted_index` processor allows the destination index for the event to | ||
be changed based on a formatted string that can use values from fields defined on | ||
the event. | ||
|
||
For example, this configuration uses a custom field, fields.log_type, to set the index: | ||
|
||
[source,yaml] | ||
------------------------------------------------------------------------------- | ||
processors: | ||
- add_formatted_index: | ||
index: "%{[fields.log_type]}-%{[agent.version]}-%{+yyyy.MM.dd}" | ||
------------------------------------------------------------------------------- | ||
|
||
With this configuration, all events with log_type: normal are sent to an index named | ||
normal-7.10.2-2022-11-18, and all events with log_type: critical are sent to an index | ||
named critical-7.10.2-2022-11-18. |