Skip to content

datastream doesn't work with ignore_malformed setting #71755

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

Closed
eljohnson92 opened this issue Apr 15, 2021 · 4 comments · Fixed by #72406
Closed

datastream doesn't work with ignore_malformed setting #71755

eljohnson92 opened this issue Apr 15, 2021 · 4 comments · Fixed by #72406
Assignees
Labels
>bug :Data Management/Data streams Data streams and their lifecycles Team:Data Management Meta label for data/management team

Comments

@eljohnson92
Copy link

Elasticsearch version : 7.12.0

{
  "name" : "test-container",
  "cluster_name" : "test",
  "cluster_uuid" : "123456789",
  "version" : {
    "number" : "7.12.0",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "78722783c38caa25a70982b5b042074cde5d3b3a",
    "build_date" : "2021-03-18T06:17:15.410153305Z",
    "build_snapshot" : false,
    "lucene_version" : "8.8.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

Plugins installed: [mapper-size]

Description of the problem including expected versus actual behavior:

We are using the index.mapping.ignore_malformed: true setting with datastream for our general purpose logging solution. the index-template would be applied successfully in elastic version 7.9.0 but after upgrading to 7.11.2, and then also trying 7.12.0 it errors out

Steps to reproduce:
request

curl "localhost:9200/_index_template/filebeat?pretty" -H "content-type: application/json" -XPUT -d '{
      "index_patterns": [
        "filebeat-*"
      ],
      "template": {
        "settings": {
          "index": {
            "mapping.ignore_malformed": true
          }
        }
      },
      "data_stream": {}
    }' | jq .

response:

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "composable template [filebeat] template after composition is invalid"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "composable template [filebeat] template after composition is invalid",
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "invalid composite mappings for [filebeat]",
      "caused_by": {
        "type": "illegal_argument_exception",
        "reason": "data stream timestamp field [@timestamp] has disallowed [ignore_malformed] attribute specified"
      }
    }
  },
  "status": 400
}


@eljohnson92 eljohnson92 added >bug needs:triage Requires assignment of a team area label labels Apr 15, 2021
@dnhatn dnhatn added :Data Management/Data streams Data streams and their lifecycles and removed needs:triage Requires assignment of a team area label labels Apr 20, 2021
@elasticmachine elasticmachine added the Team:Data Management Meta label for data/management team label Apr 20, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features (Team:Core/Features)

@martijnvg martijnvg self-assigned this Apr 20, 2021
@martijnvg
Copy link
Member

Thanks for reporting @eljohnson92.

Document inside a data stream should always have a valid timestamp in the @timestamp field, so configuring this field accept malformed values (which don't get indexed), is something Elasticsearch shouldn't allow.

In this case, with an index wide index.mapper.ignore_malformed setting configured, all date fields can accept a malformed date/timestamp value. I think Elasticsearch should ignore the index.mapping.ignore_malformed setting for the @timestamp field and let the setting be applied for all other date field.

@eljohnson92
Copy link
Author

Thanks for responding @martijnvg is there anything we should do to work around this outside of just turning off index.mapping.ignore_malformed for now?

@martijnvg
Copy link
Member

I was going to reply that the following template (with index.mapping.ignore_malformed) would work:

PUT /_index_template/filebeat
{
    "index_patterns": [
        "filebeat-*"
    ],
    "template": {
        "settings": {
            "index": {
                "mapping.ignore_malformed": true
            }
        },
        "mappings": {
            "properties": {
                "@timestamp": {
                    "type": "date",
                    "ignore_malformed": false
                }
            }
        }
    },
    "data_stream": {}
}

Only it doesn't. Another validation error occurs, which in my opinion shouldn't. I will fix this.
The idea here is to opt out of ignoring malformed values only for the @timestamp field.

Unfortunately I don't see a work around this and it seems like disabling index.mapping.ignore_malformed index setting is the only way now (until the fix is in).

martijnvg added a commit to martijnvg/elasticsearch that referenced this issue Apr 28, 2021
If `index.mapping.ignore_malformed` has been set to `true` then
here is no way to overwrite that to `false` for a data stream's
timestamp field.

Before this commit, validation would fail that disallow the usage
of `ignore_malformed` attribute on a data stream's timestamp field.

This commit allows the usage of `ignore_malformed` attribute,
so that `index.mapping.ignore_malformed` can be disabled for a
data stream's timestamp field. The `ignore_malformed` attribute
can only be set to false.

This allows the following index template:

```
PUT /_index_template/filebeat
{
    "index_patterns": [
        "filebeat-*"
    ],
    "template": {
        "settings": {
            "index": {
                "mapping.ignore_malformed": true
            }
        },
        "mappings": {
            "properties": {
                "@timestamp": {
                    "type": "date",
                    "ignore_malformed": false
                }
            }
        }
    },
    "data_stream": {}
}
```

Closes elastic#71755
martijnvg added a commit that referenced this issue Apr 29, 2021
…2406)

If `index.mapping.ignore_malformed` has been set to `true` then
here is no way to overwrite that to `false` for a data stream's
timestamp field.

Before this commit, validation would fail that disallow the usage
of `ignore_malformed` attribute on a data stream's timestamp field.

This commit allows the usage of `ignore_malformed` attribute,
so that `index.mapping.ignore_malformed` can be disabled for a
data stream's timestamp field. The `ignore_malformed` attribute
can only be set to false.

This allows the following index template:

```
PUT /_index_template/filebeat
{
    "index_patterns": [
        "filebeat-*"
    ],
    "template": {
        "settings": {
            "index": {
                "mapping.ignore_malformed": true
            }
        },
        "mappings": {
            "properties": {
                "@timestamp": {
                    "type": "date",
                    "ignore_malformed": false
                }
            }
        }
    },
    "data_stream": {}
}
```

Closes #71755
martijnvg added a commit to martijnvg/elasticsearch that referenced this issue Apr 29, 2021
Backporting elastic#72406 to 7.x branch.

If `index.mapping.ignore_malformed` has been set to `true` then
here is no way to overwrite that to `false` for a data stream's
timestamp field.

Before this commit, validation would fail that disallow the usage
of `ignore_malformed` attribute on a data stream's timestamp field.

This commit allows the usage of `ignore_malformed` attribute,
so that `index.mapping.ignore_malformed` can be disabled for a
data stream's timestamp field. The `ignore_malformed` attribute
can only be set to false.

This allows the following index template:

```
PUT /_index_template/filebeat
{
    "index_patterns": [
        "filebeat-*"
    ],
    "template": {
        "settings": {
            "index": {
                "mapping.ignore_malformed": true
            }
        },
        "mappings": {
            "properties": {
                "@timestamp": {
                    "type": "date",
                    "ignore_malformed": false
                }
            }
        }
    },
    "data_stream": {}
}
```

Closes elastic#71755
martijnvg added a commit to martijnvg/elasticsearch that referenced this issue Apr 29, 2021
Backporting elastic#72406 to 7.13 branch.

If `index.mapping.ignore_malformed` has been set to `true` then
here is no way to overwrite that to `false` for a data stream's
timestamp field.

Before this commit, validation would fail that disallow the usage
of `ignore_malformed` attribute on a data stream's timestamp field.

This commit allows the usage of `ignore_malformed` attribute,
so that `index.mapping.ignore_malformed` can be disabled for a
data stream's timestamp field. The `ignore_malformed` attribute
can only be set to false.

This allows the following index template:

```
PUT /_index_template/filebeat
{
    "index_patterns": [
        "filebeat-*"
    ],
    "template": {
        "settings": {
            "index": {
                "mapping.ignore_malformed": true
            }
        },
        "mappings": {
            "properties": {
                "@timestamp": {
                    "type": "date",
                    "ignore_malformed": false
                }
            }
        }
    },
    "data_stream": {}
}
```

Closes elastic#71755
martijnvg added a commit that referenced this issue Apr 29, 2021
…2446)

Backporting #72406 to 7.13 branch.

If `index.mapping.ignore_malformed` has been set to `true` then
here is no way to overwrite that to `false` for a data stream's
timestamp field.

Before this commit, validation would fail that disallow the usage
of `ignore_malformed` attribute on a data stream's timestamp field.

This commit allows the usage of `ignore_malformed` attribute,
so that `index.mapping.ignore_malformed` can be disabled for a
data stream's timestamp field. The `ignore_malformed` attribute
can only be set to false.

This allows the following index template:

```
PUT /_index_template/filebeat
{
    "index_patterns": [
        "filebeat-*"
    ],
    "template": {
        "settings": {
            "index": {
                "mapping.ignore_malformed": true
            }
        },
        "mappings": {
            "properties": {
                "@timestamp": {
                    "type": "date",
                    "ignore_malformed": false
                }
            }
        }
    },
    "data_stream": {}
}
```

Closes #71755
martijnvg added a commit that referenced this issue Apr 29, 2021
…2444)

Backporting #72406 to 7.x branch.

If `index.mapping.ignore_malformed` has been set to `true` then
here is no way to overwrite that to `false` for a data stream's
timestamp field.

Before this commit, validation would fail that disallow the usage
of `ignore_malformed` attribute on a data stream's timestamp field.

This commit allows the usage of `ignore_malformed` attribute,
so that `index.mapping.ignore_malformed` can be disabled for a
data stream's timestamp field. The `ignore_malformed` attribute
can only be set to false.

This allows the following index template:

```
PUT /_index_template/filebeat
{
    "index_patterns": [
        "filebeat-*"
    ],
    "template": {
        "settings": {
            "index": {
                "mapping.ignore_malformed": true
            }
        },
        "mappings": {
            "properties": {
                "@timestamp": {
                    "type": "date",
                    "ignore_malformed": false
                }
            }
        }
    },
    "data_stream": {}
}
```

Closes #71755
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Data Management/Data streams Data streams and their lifecycles Team:Data Management Meta label for data/management team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants