Skip to content

[ResponseOps][Rules] Ignore unknowns in the schema of the log threshold params #217440

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

Merged
merged 5 commits into from
Apr 8, 2025

Conversation

cnasikas
Copy link
Member

@cnasikas cnasikas commented Apr 8, 2025

Summary

A PR introduced into 8.18/9.0 (#205507) changed the way we validate the log threshold rule type parameters. The validation happens on rule params and changes a loose validation to a strict validation, so those users who’ve inserted excess fields before 8.18/9.0 will see rules starting to fail to run, their rule page failing to load and the API starting to reject calls with excess fields.

Fixes: #217384

Testing instructions

  1. Start Kibana on 8.17 and create the following rule using the API. Let the rule run.
Rule
{
    "name": "[QAF] Observability rule 3",
    "tags": [
        "metrics",
        "threshold",
        "qaf"
    ],
    "rule_type_id": "logs.alert.document.count",
    "consumer": "alerts",
    "schedule": {
        "interval": "1m"
    },
    "actions": [],
    "params": {
        "timeSize": 8,
        "timeUnit": "h",
        "count": {
            "value": 1,
            "comparator": "more than"
        },
        "criteria": [
            {
                "field": "bytes",
                "comparator": "more than",
                "value": 1
            }
        ],
        "logView": {
            "logViewId": "log-view-reference-0",
            "type": "log-view-reference"
        },
        "groupBy": [
            "geo.dest"
        ],
        "outputIndex": ".alerts-observability.logs.alerts-default"
    }
}
  1. Start Kibana on 8.18. Verify that you cannot create the same rule and the rule created in step 1 starts failing.
  2. Start Kibana on this PR and that you can create the same rule and the rule created in step 1 is working as expected.

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

@cnasikas cnasikas added bug Fixes for quality problems that affect the customer experience Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v9.0.0 backport:version Backport to applied version labels v8.18.0 v9.1.0 v8.19.0 labels Apr 8, 2025
@cnasikas cnasikas self-assigned this Apr 8, 2025
@cnasikas cnasikas changed the title [ResponseOps][Rules] Ignore unknowns in the schema of the log threashold params [ResponseOps][Rules] Ignore unknowns in the schema of the log threshold params Apr 8, 2025
@cnasikas
Copy link
Member Author

cnasikas commented Apr 8, 2025

/ci

@cnasikas cnasikas marked this pull request as ready for review April 8, 2025 08:21
@cnasikas cnasikas requested a review from a team as a code owner April 8, 2025 08:21
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@cnasikas cnasikas added the release_note:skip Skip the PR/issue when compiling release notes label Apr 8, 2025

const countRuleParamsSchema = schema.intersection([
schema.object({
const countRuleParamsSchema = schema.object(
Copy link
Member Author

Choose a reason for hiding this comment

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

I had to duplicate the schema to be able to use { unknowns: 'ignore' } on the top level. schema.intersection does not support { unknowns: 'ignore' }.


it('strips out excess fields', () => {
const result = logThresholdParamsSchema.validate(countParams);
expect(result).toEqual(omit(countParams, 'outputIndex'));
Copy link
Contributor

Choose a reason for hiding this comment

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

countParams does not have outputIndex. Adding countParamsWithExcess here would make this test a duplicate, maybe we want to remove it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 9c8b246.

],
};

const rationParams = {
Copy link
Contributor

Choose a reason for hiding this comment

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

ratioRuleParamsSchema was also changed to include { unknowns: 'ignore' } we could add a ratioParamsWithExcess and a 'validates ratio params correctly'.

Also, I think there is a typo:

Suggested change
const rationParams = {
const ratioParams = {

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 9c8b246.

Copy link
Contributor

@js-jankisalvi js-jankisalvi left a comment

Choose a reason for hiding this comment

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

Verified locally, able to create rule with outputIndex and do not see outputIndex in the response 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

A few objects in log_threshold/v1 have now { unknowns: 'ignore' }. The naming is confusing but I think we do not test that count: ThresholdSchema, does not break with additional fields. (We only test criteria: countCriteriaSchema, with countParams(WithExcess).)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 9c8b246.

Copy link
Contributor

@ymao1 ymao1 left a comment

Choose a reason for hiding this comment

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

LGTM. Verified works as expected.

@cnasikas cnasikas enabled auto-merge (squash) April 8, 2025 13:24
Copy link
Contributor

@guskovaue guskovaue left a comment

Choose a reason for hiding this comment

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

Tested locally. Works as expected!

@cnasikas cnasikas merged commit 2a01722 into elastic:main Apr 8, 2025
10 checks passed
@cnasikas cnasikas deleted the fix_rule_params_bug branch April 8, 2025 13:58
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.18, 8.x, 9.0

https://github.com/elastic/kibana/actions/runs/14335468981

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

cc @cnasikas

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 8, 2025
…ld params (elastic#217440)

## Summary

A PR introduced into 8.18/9.0
(elastic#205507) changed the way we
validate the log threshold rule type parameters. The validation happens
on rule params and changes a loose validation to a strict validation, so
those users who’ve inserted excess fields before 8.18/9.0 will see rules
starting to fail to run, their rule page failing to load and the API
starting to reject calls with excess fields.

Fixes: elastic#217384

## Testing instructions

1. Start Kibana on 8.17 and create the following rule using the API. Let
the rule run.

<details><summary>Rule</summary>

```
{
    "name": "[QAF] Observability rule 3",
    "tags": [
        "metrics",
        "threshold",
        "qaf"
    ],
    "rule_type_id": "logs.alert.document.count",
    "consumer": "alerts",
    "schedule": {
        "interval": "1m"
    },
    "actions": [],
    "params": {
        "timeSize": 8,
        "timeUnit": "h",
        "count": {
            "value": 1,
            "comparator": "more than"
        },
        "criteria": [
            {
                "field": "bytes",
                "comparator": "more than",
                "value": 1
            }
        ],
        "logView": {
            "logViewId": "log-view-reference-0",
            "type": "log-view-reference"
        },
        "groupBy": [
            "geo.dest"
        ],
        "outputIndex": ".alerts-observability.logs.alerts-default"
    }
}
```

</details>

2. Start Kibana on 8.18. Verify that you cannot create the same rule and
the rule created in step 1 starts failing.
3. Start Kibana on this PR and that you can create the same rule and the
rule created in step 1 is working as expected.

### Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

(cherry picked from commit 2a01722)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 8, 2025
…ld params (elastic#217440)

## Summary

A PR introduced into 8.18/9.0
(elastic#205507) changed the way we
validate the log threshold rule type parameters. The validation happens
on rule params and changes a loose validation to a strict validation, so
those users who’ve inserted excess fields before 8.18/9.0 will see rules
starting to fail to run, their rule page failing to load and the API
starting to reject calls with excess fields.

Fixes: elastic#217384

## Testing instructions

1. Start Kibana on 8.17 and create the following rule using the API. Let
the rule run.

<details><summary>Rule</summary>

```
{
    "name": "[QAF] Observability rule 3",
    "tags": [
        "metrics",
        "threshold",
        "qaf"
    ],
    "rule_type_id": "logs.alert.document.count",
    "consumer": "alerts",
    "schedule": {
        "interval": "1m"
    },
    "actions": [],
    "params": {
        "timeSize": 8,
        "timeUnit": "h",
        "count": {
            "value": 1,
            "comparator": "more than"
        },
        "criteria": [
            {
                "field": "bytes",
                "comparator": "more than",
                "value": 1
            }
        ],
        "logView": {
            "logViewId": "log-view-reference-0",
            "type": "log-view-reference"
        },
        "groupBy": [
            "geo.dest"
        ],
        "outputIndex": ".alerts-observability.logs.alerts-default"
    }
}
```

</details>

2. Start Kibana on 8.18. Verify that you cannot create the same rule and
the rule created in step 1 starts failing.
3. Start Kibana on this PR and that you can create the same rule and the
rule created in step 1 is working as expected.

### Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

(cherry picked from commit 2a01722)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 8, 2025
…ld params (elastic#217440)

## Summary

A PR introduced into 8.18/9.0
(elastic#205507) changed the way we
validate the log threshold rule type parameters. The validation happens
on rule params and changes a loose validation to a strict validation, so
those users who’ve inserted excess fields before 8.18/9.0 will see rules
starting to fail to run, their rule page failing to load and the API
starting to reject calls with excess fields.

Fixes: elastic#217384

## Testing instructions

1. Start Kibana on 8.17 and create the following rule using the API. Let
the rule run.

<details><summary>Rule</summary>

```
{
    "name": "[QAF] Observability rule 3",
    "tags": [
        "metrics",
        "threshold",
        "qaf"
    ],
    "rule_type_id": "logs.alert.document.count",
    "consumer": "alerts",
    "schedule": {
        "interval": "1m"
    },
    "actions": [],
    "params": {
        "timeSize": 8,
        "timeUnit": "h",
        "count": {
            "value": 1,
            "comparator": "more than"
        },
        "criteria": [
            {
                "field": "bytes",
                "comparator": "more than",
                "value": 1
            }
        ],
        "logView": {
            "logViewId": "log-view-reference-0",
            "type": "log-view-reference"
        },
        "groupBy": [
            "geo.dest"
        ],
        "outputIndex": ".alerts-observability.logs.alerts-default"
    }
}
```

</details>

2. Start Kibana on 8.18. Verify that you cannot create the same rule and
the rule created in step 1 starts failing.
3. Start Kibana on this PR and that you can create the same rule and the
rule created in step 1 is working as expected.

### Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

(cherry picked from commit 2a01722)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.18
8.x
9.0

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Apr 8, 2025
…hreshold params (#217440) (#217526)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ResponseOps][Rules] Ignore unknowns in the schema of the log
threshold params
(#217440)](#217440)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Christos
Nasikas","email":"christos.nasikas@elastic.co"},"sourceCommit":{"committedDate":"2025-04-08T13:58:26Z","message":"[ResponseOps][Rules]
Ignore unknowns in the schema of the log threshold params
(#217440)\n\n## Summary\n\nA PR introduced into
8.18/9.0\n(#205507) changed the
way we\nvalidate the log threshold rule type parameters. The validation
happens\non rule params and changes a loose validation to a strict
validation, so\nthose users who’ve inserted excess fields before
8.18/9.0 will see rules\nstarting to fail to run, their rule page
failing to load and the API\nstarting to reject calls with excess
fields.\n\nFixes: https://github.com/elastic/kibana/issues/217384\n\n##
Testing instructions\n\n1. Start Kibana on 8.17 and create the following
rule using the API. Let\nthe rule
run.\n\n<details><summary>Rule</summary>\n\n```\n{\n \"name\": \"[QAF]
Observability rule 3\",\n \"tags\": [\n \"metrics\",\n \"threshold\",\n
\"qaf\"\n ],\n \"rule_type_id\": \"logs.alert.document.count\",\n
\"consumer\": \"alerts\",\n \"schedule\": {\n \"interval\": \"1m\"\n
},\n \"actions\": [],\n \"params\": {\n \"timeSize\": 8,\n \"timeUnit\":
\"h\",\n \"count\": {\n \"value\": 1,\n \"comparator\": \"more than\"\n
},\n \"criteria\": [\n {\n \"field\": \"bytes\",\n \"comparator\":
\"more than\",\n \"value\": 1\n }\n ],\n \"logView\": {\n \"logViewId\":
\"log-view-reference-0\",\n \"type\": \"log-view-reference\"\n },\n
\"groupBy\": [\n \"geo.dest\"\n ],\n \"outputIndex\":
\".alerts-observability.logs.alerts-default\"\n }\n}\n```\n\n</details>
\n\n2. Start Kibana on 8.18. Verify that you cannot create the same rule
and\nthe rule created in step 1 starts failing.\n3. Start Kibana on this
PR and that you can create the same rule and the\nrule created in step 1
is working as expected.\n\n### Checklist\n\nCheck the PR satisfies
following conditions. \n\nReviewers should verify this PR satisfies this
list as well.\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"2a01722cfa42772b584e195eaebf4078e0cc5be2","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:ResponseOps","v9.0.0","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[ResponseOps][Rules]
Ignore unknowns in the schema of the log threshold
params","number":217440,"url":"https://github.com/elastic/kibana/pull/217440","mergeCommit":{"message":"[ResponseOps][Rules]
Ignore unknowns in the schema of the log threshold params
(#217440)\n\n## Summary\n\nA PR introduced into
8.18/9.0\n(#205507) changed the
way we\nvalidate the log threshold rule type parameters. The validation
happens\non rule params and changes a loose validation to a strict
validation, so\nthose users who’ve inserted excess fields before
8.18/9.0 will see rules\nstarting to fail to run, their rule page
failing to load and the API\nstarting to reject calls with excess
fields.\n\nFixes: https://github.com/elastic/kibana/issues/217384\n\n##
Testing instructions\n\n1. Start Kibana on 8.17 and create the following
rule using the API. Let\nthe rule
run.\n\n<details><summary>Rule</summary>\n\n```\n{\n \"name\": \"[QAF]
Observability rule 3\",\n \"tags\": [\n \"metrics\",\n \"threshold\",\n
\"qaf\"\n ],\n \"rule_type_id\": \"logs.alert.document.count\",\n
\"consumer\": \"alerts\",\n \"schedule\": {\n \"interval\": \"1m\"\n
},\n \"actions\": [],\n \"params\": {\n \"timeSize\": 8,\n \"timeUnit\":
\"h\",\n \"count\": {\n \"value\": 1,\n \"comparator\": \"more than\"\n
},\n \"criteria\": [\n {\n \"field\": \"bytes\",\n \"comparator\":
\"more than\",\n \"value\": 1\n }\n ],\n \"logView\": {\n \"logViewId\":
\"log-view-reference-0\",\n \"type\": \"log-view-reference\"\n },\n
\"groupBy\": [\n \"geo.dest\"\n ],\n \"outputIndex\":
\".alerts-observability.logs.alerts-default\"\n }\n}\n```\n\n</details>
\n\n2. Start Kibana on 8.18. Verify that you cannot create the same rule
and\nthe rule created in step 1 starts failing.\n3. Start Kibana on this
PR and that you can create the same rule and the\nrule created in step 1
is working as expected.\n\n### Checklist\n\nCheck the PR satisfies
following conditions. \n\nReviewers should verify this PR satisfies this
list as well.\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"2a01722cfa42772b584e195eaebf4078e0cc5be2"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217440","number":217440,"mergeCommit":{"message":"[ResponseOps][Rules]
Ignore unknowns in the schema of the log threshold params
(#217440)\n\n## Summary\n\nA PR introduced into
8.18/9.0\n(#205507) changed the
way we\nvalidate the log threshold rule type parameters. The validation
happens\non rule params and changes a loose validation to a strict
validation, so\nthose users who’ve inserted excess fields before
8.18/9.0 will see rules\nstarting to fail to run, their rule page
failing to load and the API\nstarting to reject calls with excess
fields.\n\nFixes: https://github.com/elastic/kibana/issues/217384\n\n##
Testing instructions\n\n1. Start Kibana on 8.17 and create the following
rule using the API. Let\nthe rule
run.\n\n<details><summary>Rule</summary>\n\n```\n{\n \"name\": \"[QAF]
Observability rule 3\",\n \"tags\": [\n \"metrics\",\n \"threshold\",\n
\"qaf\"\n ],\n \"rule_type_id\": \"logs.alert.document.count\",\n
\"consumer\": \"alerts\",\n \"schedule\": {\n \"interval\": \"1m\"\n
},\n \"actions\": [],\n \"params\": {\n \"timeSize\": 8,\n \"timeUnit\":
\"h\",\n \"count\": {\n \"value\": 1,\n \"comparator\": \"more than\"\n
},\n \"criteria\": [\n {\n \"field\": \"bytes\",\n \"comparator\":
\"more than\",\n \"value\": 1\n }\n ],\n \"logView\": {\n \"logViewId\":
\"log-view-reference-0\",\n \"type\": \"log-view-reference\"\n },\n
\"groupBy\": [\n \"geo.dest\"\n ],\n \"outputIndex\":
\".alerts-observability.logs.alerts-default\"\n }\n}\n```\n\n</details>
\n\n2. Start Kibana on 8.18. Verify that you cannot create the same rule
and\nthe rule created in step 1 starts failing.\n3. Start Kibana on this
PR and that you can create the same rule and the\nrule created in step 1
is working as expected.\n\n### Checklist\n\nCheck the PR satisfies
following conditions. \n\nReviewers should verify this PR satisfies this
list as well.\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"2a01722cfa42772b584e195eaebf4078e0cc5be2"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Christos Nasikas <christos.nasikas@elastic.co>
kibanamachine added a commit that referenced this pull request Apr 8, 2025
…threshold params (#217440) (#217525)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[ResponseOps][Rules] Ignore unknowns in the schema of the log
threshold params
(#217440)](#217440)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Christos
Nasikas","email":"christos.nasikas@elastic.co"},"sourceCommit":{"committedDate":"2025-04-08T13:58:26Z","message":"[ResponseOps][Rules]
Ignore unknowns in the schema of the log threshold params
(#217440)\n\n## Summary\n\nA PR introduced into
8.18/9.0\n(#205507) changed the
way we\nvalidate the log threshold rule type parameters. The validation
happens\non rule params and changes a loose validation to a strict
validation, so\nthose users who’ve inserted excess fields before
8.18/9.0 will see rules\nstarting to fail to run, their rule page
failing to load and the API\nstarting to reject calls with excess
fields.\n\nFixes: https://github.com/elastic/kibana/issues/217384\n\n##
Testing instructions\n\n1. Start Kibana on 8.17 and create the following
rule using the API. Let\nthe rule
run.\n\n<details><summary>Rule</summary>\n\n```\n{\n \"name\": \"[QAF]
Observability rule 3\",\n \"tags\": [\n \"metrics\",\n \"threshold\",\n
\"qaf\"\n ],\n \"rule_type_id\": \"logs.alert.document.count\",\n
\"consumer\": \"alerts\",\n \"schedule\": {\n \"interval\": \"1m\"\n
},\n \"actions\": [],\n \"params\": {\n \"timeSize\": 8,\n \"timeUnit\":
\"h\",\n \"count\": {\n \"value\": 1,\n \"comparator\": \"more than\"\n
},\n \"criteria\": [\n {\n \"field\": \"bytes\",\n \"comparator\":
\"more than\",\n \"value\": 1\n }\n ],\n \"logView\": {\n \"logViewId\":
\"log-view-reference-0\",\n \"type\": \"log-view-reference\"\n },\n
\"groupBy\": [\n \"geo.dest\"\n ],\n \"outputIndex\":
\".alerts-observability.logs.alerts-default\"\n }\n}\n```\n\n</details>
\n\n2. Start Kibana on 8.18. Verify that you cannot create the same rule
and\nthe rule created in step 1 starts failing.\n3. Start Kibana on this
PR and that you can create the same rule and the\nrule created in step 1
is working as expected.\n\n### Checklist\n\nCheck the PR satisfies
following conditions. \n\nReviewers should verify this PR satisfies this
list as well.\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"2a01722cfa42772b584e195eaebf4078e0cc5be2","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:ResponseOps","v9.0.0","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[ResponseOps][Rules]
Ignore unknowns in the schema of the log threshold
params","number":217440,"url":"https://github.com/elastic/kibana/pull/217440","mergeCommit":{"message":"[ResponseOps][Rules]
Ignore unknowns in the schema of the log threshold params
(#217440)\n\n## Summary\n\nA PR introduced into
8.18/9.0\n(#205507) changed the
way we\nvalidate the log threshold rule type parameters. The validation
happens\non rule params and changes a loose validation to a strict
validation, so\nthose users who’ve inserted excess fields before
8.18/9.0 will see rules\nstarting to fail to run, their rule page
failing to load and the API\nstarting to reject calls with excess
fields.\n\nFixes: https://github.com/elastic/kibana/issues/217384\n\n##
Testing instructions\n\n1. Start Kibana on 8.17 and create the following
rule using the API. Let\nthe rule
run.\n\n<details><summary>Rule</summary>\n\n```\n{\n \"name\": \"[QAF]
Observability rule 3\",\n \"tags\": [\n \"metrics\",\n \"threshold\",\n
\"qaf\"\n ],\n \"rule_type_id\": \"logs.alert.document.count\",\n
\"consumer\": \"alerts\",\n \"schedule\": {\n \"interval\": \"1m\"\n
},\n \"actions\": [],\n \"params\": {\n \"timeSize\": 8,\n \"timeUnit\":
\"h\",\n \"count\": {\n \"value\": 1,\n \"comparator\": \"more than\"\n
},\n \"criteria\": [\n {\n \"field\": \"bytes\",\n \"comparator\":
\"more than\",\n \"value\": 1\n }\n ],\n \"logView\": {\n \"logViewId\":
\"log-view-reference-0\",\n \"type\": \"log-view-reference\"\n },\n
\"groupBy\": [\n \"geo.dest\"\n ],\n \"outputIndex\":
\".alerts-observability.logs.alerts-default\"\n }\n}\n```\n\n</details>
\n\n2. Start Kibana on 8.18. Verify that you cannot create the same rule
and\nthe rule created in step 1 starts failing.\n3. Start Kibana on this
PR and that you can create the same rule and the\nrule created in step 1
is working as expected.\n\n### Checklist\n\nCheck the PR satisfies
following conditions. \n\nReviewers should verify this PR satisfies this
list as well.\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"2a01722cfa42772b584e195eaebf4078e0cc5be2"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217440","number":217440,"mergeCommit":{"message":"[ResponseOps][Rules]
Ignore unknowns in the schema of the log threshold params
(#217440)\n\n## Summary\n\nA PR introduced into
8.18/9.0\n(#205507) changed the
way we\nvalidate the log threshold rule type parameters. The validation
happens\non rule params and changes a loose validation to a strict
validation, so\nthose users who’ve inserted excess fields before
8.18/9.0 will see rules\nstarting to fail to run, their rule page
failing to load and the API\nstarting to reject calls with excess
fields.\n\nFixes: https://github.com/elastic/kibana/issues/217384\n\n##
Testing instructions\n\n1. Start Kibana on 8.17 and create the following
rule using the API. Let\nthe rule
run.\n\n<details><summary>Rule</summary>\n\n```\n{\n \"name\": \"[QAF]
Observability rule 3\",\n \"tags\": [\n \"metrics\",\n \"threshold\",\n
\"qaf\"\n ],\n \"rule_type_id\": \"logs.alert.document.count\",\n
\"consumer\": \"alerts\",\n \"schedule\": {\n \"interval\": \"1m\"\n
},\n \"actions\": [],\n \"params\": {\n \"timeSize\": 8,\n \"timeUnit\":
\"h\",\n \"count\": {\n \"value\": 1,\n \"comparator\": \"more than\"\n
},\n \"criteria\": [\n {\n \"field\": \"bytes\",\n \"comparator\":
\"more than\",\n \"value\": 1\n }\n ],\n \"logView\": {\n \"logViewId\":
\"log-view-reference-0\",\n \"type\": \"log-view-reference\"\n },\n
\"groupBy\": [\n \"geo.dest\"\n ],\n \"outputIndex\":
\".alerts-observability.logs.alerts-default\"\n }\n}\n```\n\n</details>
\n\n2. Start Kibana on 8.18. Verify that you cannot create the same rule
and\nthe rule created in step 1 starts failing.\n3. Start Kibana on this
PR and that you can create the same rule and the\nrule created in step 1
is working as expected.\n\n### Checklist\n\nCheck the PR satisfies
following conditions. \n\nReviewers should verify this PR satisfies this
list as well.\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"2a01722cfa42772b584e195eaebf4078e0cc5be2"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Christos Nasikas <christos.nasikas@elastic.co>
kibanamachine added a commit that referenced this pull request Apr 8, 2025
…hreshold params (#217440) (#217527)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[ResponseOps][Rules] Ignore unknowns in the schema of the log
threshold params
(#217440)](#217440)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Christos
Nasikas","email":"christos.nasikas@elastic.co"},"sourceCommit":{"committedDate":"2025-04-08T13:58:26Z","message":"[ResponseOps][Rules]
Ignore unknowns in the schema of the log threshold params
(#217440)\n\n## Summary\n\nA PR introduced into
8.18/9.0\n(#205507) changed the
way we\nvalidate the log threshold rule type parameters. The validation
happens\non rule params and changes a loose validation to a strict
validation, so\nthose users who’ve inserted excess fields before
8.18/9.0 will see rules\nstarting to fail to run, their rule page
failing to load and the API\nstarting to reject calls with excess
fields.\n\nFixes: https://github.com/elastic/kibana/issues/217384\n\n##
Testing instructions\n\n1. Start Kibana on 8.17 and create the following
rule using the API. Let\nthe rule
run.\n\n<details><summary>Rule</summary>\n\n```\n{\n \"name\": \"[QAF]
Observability rule 3\",\n \"tags\": [\n \"metrics\",\n \"threshold\",\n
\"qaf\"\n ],\n \"rule_type_id\": \"logs.alert.document.count\",\n
\"consumer\": \"alerts\",\n \"schedule\": {\n \"interval\": \"1m\"\n
},\n \"actions\": [],\n \"params\": {\n \"timeSize\": 8,\n \"timeUnit\":
\"h\",\n \"count\": {\n \"value\": 1,\n \"comparator\": \"more than\"\n
},\n \"criteria\": [\n {\n \"field\": \"bytes\",\n \"comparator\":
\"more than\",\n \"value\": 1\n }\n ],\n \"logView\": {\n \"logViewId\":
\"log-view-reference-0\",\n \"type\": \"log-view-reference\"\n },\n
\"groupBy\": [\n \"geo.dest\"\n ],\n \"outputIndex\":
\".alerts-observability.logs.alerts-default\"\n }\n}\n```\n\n</details>
\n\n2. Start Kibana on 8.18. Verify that you cannot create the same rule
and\nthe rule created in step 1 starts failing.\n3. Start Kibana on this
PR and that you can create the same rule and the\nrule created in step 1
is working as expected.\n\n### Checklist\n\nCheck the PR satisfies
following conditions. \n\nReviewers should verify this PR satisfies this
list as well.\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"2a01722cfa42772b584e195eaebf4078e0cc5be2","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:ResponseOps","v9.0.0","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[ResponseOps][Rules]
Ignore unknowns in the schema of the log threshold
params","number":217440,"url":"https://github.com/elastic/kibana/pull/217440","mergeCommit":{"message":"[ResponseOps][Rules]
Ignore unknowns in the schema of the log threshold params
(#217440)\n\n## Summary\n\nA PR introduced into
8.18/9.0\n(#205507) changed the
way we\nvalidate the log threshold rule type parameters. The validation
happens\non rule params and changes a loose validation to a strict
validation, so\nthose users who’ve inserted excess fields before
8.18/9.0 will see rules\nstarting to fail to run, their rule page
failing to load and the API\nstarting to reject calls with excess
fields.\n\nFixes: https://github.com/elastic/kibana/issues/217384\n\n##
Testing instructions\n\n1. Start Kibana on 8.17 and create the following
rule using the API. Let\nthe rule
run.\n\n<details><summary>Rule</summary>\n\n```\n{\n \"name\": \"[QAF]
Observability rule 3\",\n \"tags\": [\n \"metrics\",\n \"threshold\",\n
\"qaf\"\n ],\n \"rule_type_id\": \"logs.alert.document.count\",\n
\"consumer\": \"alerts\",\n \"schedule\": {\n \"interval\": \"1m\"\n
},\n \"actions\": [],\n \"params\": {\n \"timeSize\": 8,\n \"timeUnit\":
\"h\",\n \"count\": {\n \"value\": 1,\n \"comparator\": \"more than\"\n
},\n \"criteria\": [\n {\n \"field\": \"bytes\",\n \"comparator\":
\"more than\",\n \"value\": 1\n }\n ],\n \"logView\": {\n \"logViewId\":
\"log-view-reference-0\",\n \"type\": \"log-view-reference\"\n },\n
\"groupBy\": [\n \"geo.dest\"\n ],\n \"outputIndex\":
\".alerts-observability.logs.alerts-default\"\n }\n}\n```\n\n</details>
\n\n2. Start Kibana on 8.18. Verify that you cannot create the same rule
and\nthe rule created in step 1 starts failing.\n3. Start Kibana on this
PR and that you can create the same rule and the\nrule created in step 1
is working as expected.\n\n### Checklist\n\nCheck the PR satisfies
following conditions. \n\nReviewers should verify this PR satisfies this
list as well.\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"2a01722cfa42772b584e195eaebf4078e0cc5be2"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217440","number":217440,"mergeCommit":{"message":"[ResponseOps][Rules]
Ignore unknowns in the schema of the log threshold params
(#217440)\n\n## Summary\n\nA PR introduced into
8.18/9.0\n(#205507) changed the
way we\nvalidate the log threshold rule type parameters. The validation
happens\non rule params and changes a loose validation to a strict
validation, so\nthose users who’ve inserted excess fields before
8.18/9.0 will see rules\nstarting to fail to run, their rule page
failing to load and the API\nstarting to reject calls with excess
fields.\n\nFixes: https://github.com/elastic/kibana/issues/217384\n\n##
Testing instructions\n\n1. Start Kibana on 8.17 and create the following
rule using the API. Let\nthe rule
run.\n\n<details><summary>Rule</summary>\n\n```\n{\n \"name\": \"[QAF]
Observability rule 3\",\n \"tags\": [\n \"metrics\",\n \"threshold\",\n
\"qaf\"\n ],\n \"rule_type_id\": \"logs.alert.document.count\",\n
\"consumer\": \"alerts\",\n \"schedule\": {\n \"interval\": \"1m\"\n
},\n \"actions\": [],\n \"params\": {\n \"timeSize\": 8,\n \"timeUnit\":
\"h\",\n \"count\": {\n \"value\": 1,\n \"comparator\": \"more than\"\n
},\n \"criteria\": [\n {\n \"field\": \"bytes\",\n \"comparator\":
\"more than\",\n \"value\": 1\n }\n ],\n \"logView\": {\n \"logViewId\":
\"log-view-reference-0\",\n \"type\": \"log-view-reference\"\n },\n
\"groupBy\": [\n \"geo.dest\"\n ],\n \"outputIndex\":
\".alerts-observability.logs.alerts-default\"\n }\n}\n```\n\n</details>
\n\n2. Start Kibana on 8.18. Verify that you cannot create the same rule
and\nthe rule created in step 1 starts failing.\n3. Start Kibana on this
PR and that you can create the same rule and the\nrule created in step 1
is working as expected.\n\n### Checklist\n\nCheck the PR satisfies
following conditions. \n\nReviewers should verify this PR satisfies this
list as well.\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"2a01722cfa42772b584e195eaebf4078e0cc5be2"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Christos Nasikas <christos.nasikas@elastic.co>
@mistic mistic added v9.0.1 and removed v9.0.0 labels Apr 15, 2025
@mistic
Copy link
Member

mistic commented Apr 15, 2025

This PR didn't make it into the latest BC. Updating the labels.

=====

UPDATE: please ignore this comment, the PR did make it.

@cnasikas
Copy link
Member Author

@mistic This was an important fix for a 9.0/8.18 release blocker. The PR got merged a week ago. Why it is not part of the release? cc @kobelb @mikecote @heespi

@mikecote
Copy link
Contributor

From what I gather, it's part of the release based on the tags:

@mistic what filter did you use to label PRs as 9.0.1?

@mistic mistic added v9.0.0 and removed v9.0.1 labels Apr 15, 2025
@mistic
Copy link
Member

mistic commented Apr 15, 2025

@cnasikas @mikecote please disregard my previous comment. I did pick a wrong BC sha which generated a false alert. All good as expected and labels were fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.18.0 v8.19.0 v9.0.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken rule after upgrade disables rule management page.
9 participants