-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[abandoned][es] Add index rollover mode that can choose day and hour #2935
Changes from all commits
328939c
9e49fc7
1e2affd
ff61a02
29ca0e1
0435ed9
b79d7a7
7e564d4
5824c2e
6d8982f
c8e5556
278203c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ package es | |
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"strings" | ||
"time" | ||
|
||
|
@@ -29,42 +28,45 @@ import ( | |
) | ||
|
||
const ( | ||
suffixUsername = ".username" | ||
suffixPassword = ".password" | ||
suffixSniffer = ".sniffer" | ||
suffixSnifferTLSEnabled = ".sniffer-tls-enabled" | ||
suffixTokenPath = ".token-file" | ||
suffixServerURLs = ".server-urls" | ||
suffixRemoteReadClusters = ".remote-read-clusters" | ||
suffixMaxSpanAge = ".max-span-age" | ||
suffixNumShards = ".num-shards" | ||
suffixNumReplicas = ".num-replicas" | ||
suffixBulkSize = ".bulk.size" | ||
suffixBulkWorkers = ".bulk.workers" | ||
suffixBulkActions = ".bulk.actions" | ||
suffixBulkFlushInterval = ".bulk.flush-interval" | ||
suffixTimeout = ".timeout" | ||
suffixIndexPrefix = ".index-prefix" | ||
suffixIndexDateSeparator = ".index-date-separator" | ||
suffixTagsAsFields = ".tags-as-fields" | ||
suffixTagsAsFieldsAll = suffixTagsAsFields + ".all" | ||
suffixTagsAsFieldsInclude = suffixTagsAsFields + ".include" | ||
suffixTagsFile = suffixTagsAsFields + ".config-file" | ||
suffixTagDeDotChar = suffixTagsAsFields + ".dot-replacement" | ||
suffixReadAlias = ".use-aliases" | ||
suffixUseILM = ".use-ilm" | ||
suffixCreateIndexTemplate = ".create-index-templates" | ||
suffixEnabled = ".enabled" | ||
suffixVersion = ".version" | ||
suffixMaxDocCount = ".max-doc-count" | ||
suffixLogLevel = ".log-level" | ||
suffixUsername = ".username" | ||
suffixPassword = ".password" | ||
suffixSniffer = ".sniffer" | ||
suffixSnifferTLSEnabled = ".sniffer-tls-enabled" | ||
suffixTokenPath = ".token-file" | ||
suffixServerURLs = ".server-urls" | ||
suffixRemoteReadClusters = ".remote-read-clusters" | ||
suffixMaxSpanAge = ".max-span-age" | ||
suffixNumShards = ".num-shards" | ||
suffixNumReplicas = ".num-replicas" | ||
suffixBulkSize = ".bulk.size" | ||
suffixBulkWorkers = ".bulk.workers" | ||
suffixBulkActions = ".bulk.actions" | ||
suffixBulkFlushInterval = ".bulk.flush-interval" | ||
suffixTimeout = ".timeout" | ||
suffixIndexPrefix = ".index-prefix" | ||
suffixIndexDateSeparator = ".index-date-separator" | ||
suffixIndexRolloverFrequency = ".index-rollover-frequency" | ||
suffixTagsAsFields = ".tags-as-fields" | ||
suffixTagsAsFieldsAll = suffixTagsAsFields + ".all" | ||
suffixTagsAsFieldsInclude = suffixTagsAsFields + ".include" | ||
suffixTagsFile = suffixTagsAsFields + ".config-file" | ||
suffixTagDeDotChar = suffixTagsAsFields + ".dot-replacement" | ||
suffixReadAlias = ".use-aliases" | ||
suffixUseILM = ".use-ilm" | ||
suffixCreateIndexTemplate = ".create-index-templates" | ||
suffixEnabled = ".enabled" | ||
suffixVersion = ".version" | ||
suffixMaxDocCount = ".max-doc-count" | ||
suffixLogLevel = ".log-level" | ||
// default number of documents to return from a query (elasticsearch allowed limit) | ||
// see search.max_buckets and index.max_result_window | ||
defaultMaxDocCount = 10_000 | ||
defaultServerURL = "http://127.0.0.1:9200" | ||
defaultRemoteReadClusters = "" | ||
// default separator for Elasticsearch index date layout. | ||
defaultIndexDateSeparator = "-" | ||
|
||
defaultIndexRolloverFrequency = "day" | ||
) | ||
|
||
// TODO this should be moved next to config.Configuration struct (maybe ./flags package) | ||
|
@@ -205,7 +207,12 @@ func addFlags(flagSet *flag.FlagSet, nsConfig *namespaceConfig) { | |
flagSet.String( | ||
nsConfig.namespace+suffixIndexDateSeparator, | ||
defaultIndexDateSeparator, | ||
"Optional date separator of Jaeger indices. For example \".\" creates \"jaeger-span-2020.11.20 \".") | ||
"Optional date separator of Jaeger indices. For example \".\" creates \"jaeger-span-2020.11.20\".") | ||
flagSet.String( | ||
nsConfig.namespace+suffixIndexRolloverFrequency, | ||
defaultIndexRolloverFrequency, | ||
"Rotates Jaeger indices over the given period. For example \"day\" creates \"jaeger-span-yyyy-MM-dd\" every day after UTC 12AM. Valid options: [hour, day]. "+ | ||
"Jaeger additionally supports manual and automated (via ILM) index management. Reference: https://www.jaegertracing.io/docs/deployment/#elasticsearch-rollover.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is confusing. Doesn't this day/hour enhancement classifies as "manual"? If not, what other "manual" rollover are we referring to? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "manual" here refers to the esRollover/Cleaner python scripts that are used to manually rollover/delete an index (automated via cronjobs). This day/hour enhancement is a simple and convenient way to rollover an index by duration only and lacks the ability to:
Both the esRollover/Cleaner python scripts and ILM (supported in Jaeger) provide the above, which is why I suggested the term "index management" here because I consider these as complete index management solutions and want users to be aware of these more comprehensive but "higher-effort" alternatives. Agree this is confusing, perhaps we could rephrase to: "This does not delete old indices. For details on complete index management solutions supported by Jaeger, refer to: https://www.jaegertracing.io/docs/deployment/#elasticsearch-rollover". Open to suggestions. |
||
flagSet.Bool( | ||
nsConfig.namespace+suffixTagsAsFieldsAll, | ||
nsConfig.Tags.AllAsFields, | ||
|
@@ -295,7 +302,6 @@ func initFromViper(cfg *namespaceConfig, v *viper.Viper) { | |
cfg.BulkFlushInterval = v.GetDuration(cfg.namespace + suffixBulkFlushInterval) | ||
cfg.Timeout = v.GetDuration(cfg.namespace + suffixTimeout) | ||
cfg.IndexPrefix = v.GetString(cfg.namespace + suffixIndexPrefix) | ||
cfg.IndexDateLayout = initDateLayout(v.GetString(cfg.namespace + suffixIndexDateSeparator)) | ||
cfg.Tags.AllAsFields = v.GetBool(cfg.namespace + suffixTagsAsFieldsAll) | ||
cfg.Tags.Include = v.GetString(cfg.namespace + suffixTagsAsFieldsInclude) | ||
cfg.Tags.File = v.GetString(cfg.namespace + suffixTagsFile) | ||
|
@@ -317,6 +323,10 @@ func initFromViper(cfg *namespaceConfig, v *viper.Viper) { | |
if len(remoteReadClusters) > 0 { | ||
cfg.RemoteReadClusters = strings.Split(remoteReadClusters, ",") | ||
} | ||
|
||
rolloverFreq := strings.ToLower(v.GetString(cfg.namespace + suffixIndexRolloverFrequency)) | ||
separator := v.GetString(cfg.namespace + suffixIndexDateSeparator) | ||
cfg.IndexDateLayout = initDateLayout(rolloverFreq, separator) | ||
} | ||
|
||
// GetPrimary returns primary configuration. | ||
|
@@ -343,6 +353,11 @@ func stripWhiteSpace(str string) string { | |
return strings.Replace(str, " ", "", -1) | ||
} | ||
|
||
func initDateLayout(separator string) string { | ||
return fmt.Sprintf("2006%s01%s02", separator, separator) | ||
func initDateLayout(rolloverFreq, sep string) string { | ||
// default to daily format | ||
indexLayout := "2006" + sep + "01" + sep + "02" | ||
if rolloverFreq == "hour" { | ||
indexLayout = indexLayout + sep + "15" | ||
} | ||
return indexLayout | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest adding more detailed explanation to the website (for next release) and linking there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1