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

Several calls to the same stats request (esAlerts) #2586

Open
frankeros opened this issue Nov 3, 2020 · 2 comments
Open

Several calls to the same stats request (esAlerts) #2586

frankeros opened this issue Nov 3, 2020 · 2 comments
Assignees
Labels
type/bug Bug issue

Comments

@frankeros
Copy link
Contributor

Wazuh Elastic Rev
4.x 7.x 444

Description
The request esAlert is sent several times in the Dashboard.

Screenshots
stats

Additional context
It occurs because the request call is in the componentDidUpdate of the component class metrics

@frankeros
Copy link
Contributor Author

Update

It was tried to fix in this PR #2587.
This fix was tested on the dev environment. But in prod in some cases, this fix caused that the statics never load.
That's why the PR was reverted.

@frankeros
Copy link
Contributor Author

Update

Searching deeper, I found the reason why the prop resultState in metrics.tsx causing several request calls.

  • The component Metrics is a child of the component wzVisualize, and the last one is sending his prop resultState.

image

  • The component wzVisaulize is used as directive by the template dashboard and this is sending the global variable resultState

image

  • This global variable is set by the controller kibana-discovery.ts through a chain of watchers and observers.

image

But the problem is that this handler is setting resultState as 'loading' then as 'ready' two times when the controller loads.

This happens because the state of the filters is set two times when FilterManager is called.
The methods from the class FireManager are merging the provided filters and if there are changes, they fire the update events. .
image

The first time is here
image
With this data

{
  $state:
  {
    isImplicit: true,
    store: "appState"
  },
  meta:
  {
    alias: null,
    disabled: false,
    index: "wazuh-alerts-*",
    key: "cluster.name",
    negate: false,
    params: {query: "wazuh"},
    removable: false,
    type: "phrase",
    value: formatter => {}
  },
  query: { match: { cluster.name: {query: "wazuh", type: "phrase"}}}
}

But the method setAppFilters is removing the prop $state.isImplicit
image
image

That is why this prop is set againg here
image
Provoking the second update of the resultState

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Bug issue
Projects
None yet
Development

No branches or pull requests

2 participants