Skip to content
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

[Jaeger-V2] Add configurable index data layout and rollover frequency #5790

Conversation

JaredTan95
Copy link
Contributor

@JaredTan95 JaredTan95 commented Jul 30, 2024

make configure index datalayout and frequency in jaeger-v2

I think this way is a bit repetitive, as I am trying to contribute for the first time, there are better ways to achieve please guide~

@JaredTan95 JaredTan95 requested a review from a team as a code owner July 30, 2024 15:06
@JaredTan95 JaredTan95 requested a review from albertteoh July 30, 2024 15:06
@JaredTan95 JaredTan95 force-pushed the configure-index-daltalayout-and-frequency branch from 5e66765 to f77bc5b Compare July 30, 2024 15:07
@JaredTan95 JaredTan95 changed the title [Jaeger-V2] configurable index daltalayout and frequency [Jaeger-V2] configurable index datalayout and frequency Jul 30, 2024
@JaredTan95 JaredTan95 changed the title [Jaeger-V2] configurable index datalayout and frequency [Jaeger-V2] configurable index data layout and frequency Jul 30, 2024
@JaredTan95 JaredTan95 changed the title [Jaeger-V2] configurable index data layout and frequency [Jaeger-V2] configurable index data layout and rollover frequency Jul 30, 2024
@JaredTan95 JaredTan95 force-pushed the configure-index-daltalayout-and-frequency branch from 0c67510 to d203d55 Compare August 1, 2024 02:59
pkg/es/config/config.go Outdated Show resolved Hide resolved
@JaredTan95 JaredTan95 force-pushed the configure-index-daltalayout-and-frequency branch 2 times, most recently from 01544c8 to 05d35bc Compare August 2, 2024 06:02
pkg/es/config/config.go Outdated Show resolved Hide resolved
pkg/es/config/config.go Outdated Show resolved Hide resolved
plugin/storage/es/factory.go Outdated Show resolved Hide resolved
plugin/storage/es/factory.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Aug 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.81%. Comparing base (9bdd368) to head (b712a72).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5790      +/-   ##
==========================================
- Coverage   96.82%   96.81%   -0.01%     
==========================================
  Files         345      345              
  Lines       16518    16570      +52     
==========================================
+ Hits        15993    16043      +50     
- Misses        339      340       +1     
- Partials      186      187       +1     
Flag Coverage Δ
badger_v1 8.02% <0.00%> (-0.01%) ⬇️
badger_v2 1.85% <0.00%> (+0.02%) ⬆️
cassandra-3.x-v1 16.57% <0.00%> (-0.05%) ⬇️
cassandra-3.x-v2 1.78% <0.00%> (+0.02%) ⬆️
cassandra-4.x-v1 16.57% <0.00%> (-0.05%) ⬇️
cassandra-4.x-v2 1.78% <0.00%> (+0.02%) ⬆️
elasticsearch-6.x-v1 19.08% <90.34%> (+0.29%) ⬆️
elasticsearch-7.x-v1 19.14% <90.34%> (+0.30%) ⬆️
elasticsearch-8.x-v1 19.35% <90.34%> (+0.30%) ⬆️
elasticsearch-8.x-v2 1.85% <0.00%> (+0.03%) ⬆️
grpc_v1 9.47% <0.00%> (-0.02%) ⬇️
grpc_v2 ?
kafka-v1 9.73% <0.00%> (-0.02%) ⬇️
kafka-v2 1.85% <0.00%> (+0.02%) ⬆️
memory_v2 1.85% <0.00%> (+0.03%) ⬆️
opensearch-1.x-v1 19.20% <90.34%> (+0.31%) ⬆️
opensearch-2.x-v1 19.20% <90.34%> (+0.30%) ⬆️
opensearch-2.x-v2 ?
tailsampling-processor 0.49% <0.00%> (+0.03%) ⬆️
unittests 95.31% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good, thanks for doing this.

cmd/esmapping-generator/app/flags.go Outdated Show resolved Hide resolved
pkg/es/config/config.go Outdated Show resolved Hide resolved
pkg/es/config/config.go Outdated Show resolved Hide resolved
pkg/es/config/config.go Outdated Show resolved Hide resolved
plugin/storage/es/mappings/mapping.go Outdated Show resolved Hide resolved
plugin/storage/es/options.go Outdated Show resolved Hide resolved
@JaredTan95 JaredTan95 force-pushed the configure-index-daltalayout-and-frequency branch from e89accf to 422a678 Compare August 7, 2024 13:53
@JaredTan95 JaredTan95 force-pushed the configure-index-daltalayout-and-frequency branch from 9f49a23 to 8d42129 Compare August 8, 2024 08:35
@JaredTan95 JaredTan95 force-pushed the configure-index-daltalayout-and-frequency branch from ad01a13 to 8d3ebb6 Compare August 13, 2024 10:53
@JaredTan95
Copy link
Contributor Author

for instance


🚧 🚧 🚧 jaeger-v2 error logs:

  2024/09/03 17:08:50 application version: git-commit=, git-version=, build-date=

  Error: failed to get config: cannot unmarshal the configuration: decoding failed due to the following error(s):

  

  error decoding 'extensions': error reading configuration for "jaeger_storage": decoding failed due to the following error(s):

  

  error decoding 'backends[another_storage]': decoding failed due to the following error(s):

  

  'elasticsearch.indices.spans' has invalid keys: index_prefix

  error decoding 'backends[some_storage]': decoding failed due to the following error(s):

  

  'elasticsearch.indices.spans' has invalid keys: index_prefix

  'elasticsearch.indices.services' has invalid keys: index_prefix

  'elasticsearch.indices.dependencies' has invalid keys: index_prefix

  2024/09/03 17:08:50 failed to get config: cannot unmarshal the configuration: decoding failed due to the following error(s):

ok,i will check it soon

@JaredTan95 JaredTan95 force-pushed the configure-index-daltalayout-and-frequency branch from 2f587d5 to 037f479 Compare September 6, 2024 08:02
@yurishkuro
Copy link
Member

ES v7 failed with

=== RUN   TestIndexRollover_CreateIndicesWithILM/SetPolicyName/WithAdaptiveSampling
Error: template: mapping:5:8: executing "mapping" at <.IndexPrefix>: can't evaluate field IndexPrefix in type *mappings.IndexTemplateOptions

Signed-off-by: Jared Tan <[email protected]>
@yurishkuro
Copy link
Member

rollover tests fail - it looks like somewhere the prefix is not being respected.

another_storage:
elasticsearch:
index_prefix: "jaeger-archive"
indices:
spans:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: is the services index being built at all when the storage is in the archive mode? I don't think it should be, but in this configuration services.prefix: "jaeger-main" would be the default, and the archive storage is not told in any way that it is indeed archive.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yurishkuro my apologies i don't have a lot of context here but how should we proceed with this?

Copy link
Member

@yurishkuro yurishkuro Oct 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to check in the code if writing/reading to/from Archive storage relies exclusively on spans index, or if it uses any other indices. If the latter, then we need to override the prefix to jaeger-archive not just for spans but for other indices too. This is where the defaults: section I mentioned in another comment would be useful - we could just define it once instead of duplicating all the information.

IndexPrefix: cfg.IndexPrefix,
IndexDateLayout: cfg.IndexDateLayoutDependencies,
IndexPrefix: cfg.Indices.Dependencies.Prefix,
IndexDateLayout: cfg.Indices.Dependencies.RolloverFrequency,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a bug: RolloverFrequency -> DateLayout. Please re-check everywhere.

type IndexTemplateOptions struct {
UseILM bool
ILMPolicyName string
config.IndexOptions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would recommend against embedding the whole struct, because it makes the templates tightly coupled with the configuration. E.g. it looks like only a couple of fields are actually used in the templates, prefix and priority, so I would define them explicitly in IndexTemplateOptions and copy from IndexOptions as needed. This way we won't have to change the templates just because we changed the config struct.

@@ -20,10 +20,35 @@ extensions:
backends:
some_storage:
elasticsearch:
index_prefix: "jaeger-main"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: we may want to rethink if we still want a single field in the config for index prefix, which would apply if the individual index options didn't override it explicitly. This would simplify the configuration while maintaining the flexibility.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yurishkuro is this still something we want to address?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be a good usability improvement - perhaps under Indices we can have a "defaults" entry that will apply unless overwritten by the more specific entries like spans:

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yurishkuro this PR is already pretty big (31 files changed). thoughts on getting this PR in and tackling this in a follow-up PR under #6059. There's some follow-up work that needs to be done there anyway for aligning the config with OTEL.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, it might be a good idea to try out Sapling and do stacked PRs, to avoid precisely this problem (at work we always use stacked PRs)

Comment on lines +127 to +128
if prefix != "" {
return prefix + indexPrefixSeparator + index
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at mapping.go I think this should be a bit smarter, e.g.

Suggested change
if prefix != "" {
return prefix + indexPrefixSeparator + index
if prefix != "" {
if !prefix.endsWith(indexPrefixSeparator) { prefix += indexPrefixSeparator }
return prefix + index

if prefix != "" {
prefix += indexPrefixSeparator
func getSpanAndServiceIndexFn(archive, useReadWriteAliases bool, spanIndexOpts, serviceIndexOpts cfg.IndexOptions) spanAndServiceIndexFn {
if spanIndexOpts.Prefix != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to above

Suggested change
if spanIndexOpts.Prefix != "" {
if spanIndexOpts.Prefix != "" && !strings.HasSuffix(spanIndexOpts.Prefix, indexPrefixSeparator) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we do this in multiple places I would extract into a single function. Ideally these kinds of adjustments should be done very early after parsing the config, not spread out across many places in the code. It could be even a helper function on the IndexOptions struct, e.g.

func (o IndexOptions) FullIndexName(name string) {
  if o.Prefix == "" {
    return name
  }
  if strings.HasSuffix(o.Prefix. indexPrefixSeparator) {
    return o.Prefix + name
  }
  return o.Prefix + indexPrefixSeparator + name
}

@mahadzaryab1
Copy link
Collaborator

@JaredTan95 hi! just wanted to check on the status of this. We're pretty close to finishing up #5229 so I wanted to check in on if you had time to address the comments above? Let me know if you'd like me to pick it up for you.

@JaredTan95
Copy link
Contributor Author

@mahadzaryab1 hi, I will update in a few days to address the above comments

@yurishkuro
Copy link
Member

Superseded by #6060, let's close this to minimize noise.

@yurishkuro yurishkuro closed this Oct 6, 2024
@JaredTan95 JaredTan95 deleted the configure-index-daltalayout-and-frequency branch October 7, 2024 01:32
yurishkuro added a commit that referenced this pull request Oct 12, 2024
…6060)

## Which problem is this PR solving?
- Part of #6059

## Description of the changes
- Continuation of #5790
- Refactors the configurations for ElasticSearch and OpenSearch to
simplify the configuration by having more logical groupings

## How was this change tested?
- Unit Tests and E2E Integration Tests

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

---------

Signed-off-by: Jared Tan <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Co-authored-by: Jared Tan <[email protected]>
Co-authored-by: Yuri Shkuro <[email protected]>
Saumya40-codes pushed a commit to Saumya40-codes/jaeger that referenced this pull request Oct 14, 2024
…aegertracing#6060)

## Which problem is this PR solving?
- Part of jaegertracing#6059

## Description of the changes
- Continuation of jaegertracing#5790
- Refactors the configurations for ElasticSearch and OpenSearch to
simplify the configuration by having more logical groupings

## How was this change tested?
- Unit Tests and E2E Integration Tests

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

---------

Signed-off-by: Jared Tan <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Co-authored-by: Jared Tan <[email protected]>
Co-authored-by: Yuri Shkuro <[email protected]>
Signed-off-by: Saumya Shah <[email protected]>
Saumya40-codes pushed a commit to Saumya40-codes/jaeger that referenced this pull request Oct 14, 2024
…aegertracing#6060)

## Which problem is this PR solving?
- Part of jaegertracing#6059

## Description of the changes
- Continuation of jaegertracing#5790
- Refactors the configurations for ElasticSearch and OpenSearch to
simplify the configuration by having more logical groupings

## How was this change tested?
- Unit Tests and E2E Integration Tests

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

---------

Signed-off-by: Jared Tan <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Co-authored-by: Jared Tan <[email protected]>
Co-authored-by: Yuri Shkuro <[email protected]>
Signed-off-by: Saumya Shah <[email protected]>
chahatsagarmain pushed a commit to chahatsagarmain/jaeger that referenced this pull request Oct 23, 2024
…aegertracing#6060)

## Which problem is this PR solving?
- Part of jaegertracing#6059

## Description of the changes
- Continuation of jaegertracing#5790
- Refactors the configurations for ElasticSearch and OpenSearch to
simplify the configuration by having more logical groupings

## How was this change tested?
- Unit Tests and E2E Integration Tests

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

---------

Signed-off-by: Jared Tan <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Co-authored-by: Jared Tan <[email protected]>
Co-authored-by: Yuri Shkuro <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:exprimental Change to an experimental part of the code storage/elasticsearch v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants