-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Conversation
Pinging @elastic/stack-monitoring (Team:Monitoring) |
There was a problem hiding this 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!
x-pack/plugins/monitoring/server/alerts/large_shard_size_alert.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/monitoring/server/alerts/large_shard_size_alert.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/monitoring/server/lib/alerts/fetch_index_shard_size.ts
Outdated
Show resolved
Hide resolved
const { name: nodeName, uuid: nodeId } = sourceNode; | ||
const shardSize = +(shardSizeBytes! / gbMultiplier).toFixed(2); | ||
const avgShardSize = primaryShardSizeBytes ? primaryShardSizeBytes / totalPrimaryShards : 0; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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;
}
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
@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"? |
From the user perspective "average shard size" is good enough. |
There was a problem hiding this 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/server/lib/alerts/fetch_index_shard_size.ts
Outdated
Show resolved
Hide resolved
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
💚 Build Succeeded
Metrics [docs]Page load bundle
History
To update your PR or re-run it, just comment with: |
* 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>
* 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>
* 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>
…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
…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) ...
Resolves: #96145
Instead of using
index_stats.primaries.store.size_in_bytes
raw value we are calculating shard average size: