-
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
Conversation
Signed-off-by: WalkerWang731 <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #2935 +/- ##
==========================================
+ Coverage 95.95% 95.97% +0.02%
==========================================
Files 223 223
Lines 9712 9726 +14
==========================================
+ Hits 9319 9335 +16
Misses 324 324
+ Partials 69 67 -2
Continue to review full report at Codecov.
|
Sorry for the slow response, I can take a look at this tomorrow. |
Actually, just only This is our temporary solution, I know is not graceful solution
btw, although, we can not separate so, above is my thought, for your information. |
Thanks @WalkerWang731 , have you considered the esRollover functionality available in Jaeger? There is also support for Elasticsearch's ILM functionality that is a bit more sophisticated, providing automated rollover without the need for a cron job to execute the rollover as is required with I believe both approaches support rollover by time units (days, hours, minutes), number of documents or by size. |
Thanks @albertteoh , For the Elasticsearch's ILM functionality and esRollover functionality available in Jaeger they looks good.
So, although the solution of this commit is not the most perfect, but the operation of the rotation is also simplified as much as possible to provide users with a simpler way. And maybe we can add the other two ways in the help text. Actually, this commit part will not have any impact on the code structure, which is a minor change, But I have to say I'm really not sure whether need to merge, need your review and assessment, I just want to give a simple way to rotate the index. Thanks, above are my suggestions, for your information. |
How do you plan to delete old indices? It seems having too many indices can impact shard performance. |
Yes, more shards will impact ES performance, delete old indices can use |
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.
@bhiravabhatla, please remind us why Jaeger's ILM support was limited to ES 7 and does not supported for ES 6's ILM feature?
I would prefer users adopt a single index management solution for rollover and cleanup (either via scripts+cronjob or ILM) rather than require setting a flag + ILM policy for cleanup.
However, I appreciate using esRollover/Cleaner scripts needs a bit more effort on setup and maintenance, and ILM is limited to version 7.
If we determine that ILM isn't feasible in ES 6, this proposal is okay with me so long as we document usage and the recommended alternatives clearly both here and in the official documentation.
plugin/storage/es/options.go
Outdated
flagSet.String( | ||
nsConfig.namespace+suffixIndexRotate, | ||
defaultIndexRotate, | ||
"Optional rotation opportunity of Jaeger indices. For example \"day\" creates \"jaeger-span-yyyy-HH-dd\" every day after UTC 12AM. Valid opportunity: [hour, day]") |
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.
s/Optional rotation opportunity of Jaeger indices/Rotates Jaeger indices over the given period/
s/Valid opportunity/Valid options/
As you suggested, I would add a reference to the alternative esRollover and ILM solutions.
plugin/storage/es/options.go
Outdated
|
||
indexRotate := strings.ToLower(v.GetString(cfg.namespace + suffixIndexRotate)) | ||
|
||
switch indexRotate { |
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.
Maybe we can DRY and simplify to something like:
separator := v.GetString(cfg.namespace + suffixIndexDateSeparator)
rotateBy := strings.ToLower(v.GetString(cfg.namespace + suffixIndexRotate))
cfg.IndexDateLayout = initDateLayout(rotateBy, separator)
...
func initDateLayout(rotateBy, separator string) string {
seps := []interface{}{separator, separator}
indexLayout := "2006%s01%s02"
if rotateBy == "hour" {
indexLayout = "2006%s01%s02%s15"
seps = append(seps, separator)
}
return fmt.Sprintf(indexLayout, seps...)
}
pkg/es/config/config.go
Outdated
@@ -63,6 +63,7 @@ type Configuration struct { | |||
BulkFlushInterval time.Duration `mapstructure:"-"` | |||
IndexPrefix string `mapstructure:"index_prefix"` | |||
IndexDateLayout string `mapstructure:"index_date_layout"` | |||
IndexRotate string `mapstructure:"-"` |
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.
ES uses the term Rollover
, I think we should stay consistent with terminology.
@@ -200,8 +200,12 @@ func timeRangeIndices(indexName, indexDateLayout string, startTime time.Time, en | |||
firstIndex := indexWithDate(indexName, indexDateLayout, startTime) | |||
currentIndex := indexWithDate(indexName, indexDateLayout, endTime) | |||
for currentIndex != firstIndex { | |||
indices = append(indices, currentIndex) | |||
endTime = endTime.Add(-24 * time.Hour) | |||
if len(indices) == 0 { |
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.
Could be simplified:
if len(indices) == 0 || indices[len(indices)-1] != currentIndex {
indices = append(indices, currentIndex)
}
@albertteoh Another reason is is_write_index is only supported for ES Versions > 6.4. We use is_write_index for ILM implementation. |
Signed-off-by: WalkerWang731 <[email protected]>
Hi, @albertteoh
|
plugin/storage/es/options.go
Outdated
flagSet.String( | ||
nsConfig.namespace+suffixIndexRollover, | ||
defaultIndexRollover, | ||
"Rotates Jaeger indices over the given period. For example \"day\" creates \"jaeger-span-yyyy-HH-dd\" every day after UTC 12AM. Valid options: [hour, day]. "+ |
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.
Rollover Jaeger indices for the given period.
s/jaeger-span-yyyy-HH-dd/jaeger-span-yyyy-MM-dd/
plugin/storage/es/options.go
Outdated
nsConfig.namespace+suffixIndexRollover, | ||
defaultIndexRollover, | ||
"Rotates Jaeger indices over the given period. For example \"day\" creates \"jaeger-span-yyyy-HH-dd\" every day after UTC 12AM. Valid options: [hour, day]. "+ | ||
"Jaeger also support Elasticsearch ILM to manage indices, reference(https://www.jaegertracing.io/docs/deployment/#elasticsearch-ilm-support)") |
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.
Jaeger additionally supports manual and automated (via ILM) index management. Reference: https://www.jaegertracing.io/docs/deployment/#elasticsearch-rollover.
plugin/storage/es/options.go
Outdated
@@ -295,7 +303,7 @@ 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.IndexDateLayout = initDateLayout(strings.ToLower(v.GetString(cfg.namespace+suffixIndexRollover)), v.GetString(cfg.namespace+suffixIndexDateSeparator)) |
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 think it's a bit more readable to separate these into two separate variables as it starts to get a bit unwieldy with the additional string getter and manipulation functions:
rolloverBy := strings.ToLower(v.GetString(cfg.namespace + suffixIndexRollover))
separator := v.GetString(cfg.namespace + suffixIndexDateSeparator)
cfg.IndexDateLayout = initDateLayout(rolloverBy, separator)
plugin/storage/es/options.go
Outdated
@@ -343,6 +351,12 @@ 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(RolloverBy, separator string) string { |
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.
s/RolloverBy/rolloverBy/
Thanks @WalkerWang731, just a few minor comments. By the way, it's good practice to create PRs off a branch in your fork, instead of Anybody understand what causes the following build errors?
|
Signed-off-by: WalkerWang731 <[email protected]>
Hi @albertteoh, |
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.
lgtm, thanks @WalkerWang731.
pkg/es/config/config.go
Outdated
@@ -63,6 +63,7 @@ type Configuration struct { | |||
BulkFlushInterval time.Duration `mapstructure:"-"` | |||
IndexPrefix string `mapstructure:"index_prefix"` | |||
IndexDateLayout string `mapstructure:"index_date_layout"` | |||
IndexRollover string `mapstructure:"-"` |
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.
This is a poor name, what does "index rollover" mean? From the flag description it seems to mean "frequency", so let's name it IndexRolloverFrequency (and all other vars/flags respectively)
nsConfig.namespace+suffixIndexRollover, | ||
defaultIndexRollover, | ||
"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 comment
The reason will be displayed to describe this comment to others. Learn more.
Jaeger additionally supports manual and automated (via ILM) index management.
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 comment
The 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:
- Rollover on other dimensions such as by size or number of ES documents.
- Clean older indices.
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.
if len(indices) == 0 || indices[len(indices)-1] != currentIndex { | ||
indices = append(indices, currentIndex) | ||
} | ||
endTime = endTime.Add(-1 * time.Hour) |
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.
So this will do 24 iterations on every invocation, even though the default is daily rotation? Could we make this more efficient?
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.
ok let me take a look
flagSet.String( | ||
nsConfig.namespace+suffixIndexRollover, | ||
defaultIndexRollover, | ||
"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]. "+ |
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
Co-authored-by: Yuri Shkuro <[email protected]>
Pull request has been modified.
…re efficient Signed-off-by: WalkerWang731 <[email protected]>
Hi @albertteoh @yurishkuro, By the way, I also want to limit Here is my plan
Because I can't get the Thank you! |
My two cents... I think it's better to maintain index format consistency between spans and services to avoid surprises and more work to manage these indices. I would also think that service index sizes would be fairly small and so not have as much an impact on ES performance? Either that or introduce |
Hi @albertteoh The formula: (SHARD_COUNT * INDEX_COUNT * (REPLICA_COUNT+ 1) ) * KEEP_DAY / NODE_COUNT
I also agree that keep the index format consistency between spans and services, but provide like as So, according to the above, limiting Do you have any better suggestions, please let me know. Thank you! |
Hi @WalkerWang731, sorry I don't completely follow; are you saying it should be okay to leave this PR as is, or is it quite critical to ensure the service index must always be on a daily rollover? Please also make sure:
|
Hi @albertteoh
Yeah, I think it's should be ok now, unit test has passed, except docker relevant issues. I'm not sure whether need @Ashmita152 help to take a look?
|
Co-authored-by: Yuri Shkuro <[email protected]> Signed-off-by: WalkerWang731 <[email protected]>
Signed-off-by: WalkerWang731 <[email protected]>
Co-authored-by: Yuri Shkuro <[email protected]> Signed-off-by: WalkerWang731 <[email protected]>
Signed-off-by: WalkerWang731 <[email protected]>
fix signoff issue of 29ca0e1
close this PR because can't fix the signoff issue and let me recreate a new PR. |
Which problem is this PR solving?
Short description of the changes
index-rollover-frequency
, default is day mode, will not affect existing usageParameter config of
collector
ingester
query
(SPAN_STORAGE_TYPE=elasticsearch)