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

[RAC] Update alert documents in lifecycle rule type helper #101598

Merged
merged 8 commits into from
Jun 16, 2021

Conversation

dgieselaar
Copy link
Member

@dgieselaar dgieselaar commented Jun 8, 2021

Closes #100451.

Summary

Create event.kind:signal alert documents, and update those when an alert is/stays active, in addition to the append-only evaluations (which are now event.kind:event). Usage of collapse is also removed for the table/APM app views.

Other changes:

  • catch a no_matching_indices exception for the getDynamicIndexPattern function
  • make sure an index doesn't accidentally get created when there is no corresponding index template

@dgieselaar dgieselaar added release_note:skip Skip the PR/issue when compiling release notes v7.14.0 Theme: rac label obsolete labels Jun 8, 2021
@dgieselaar dgieselaar requested a review from a team as a code owner June 8, 2021 13:46
@botelastic botelastic bot added the Team:APM All issues that need APM UI Team support label Jun 8, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

Copy link
Contributor

@smith smith left a comment

Choose a reason for hiding this comment

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

Works on my machine!

await ruleDataClient.getWriter().bulk({
body: eventsToIndex.flatMap((event) => [{ index: {} }, event]),
body: eventsToIndex
Copy link
Contributor

Choose a reason for hiding this comment

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

This is clever, but it would be cleverer with an explanation of what's going on and a unit test.

Copy link
Member Author

Choose a reason for hiding this comment

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

OKAY OKAY I GET IT.

@jasonrhodes
Copy link
Member

Running this locally, I get this error in the transaction error rate rule type (it's being thrown from the ruleRegistry lifecycle rule type factory):

"action [indices:admin/create] is unauthorized for user [kibana_system_user] with roles [kibana_system] on indices [.alerts-observability-apm-000001], this action is granted by the index privileges [create_index,manage,all]"
Full Error JSON
{
  "reason": "execute",
  "error": {
    "name": "ResponseError",
    "meta": {
      "body": {
        "error": {
          "root_cause": [
            {
              "type": "security_exception",
              "reason": "action [indices:admin/create] is unauthorized for user [kibana_system_user] with roles [kibana_system] on indices [.alerts-observability-apm-000001], this action is granted by the index privileges [create_index,manage,all]"
            }
          ],
          "type": "security_exception",
          "reason": "action [indices:admin/create] is unauthorized for user [kibana_system_user] with roles [kibana_system] on indices [.alerts-observability-apm-000001], this action is granted by the index privileges [create_index,manage,all]"
        },
        "status": 403
      },
      "statusCode": 403,
      "headers": {
        "content-length": "565",
        "content-type": "application/json;charset=utf-8",
        "x-cloud-request-id": "b7SkxMHtRCmqtrHj78PWfQ",
        "x-found-handling-cluster": "b5caf8c576704714a9bb2559bddab987",
        "x-found-handling-instance": "instance-0000000040",
        "date": "Wed, 09 Jun 2021 23:05:39 GMT"
      },
      "meta": {
        "context": null,
        "request": {
          "params": {
            "method": "PUT",
            "path": "/.alerts-observability-apm-000001",
            "body": "{\"aliases\":{\".alerts-observability-apm\":{\"is_write_index\":true}}}",
            "querystring": "",
            "headers": {
              "user-agent": "elasticsearch-js/8.0.0-canary.4 (darwin 18.7.0-x64; Node.js v14.17.0)",
              "x-elastic-product-origin": "kibana",
              "x-elastic-client-meta": "es=8.0.0p,js=14.17.0,t=8.0.0p,hc=14.17.0",
              "content-type": "application/json",
              "content-length": "65"
            },
            "timeout": 30000
          },
          "options": {},
          "id": 309
        },
        "name": "elasticsearch-js",
        "connection": {
          "url": "https://b5caf8c576704714a9bb2559bddab987.us-east-1.aws.staging.foundit.no:9243/",
          "id": "https://b5caf8c576704714a9bb2559bddab987.us-east-1.aws.staging.foundit.no:9243/",
          "headers": {},
          "deadCount": 0,
          "resurrectTimeout": 0,
          "_openRequests": 0,
          "status": "alive",
          "roles": {
            "master": true,
            "data": true,
            "ingest": true,
            "ml": false
          }
        },
        "attempts": 0,
        "aborted": false
      }
    }
  }
}

Currently, Kibana can't parse this error accurately enough to expose the underlying error message, so it just prints:

server    log   [19:01:53.220] [error][alerting][alerting][plugins][plugins] Executing Alert "a57fda90-c96d-11eb-97f6-c3426f999277" has resulted in Error: security_exception, caused by: ""

@dgieselaar
Copy link
Member Author

@jasonrhodes what version of ES are you on? The error you are seeing is supposed to be handled by the ES permission changes in elastic/elasticsearch#72181.

@jasonrhodes
Copy link
Member

I'm pointed at the Edge cluster.

@jasonrhodes
Copy link
Member

No need to block these changes if we feel confident they're fixed. I'll keep playing with it after the merge.

@dgieselaar
Copy link
Member Author

@jasonrhodes at the time of writing, the edge cluster's ES snapshot is from 26th of April, which predates the privilege changes.

@jasonrhodes
Copy link
Member

OK well then let's merge this and I'll test against the Logs and Metrics rule stuff we're currently working on.

At another time, I need a refresher on how to test APM data locally when Edge isn't working, it's been a long time since I've run apm-integration-testing :)

@dgieselaar
Copy link
Member Author

@elasticmachine merge upstream

@dgieselaar dgieselaar added the auto-backport Deprecated - use backport:version if exact versions are needed label Jun 16, 2021
@dgieselaar dgieselaar enabled auto-merge (squash) June 16, 2021 16:11
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
ruleRegistry 6 7 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@dgieselaar dgieselaar merged commit 8eea491 into elastic:master Jun 16, 2021
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Jun 16, 2021
…01598)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Jun 16, 2021
…102397)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Dario Gieselaar <dario.gieselaar@elastic.co>
jloleysens added a commit to jloleysens/kibana that referenced this pull request Jun 17, 2021
…egrations-to-global-search

* 'master' of github.com:elastic/kibana: (46 commits)
  [Lens] Add some more documentation for dynamic coloring (elastic#101369)
  hide not searchable results when no term (elastic#102401)
  [Lens] Fix Formula functional test with multiple suggestions (elastic#102378)
  Fix trusted apps modified by field displayed as a date field (elastic#102377)
  [Lens] Docs for time shift (elastic#102048)
  update readme of logs-metrics-ui (elastic#101968)
  Refactor observability plugin breadcrumbs (elastic#102290)
  [Index Patterns] Move rollup config to index pattern management v2 (elastic#102285)
  [Security Solution][Endpoint] Isolate Action should only be available to Platinum+ licenses (elastic#102374)
  [build] Updates Ironbank templates (elastic#102407)
  Update security best practices document (elastic#100814)
  [Enterprise Search] Set up initial KibanaPageTemplate  (elastic#102170)
  [Reporting/Docs] Add section to troubleshooting guide to explain the StatusCodeError logs (elastic#102278)
  [DOCS] Updating Elastic Security Overview topic  (elastic#101922)
  [Uptime] refactor Synthetics Integration package UI (elastic#102080)
  [Task Manager] Log at different levels based on the state (elastic#101751)
  [APM] Fixing time comparison types (elastic#101423)
  [RAC] Update alert documents in lifecycle rule type helper (elastic#101598)
  [ML] Functional tests - fix and re-activate alerting flyout test (elastic#102368)
  [Reporting] remove unused reference to path.data config (elastic#102267)
  ...

# Conflicts:
#	x-pack/plugins/fleet/kibana.json
majagrubic pushed a commit to majagrubic/kibana that referenced this pull request Jun 18, 2021
…01598)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes Team:APM All issues that need APM UI Team support Theme: rac label obsolete v7.14.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RAC] Lifecycle rule type: fix the way we write RAC documents
5 participants