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

[Monitoring] Using primary average shard size #96177

Merged
merged 11 commits into from
Apr 13, 2021

Conversation

igoristic
Copy link
Contributor

@igoristic igoristic commented Apr 2, 2021

Resolves: #96145

Instead of using index_stats.primaries.store.size_in_bytes raw value we are calculating shard average size:

index_stats.primaries.store.size_in_bytes / index_stats.shards.primaries

@igoristic igoristic added Team:Monitoring Stack Monitoring team v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.13.0 v7.12.1 labels Apr 2, 2021
@igoristic igoristic requested a review from a team April 2, 2021 21:06
@elasticmachine
Copy link
Contributor

Pinging @elastic/stack-monitoring (Team:Monitoring)

@igoristic igoristic changed the title [Monitoring] Using average shard size [Monitoring] Using primary average shard size Apr 6, 2021
Copy link
Member

@jasonrhodes jasonrhodes left a comment

Choose a reason for hiding this comment

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

Just a few questions, thanks!

docs/user/monitoring/kibana-alerts.asciidoc Outdated Show resolved Hide resolved
x-pack/plugins/monitoring/common/constants.ts Outdated Show resolved Hide resolved
const { name: nodeName, uuid: nodeId } = sourceNode;
const shardSize = +(shardSizeBytes! / gbMultiplier).toFixed(2);
const avgShardSize = primaryShardSizeBytes ? primaryShardSizeBytes / totalPrimaryShards : 0;
Copy link
Member

Choose a reason for hiding this comment

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

We're already defaulting this value to 0 on line 145, right? 0 / totalPrimaryShards will be 0 so do we need this ternary?

Also, do we ever expect totalPrimaryShards to be 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, the ternary actually checks to make sure it's not 0 (which can be either from the response or our default), since I don't want to divide the 0 (like you mentioned). Maybe scoping would make it more readable? eg:

avgShardSize = primaryShardSizeBytes ? (primaryShardSizeBytes / totalPrimaryShards) : 0

...do we ever expect totalPrimaryShards to be 0

Yes, it's possible to have zero primaries (mainly during the allocation of shards), in which case the cluster status goes red (though in most cases it's temporary since not all shards are yet assigned). This article explains it very well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess I don't even need this check, since I'm already doing this right before:

if (!primaryShardSizeBytes) {
  continue;
}

Copy link
Member

Choose a reason for hiding this comment

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

Exactly, that's what I was thinking. I asked about totalPrimaryShards because we're currently not checking that value to make sure it's not 0, so I think we can still end up in a divide by 0 scenario here, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, because the condition if (primaryShardSizeBytes) would not pass because 0 is actually considered falsy in javascript/ts. So, we don't need to explicitly say if (primaryShardSizeBytes === 0)

Copy link
Member

Choose a reason for hiding this comment

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

Heh, yeah I know about 0 being falsy ;) I'm asking about the denominator, totalPrimaryShards.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eh, I see your point now, sorry for the derp moment 🙃

Added that to the check as well, so should be good now

@jasonrhodes
Copy link
Member

@ravikesarwani / @igoristic I requested we simplify the language here a bit and just say "average shard size" because that's what we're trying to calculate by dividing primary size by primary count.

If you all think that we definitely need to specify "primary" everywhere, can we say "average primary shard size" rather than "(primary average) shard size"?

@ravikesarwani
Copy link
Contributor

From the user perspective "average shard size" is good enough.
In code I would assume we should say in the comments why we choose to use primary shard for the calculation.

@igoristic igoristic requested a review from jasonrhodes April 12, 2021 16:05
Copy link
Member

@jasonrhodes jasonrhodes left a comment

Choose a reason for hiding this comment

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

A few more questions/changes.

x-pack/plugins/monitoring/common/constants.ts Outdated Show resolved Hide resolved
@igoristic
Copy link
Contributor Author

@elasticmachine merge upstream

@igoristic igoristic requested a review from jasonrhodes April 13, 2021 14:42
Copy link
Member

@jasonrhodes jasonrhodes left a comment

Choose a reason for hiding this comment

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

LGTM

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
monitoring 45.4KB 45.5KB +38.0B

History

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

@igoristic igoristic merged commit 355c949 into elastic:master Apr 13, 2021
@igoristic igoristic deleted the fix_large_shard_size branch April 13, 2021 21:01
igoristic added a commit to igoristic/kibana that referenced this pull request Apr 13, 2021
* Using shard size avg instead of primary total

* Added ui text

* Changed to primary average instead of total

* Addressed cr feedback

* Added zero check

* Fixed threshold checking

* Changed description

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
igoristic added a commit that referenced this pull request Apr 13, 2021
* Using shard size avg instead of primary total

* Added ui text

* Changed to primary average instead of total

* Addressed cr feedback

* Added zero check

* Fixed threshold checking

* Changed description

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

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
igoristic added a commit that referenced this pull request Apr 13, 2021
* Using shard size avg instead of primary total

* Added ui text

* Changed to primary average instead of total

* Addressed cr feedback

* Added zero check

* Fixed threshold checking

* Changed description

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

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

Backport:
7.x: cc27608
7.12: 9ddd575

jloleysens added a commit to jloleysens/kibana that referenced this pull request Apr 14, 2021
…ax_primary_shard_size

* 'master' of github.com:elastic/kibana: (99 commits)
  added missing optional chain for bracket notation (elastic#96939)
  [Discover][DocViewer] Fix toggle columns from doc viewer table tab (elastic#95748)
  [TSVB] Fix per-request caching of index patterns (elastic#97043)
  [Datatable] Fix filter cell flakiness (elastic#96934)
  Unskip heatmap suite and fixes flakiness (elastic#96941)
  [Fleet] Improve performance of data stream API (elastic#97058)
  [ML] Data Frame Analytics: remove beta badge (elastic#96977)
  [App Search] Migrate expanded rows for meta engines table in Engines Overview (elastic#96251)
  Instances latency distribution chart tooltips and axis fixes (elastic#95577)
  [Monitoring] Using primary average shard size (elastic#96177)
  [Workplace Search] Hide Kibana chrome on 3rd party connector redirects (elastic#97028)
  ## [Security Solution] Fixes `Exit full screen` and `Copy to cliboard` styling issues (elastic#96676)
  Index pattern field editor - Add warning on name or type change (elastic#95528)
  [App Search] Add small engine breadcrumb utility helper (elastic#96917)
  Copy esArchiver commands from ./reassign.ts to fix tests (elastic#97012)
  [Security Solution][Detections] Updates MITRE Tactics, Techniques, and Subtechniques for 7.13 (elastic#97011)
  Index patterns server - throw correct error on field caps 404 (elastic#95879)
  Use `EuiThemeProvider` in lists plugin tests and stories (elastic#96129)
  [npm] upgrade caniuse database (elastic#97002)
  chore(NA): moving @kbn/apm-utils into bazel (elastic#96227)
  ...

# Conflicts:
#	x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/serialization/policy_serialization.test.ts
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/schema.ts
phillipb added a commit to phillipb/kibana that referenced this pull request Apr 14, 2021
…to-metrics-tab

* 'master' of github.com:elastic/kibana: (61 commits)
  [Usage collection] Usage counters (elastic#96696)
  UI actions readme (elastic#96925)
  [TSVB] Enable brush for visualizations created with no index patterns (elastic#96727)
  [Data telemetry] Add Async Search to the tests (elastic#96693)
  added missing optional chain for bracket notation (elastic#96939)
  [Discover][DocViewer] Fix toggle columns from doc viewer table tab (elastic#95748)
  [TSVB] Fix per-request caching of index patterns (elastic#97043)
  [Datatable] Fix filter cell flakiness (elastic#96934)
  Unskip heatmap suite and fixes flakiness (elastic#96941)
  [Fleet] Improve performance of data stream API (elastic#97058)
  [ML] Data Frame Analytics: remove beta badge (elastic#96977)
  [App Search] Migrate expanded rows for meta engines table in Engines Overview (elastic#96251)
  Instances latency distribution chart tooltips and axis fixes (elastic#95577)
  [Monitoring] Using primary average shard size (elastic#96177)
  [Workplace Search] Hide Kibana chrome on 3rd party connector redirects (elastic#97028)
  ## [Security Solution] Fixes `Exit full screen` and `Copy to cliboard` styling issues (elastic#96676)
  Index pattern field editor - Add warning on name or type change (elastic#95528)
  [App Search] Add small engine breadcrumb utility helper (elastic#96917)
  Copy esArchiver commands from ./reassign.ts to fix tests (elastic#97012)
  [Security Solution][Detections] Updates MITRE Tactics, Techniques, and Subtechniques for 7.13 (elastic#97011)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:Monitoring Stack Monitoring team v7.12.1 v7.13.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Monitoring] Calculate average shard size for "Large Shard Size" alert
5 participants