-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Infra][Hosts] Fix inventory Network Inbound and Outbound alert rules #251855
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
crespocarlos
merged 6 commits into
elastic:main
from
crespocarlos:251854-fix-network-alerts
Feb 11, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
de40325
fix: inventory Network Inbound and Outbound alert rules
crespocarlos 4818925
Merge branch 'main' into 251854-fix-network-alerts
elasticmachine 5e2ab63
Merge branch 'main' into 251854-fix-network-alerts
elasticmachine 6547019
chore: clean up
crespocarlos 3a78b4c
Merge branch 'main' into 251854-fix-network-alerts
elasticmachine baf1125
Merge branch 'main' into 251854-fix-network-alerts
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
...ins/infra/server/lib/alerting/inventory_metric_threshold/lib/convert_metric_value.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { convertMetricValue } from './convert_metric_value'; | ||
|
|
||
| describe('convertMetricValue', () => { | ||
| describe('cpu metrics', () => { | ||
| it('should convert cpu percentage from 0-100 to 0-1 scale', () => { | ||
| expect(convertMetricValue('cpu', 50)).toBe(0.5); | ||
| expect(convertMetricValue('cpu', 100)).toBe(1); | ||
| expect(convertMetricValue('cpu', 0)).toBe(0); | ||
| }); | ||
|
|
||
| it('should convert cpuV2 percentage from 0-100 to 0-1 scale', () => { | ||
| expect(convertMetricValue('cpuV2', 50)).toBe(0.5); | ||
| expect(convertMetricValue('cpuV2', 100)).toBe(1); | ||
| expect(convertMetricValue('cpuV2', 0)).toBe(0); | ||
| }); | ||
| }); | ||
|
|
||
| describe('memory metrics', () => { | ||
| it('should convert memory percentage from 0-100 to 0-1 scale', () => { | ||
| expect(convertMetricValue('memory', 75)).toBe(0.75); | ||
| expect(convertMetricValue('memory', 100)).toBe(1); | ||
| expect(convertMetricValue('memory', 0)).toBe(0); | ||
| }); | ||
| }); | ||
|
|
||
| describe('network metrics (bits to bytes)', () => { | ||
| it('should convert tx threshold from bits to bytes', () => { | ||
| expect(convertMetricValue('tx', 8)).toBe(1); | ||
| }); | ||
|
|
||
| it('should convert rx threshold from bits to bytes', () => { | ||
| expect(convertMetricValue('rx', 8)).toBe(1); | ||
| expect(convertMetricValue('rx', 800)).toBe(100); | ||
| }); | ||
|
|
||
| it('should convert txV2 threshold from bits to bytes', () => { | ||
| expect(convertMetricValue('txV2', 8)).toBe(1); | ||
| expect(convertMetricValue('txV2', 800)).toBe(100); | ||
| expect(convertMetricValue('txV2', 450000)).toBe(56250); | ||
| }); | ||
|
|
||
| it('should convert rxV2 threshold from bits to bytes', () => { | ||
| expect(convertMetricValue('rxV2', 8)).toBe(1); | ||
| expect(convertMetricValue('rxV2', 800)).toBe(100); | ||
| expect(convertMetricValue('rxV2', 450000)).toBe(56250); | ||
| }); | ||
| }); | ||
|
|
||
| describe('metrics without conversion', () => { | ||
| it('should return the value unchanged for metrics without converters', () => { | ||
| expect(convertMetricValue('diskIOReadBytes', 1000)).toBe(1000); | ||
| expect(convertMetricValue('diskIOWriteBytes', 2000)).toBe(2000); | ||
| expect(convertMetricValue('logRate', 500)).toBe(500); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
For ECS,
rxV2andtxV2used the same fields asrxandtx, and we missed this conversion.For Semconv,
system.network.iois in bytes, but users set up these alerts in bits/s, so this conversion is also needed.