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

[alerting] migrating an alert with a large alert param into 7.13.0 will cause a migration error #100607

Closed
pmuellr opened this issue May 25, 2021 · 5 comments · Fixed by #100726
Closed
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Feature:Alerting Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)

Comments

@pmuellr
Copy link
Member

pmuellr commented May 25, 2021

Kibana version: 7.13.0

Elasticsearch version: 7.13.0

Describe the bug:

In 7.13.0, we changed the type of the alert saved object params property, from type: object; enabled: false to type: flattened in PR #92036.

"params": {
"type": "flattened"
},

Unfortunately, this will cause a problem for any field in the params which is greater than 32766 byte long; we just saw such an alert fail in a migration in an internal repo.

FATAL  Error: Unable to complete saved object migrations for the [.kibana] index. 
Error: pickupUpdatedMappings task failed with the following failures:
[
  {
    "index": ".kibana_7.13.0_001",
    "type": "_doc",
    "id": "alert:1b5a5b52-5fdb-4a17-9ecb-909083978c60",
    "cause": {
      "type": "illegal_argument_exception",
      "reason": "Document contains at least one immense term in field=\"alert.params\" (whose UTF8 encoding is longer
than the max length 32766), all of which were skipped.  Please correct the analyzer to not produce such terms.  The
prefix of the first immense term is: '[bytes elited]...', original message: bytes can be at most 32766 in length;
got 92326",
      "caused_by": {
        "type": "max_bytes_length_exceeded_exception",
        "reason": "max_bytes_length_exceeded_exception: bytes can be at most 32766 in length; got 92326"
      }
    },
    "status": 400
  }
]

I haven't repro'd it yet, but I would expect that you could cause this to fail with a normal alert creation with a param over the length limit. If that doesn't fail, or fails differently, I think we'd want to try to repro the migration failure directly, by creating an alert with a huge param in 7.12, then migrating to 7.13.

@pmuellr pmuellr added bug Fixes for quality problems that affect the customer experience Feature:Alerting Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) labels May 25, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-alerting-services (Team:Alerting Services)

@pmuellr
Copy link
Member Author

pmuellr commented May 25, 2021

We're hoping we can "fix" this by adding an ignore_above to the field definition ... https://www.elastic.co/guide/en/elasticsearch/reference/current/flattened.html#flattened-params

@pmuellr
Copy link
Member Author

pmuellr commented May 26, 2021

Was able to repro the error by creating an alert with a 100K param. Used the es query alert - when creating a new one, it populates it's query parameter with a simple query, so I inserted 100K space characters before the final } (in case we did a trim() on the value).

{
  "query":{
    "match_all" : {}
  }
}

image

So, assuming that if we can prevent this from happening with this repro during create, it will also fix the migration issue.

@pmuellr
Copy link
Member Author

pmuellr commented May 26, 2021

Added "ignore_above": 4096 just after the type parameter here, and was able to save the alert, see it run, re-edit it again - so seems like it's going to work.

"params": {
"type": "flattened"
},

I wasn't sure what value to use for ignore_above - most uses in Kibana use 1024, but they're for relatively "simple" fields, and I think we want to account for more. The max will be in the 32K range, but didn't want to really go that high. 4K seemed pretty reasonable, 8K would be fine for me as well.

This should only impact the searching of alerts via the params, nothing else operationally.

Now to write a test ...

pmuellr added a commit to pmuellr/kibana that referenced this issue May 26, 2021
…se params

resolves elastic#100607

This fixes a problem when very large parameters (over 32K bytes) are saved with
an alert.  Before this fix, an error from elasticsearch would be thrown with
the following message, and a 400 returned from create (and presumably update).

    Document contains at least one immense term in field=\"alert.params\"
    (whose UTF8 encoding is longer than the max length 32766), all of which
    were skipped.

After the fix, you can alerts with immense params can be saved and executed.

Note that the immense params will not be searchable, since they won't be indexed,
but that seems both unavoidable, and not a severe issue.
@mikecote
Copy link
Contributor

I wasn't sure what value to use for ignore_above - most uses in Kibana use 1024, but they're for relatively "simple" fields, and I think we want to account for more. The max will be in the 32K range, but didn't want to really go that high. 4K seemed pretty reasonable, 8K would be fine for me as well.

From my understanding, this ignore_above tells Elasticsearch to skip analyzing values that are above X? If that's the case, whatever number we put would be the threshold before exact matches stop working. 1k, 4k or 8k seem pretty big for an exact match query?

pmuellr added a commit that referenced this issue May 27, 2021
…se params (#100726)

resolves #100607

This fixes a problem when very large parameters (over 32K bytes) are saved with
an alert.  Before this fix, an error from elasticsearch would be thrown with
the following message, and a 400 returned from create (and presumably update).

    Document contains at least one immense term in field=\"alert.params\"
    (whose UTF8 encoding is longer than the max length 32766), all of which
    were skipped.

After the fix, alerts with immense params can be saved and executed.

Note that the immense params will not be searchable, since they won't be indexed,
but that seems both unavoidable, and not a severe issue.
pmuellr added a commit to pmuellr/kibana that referenced this issue May 27, 2021
…se params (elastic#100726)

resolves elastic#100607

This fixes a problem when very large parameters (over 32K bytes) are saved with
an alert.  Before this fix, an error from elasticsearch would be thrown with
the following message, and a 400 returned from create (and presumably update).

    Document contains at least one immense term in field=\"alert.params\"
    (whose UTF8 encoding is longer than the max length 32766), all of which
    were skipped.

After the fix, alerts with immense params can be saved and executed.

Note that the immense params will not be searchable, since they won't be indexed,
but that seems both unavoidable, and not a severe issue.
pmuellr added a commit to pmuellr/kibana that referenced this issue May 27, 2021
…se params (elastic#100726)

resolves elastic#100607

This fixes a problem when very large parameters (over 32K bytes) are saved with
an alert.  Before this fix, an error from elasticsearch would be thrown with
the following message, and a 400 returned from create (and presumably update).

    Document contains at least one immense term in field=\"alert.params\"
    (whose UTF8 encoding is longer than the max length 32766), all of which
    were skipped.

After the fix, alerts with immense params can be saved and executed.

Note that the immense params will not be searchable, since they won't be indexed,
but that seems both unavoidable, and not a severe issue.
pmuellr added a commit that referenced this issue May 27, 2021
…se params (#100726) (#100772)

resolves #100607

This fixes a problem when very large parameters (over 32K bytes) are saved with
an alert.  Before this fix, an error from elasticsearch would be thrown with
the following message, and a 400 returned from create (and presumably update).

    Document contains at least one immense term in field=\"alert.params\"
    (whose UTF8 encoding is longer than the max length 32766), all of which
    were skipped.

After the fix, alerts with immense params can be saved and executed.

Note that the immense params will not be searchable, since they won't be indexed,
but that seems both unavoidable, and not a severe issue.
pmuellr added a commit that referenced this issue May 27, 2021
…se params (#100726) (#100773)

resolves #100607

This fixes a problem when very large parameters (over 32K bytes) are saved with
an alert.  Before this fix, an error from elasticsearch would be thrown with
the following message, and a 400 returned from create (and presumably update).

    Document contains at least one immense term in field=\"alert.params\"
    (whose UTF8 encoding is longer than the max length 32766), all of which
    were skipped.

After the fix, alerts with immense params can be saved and executed.

Note that the immense params will not be searchable, since they won't be indexed,
but that seems both unavoidable, and not a severe issue.
@kobelb kobelb added the needs-team Issues missing a team label label Jan 31, 2022
@botelastic botelastic bot removed the needs-team Issues missing a team label label Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Alerting Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants