open-telemetry / opentelemetry-collector-contrib

Contrib repository for the OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
2.89k stars 2.26k forks source link

[exporter/elasticsearch] Bulk indexer error: an id must be provided if version type or value are set #33139

Open lmssy opened 3 months ago

lmssy commented 3 months ago

Component(s)

exporter/elasticsearch

What happened?

Description

I'm trying to export trace & span to elasticsearch v7, I config collector just follow the document https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/elasticsearchexporter but in collector's log report below error, there is no index created in elasticsearch. please help to check, thx.

image

Steps to Reproduce

Expected Result

Actual Result

Collector version

0.100.0

Environment information

Environment

OpenTelemetry Collector configuration

extensions:
  health_check:
receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318
exporters:
  file:
    path: /agent.json
  debug:
  elasticsearch/trace:
    endpoints: [http://my-elastich-host:9200]
    traces_index: trace_index
    user: xxx
    password: xxx
processors:
  batch/trace:
  memory_limiter/trace:
    limit_mib: 3000
    spike_limit_mib: 600
    check_interval: 5s
  tail_sampling:
    decision_wait: 10s
    policies:
      - name: slow_calls
        type: latency
        latency:
          threshold_ms: 5000
      - name: error_otel_status
        type: status_code
        status_code:
          status_codes:
            - ERROR
      - name: error_http_status
        type: numeric_attribute
        numeric_attribute:
            key: http.status_code
            min_value: 500
      - name: keep_sampled_success
        type: and
        and:
          and_sub_policy:
            - name: drop_noisy_traces_url
              type: string_attribute
              string_attribute:
                key: http.url
                values:
                  - \/metrics
                  - opentelemetry\.proto
                  - favicon\.ico
                  - \/health
                enabled_regex_matching: true
                invert_match: true
            - name: keep_percentage
              type: probabilistic
              probabilistic:
                sampling_percentage: 100
service:
  extensions: [health_check]
  pipelines:
    traces:
      receivers: [otlp]
      processors: [memory_limiter/trace,tail_sampling,batch/trace]
      exporters: [debug,file,elasticsearch/trace]

Log output

2024-05-21T13:48:18.897+0800    error   elasticsearchexporter@v0.100.0/elasticsearch_bulk.go:150    Bulk indexer error: flush: [400 Bad Request] {"error":{"root_cause":[{"type":"action_request_validation_exception","reason":"Validation Failed: 1: an id must be provided if version type or value are set;2: an id must be provided if version type or value are set;"}],"type":"action_request_validation_exception","reason":"Validation Failed: 1: an id must be provided if version type or value are set;2: an id must be provided if version type or value are set;"},"status":400}  {"kind": "exporter", "data_type": "traces", "name": "elasticsearch/trace"}
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter.newBulkIndexer.func1
    github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter@v0.100.0/elasticsearch_bulk.go:150
github.com/elastic/go-elasticsearch/v7/esutil.(*bulkIndexer).init.func1
    github.com/elastic/go-elasticsearch/v7@v7.17.10/esutil/bulk_indexer.go:324
2024-05-21T13:48:18.907+0800    error   elasticsearchexporter@v0.100.0/elasticsearch_bulk.go:150    Bulk indexer error: flush: [400 Bad Request] {"error":{"root_cause":[{"type":"action_request_validation_exception","reason":"Validation Failed: 1: an id must be provided if version type or value are set;2: an id must be provided if version type or value are set;"}],"type":"action_request_validation_exception","reason":"Validation Failed: 1: an id must be provided if version type or value are set;2: an id must be provided if version type or value are set;"},"status":400}  {"kind": "exporter", "data_type": "traces", "name": "elasticsearch/trace"}
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter.newBulkIndexer.func1
    github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter@v0.100.0/elasticsearch_bulk.go:150
github.com/elastic/go-elasticsearch/v7/esutil.(*worker).flush
    github.com/elastic/go-elasticsearch/v7@v7.17.10/esutil/bulk_indexer.go:568
github.com/elastic/go-elasticsearch/v7/esutil.(*bulkIndexer).init.func1
    github.com/elastic/go-elasticsearch/v7@v7.17.10/esutil/bulk_indexer.go:321
2024-05-21T13:48:18.907+0800    error   elasticsearchexporter@v0.100.0/elasticsearch_bulk.go:150    Bulk indexer error: flush: [400 Bad Request] {"error":{"root_cause":[{"type":"action_request_validation_exception","reason":"Validation Failed: 1: an id must be provided if version type or value are set;2: an id must be provided if version type or value are set;"}],"type":"action_request_validation_exception","reason":"Validation Failed: 1: an id must be provided if version type or value are set;2: an id must be provided if version type or value are set;"},"status":400}  {"kind": "exporter", "data_type": "traces", "name": "elasticsearch/trace"}
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter.newBulkIndexer.func1
    github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter@v0.100.0/elasticsearch_bulk.go:150
github.com/elastic/go-elasticsearch/v7/esutil.(*bulkIndexer).init.func1
    github.com/elastic/go-elasticsearch/v7@v7.17.10/esutil/bulk_indexer.go:324
2024-05-21T13:48:18.968+0800    error   elasticsearchexporter@v0.100.0/elasticsearch_bulk.go:150    Bulk indexer error: flush: [400 Bad Request] {"error":{"root_cause":[{"type":"action_request_validation_exception","reason":"Validation Failed: 1: an id must be provided if version type or value are set;2: an id must be provided if version type or value are set;"}],"type":"action_request_validation_exception","reason":"Validation Failed: 1: an id must be provided if version type or value are set;2: an id must be provided if version type or value are set;"},"status":400}  {"kind": "exporter", "data_type": "traces", "name": "elasticsearch/trace"}
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter.newBulkIndexer.func1
    github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter@v0.100.0/elasticsearch_bulk.go:150
github.com/elastic/go-elasticsearch/v7/esutil.(*worker).flush
    github.com/elastic/go-elasticsearch/v7@v7.17.10/esutil/bulk_indexer.go:568
github.com/elastic/go-elasticsearch/v7/esutil.(*bulkIndexer).init.func1
    github.com/elastic/go-elasticsearch/v7@v7.17.10/esutil/bulk_indexer.go:321
2024-05-21T13:48:18.968+0800    error   elasticsearchexporter@v0.100.0/elasticsearch_bulk.go:150    Bulk indexer error: flush: [400 Bad Request] {"error":{"root_cause":[{"type":"action_request_validation_exception","reason":"Validation Failed: 1: an id must be provided if version type or value are set;2: an id must be provided if version type or value are set;"}],"type":"action_request_validation_exception","reason":"Validation Failed: 1: an id must be provided if version type or value are set;2: an id must be provided if version type or value are set;"},"status":400}  {"kind": "exporter", "data_type": "traces", "name": "elasticsearch/trace"}
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter.newBulkIndexer.func1
    github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter@v0.100.0/elasticsearch_bulk.go:150
github.com/elastic/go-elasticsearch/v7/esutil.(*bulkIndexer).init.func1
    github.com/elastic/go-elasticsearch/v7@v7.17.10/esutil/bulk_indexer.go:324
2024-05-21T13:48:19.010+0800    info    TracesExporter  {"kind": "exporter", "data_type": "traces", "name": "debug", "resource spans": 1, "spans": 1}
2024-05-21T13:48:21.016+0800    info    TracesExporter  {"kind": "exporter", "data_type": "traces", "name": "debug", "resource spans": 2, "spans": 2}
2024-05-21T13:48:24.026+0800    info    TracesExporter  {"kind": "exporter", "data_type": "traces", "name": "debug", "resource spans": 1, "spans": 1}
2024-05-21T13:48:31.045+0800    info    TracesExporter  {"kind": "exporter", "data_type": "traces", "name": "debug", "resource spans": 1, "spans": 1}

Additional context

No response

github-actions[bot] commented 3 months ago

Pinging code owners:

lmssy commented 3 months ago

anyone can take a look for this issue?

github-actions[bot] commented 1 month ago

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

medorock25 commented 2 weeks ago

does anyone knows the solution ?

medorock25 commented 1 week ago

@lmssy Have you solved this issue ?

carsonip commented 6 days ago

Sorry for the late reply. I am unable to reproduce the issue with v7.17.23 Elasticsearch and v0.108.0 elasticsearchexporter with a simpler config:

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318
exporters:
  debug:
  elasticsearch/trace:
    endpoints: [https://redacted.elastic-cloud.com]
    traces_index: trace_index
    user: redacted
    password: redacted
service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: []
      exporters: [debug,elasticsearch/trace]

Questions