Skip to content

Component templates are considered invalid without timestamp_field #58956

@jonathan-buttner

Description

@jonathan-buttner

Elasticsearch version (bin/elasticsearch --version):
8.0.0 snapshot
https://storage.googleapis.com/kibana-ci-es-snapshots-daily/8.0.0/archives/20200702-061321_92851b422f0/elasticsearch-8.0.0-SNAPSHOT-darwin-x86_64.tar.gz

{
  "name" : "jbuttner-mbp",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "NyhzfY6ATt26icttpHgMMg",
  "version" : {
    "number" : "8.0.0-SNAPSHOT",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "92851b422f0a341f211008e24fdfe563291c84b9",
    "build_date" : "2020-07-02T06:05:57.277162Z",
    "build_snapshot" : true,
    "lucene_version" : "8.6.0",
    "minimum_wire_compatibility_version" : "7.9.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

OS version (uname -a if on a Unix-like system):
macOS

Description of the problem including expected versus actual behavior:
If a template uses a component template to be built, it will be rejected by ES if the component template does not have the timestamp_field even if the _index_template API request contains the necessary field.

Steps to reproduce:

POST _component_template/metrics-endpoint.metadata-mappings
{
  "template": {
    "mappings": {
      "dynamic": true
    }
  }
}
PUT _index_template/test1
{
  "priority": 4,
  "index_patterns": [
    "metrics-endpoint.metadata-*"
  ],
  "template": {
    "mappings": {
      "date_detection": false,
      "properties": {
        "@timestamp": {
          "type": "date"
        }
      }
    }
  },
  "data_stream": {
    "timestamp_field": "@timestamp"
  },
  "composed_of": [
    "metrics-endpoint.metadata-mappings"
  ]
}

This will fail with the following error:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "composable template [test1] template after composition with component templates [metrics-endpoint.metadata-mappings] is invalid"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "composable template [test1] template after composition with component templates [metrics-endpoint.metadata-mappings] is invalid",
    "caused_by" : {
      "type" : "illegal_argument_exception",
      "reason" : "invalid composite mappings for [test1]",
      "caused_by" : {
        "type" : "illegal_argument_exception",
        "reason" : "expected timestamp field [@timestamp], but found no timestamp field"
      }
    }
  },
  "status" : 400
}

If we use this component template instead the request will succeed:

POST _component_template/metrics-endpoint.metadata-mappings
{
  "template": {
    "mappings": {
      "dynamic": false,
      "properties": {
        "@timestamp": {
          "type": "date"
        }
      }
    }
  }
}

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions