-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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] "Internal Monitoring" deprecation warning #72020
Merged
igoristic
merged 20 commits into
elastic:master
from
igoristic:internal-monitoring-deprecation
Jul 27, 2020
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
978c636
Internal Monitoring deprecation
igoristic df51458
Fixed type
igoristic 6750d52
Added if cloud logic
igoristic 654e485
Merge branch 'master' of https://github.com/elastic/kibana into inter…
igoristic 6ef83f1
Fixed i18n test
igoristic 8797eab
Merge branch 'master' of https://github.com/elastic/kibana into inter…
igoristic 4582b2a
Merge branch 'master' of https://github.com/elastic/kibana into inter…
igoristic cbb0fb4
Addressed code review feedback
igoristic d6b31c2
Merge branch 'master' of https://github.com/elastic/kibana into inter…
igoristic b9e7db8
Fixed types
igoristic 28f4093
Merge branch 'master' of https://github.com/elastic/kibana into inter…
igoristic 57cbbfc
Merge branch 'master' of https://github.com/elastic/kibana into inter…
igoristic a3171f9
Changed query
igoristic 2c45f1c
Merge branch 'master' into internal-monitoring-deprecation
elasticmachine 60daec3
Merge branch 'master' into internal-monitoring-deprecation
elasticmachine ddbdad0
Merge branch 'master' into internal-monitoring-deprecation
elasticmachine 2216464
Added delay to fix a test
igoristic 24f8817
Merge branch 'master' of https://github.com/elastic/kibana into inter…
igoristic c44908f
Fixed tests
igoristic 9c7d7b7
Fixed text
igoristic 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
This file contains 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 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 |
---|---|---|
|
@@ -4,46 +4,97 @@ | |
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { CatIndicesParams } from 'elasticsearch'; | ||
// @ts-ignore | ||
import { RequestHandlerContext } from 'kibana/server'; | ||
import { getIndexPatterns } from '../../../../../lib/cluster/get_index_patterns'; | ||
|
||
// @ts-ignore | ||
import { handleError } from '../../../../../lib/errors'; | ||
import { RouteDependencies } from '../../../../../types'; | ||
|
||
export function internalMonitoringCheckRoute(_server: unknown, npRoute: RouteDependencies) { | ||
const queryBody = { | ||
size: 15, | ||
igoristic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
query: { | ||
bool: { | ||
filter: [ | ||
{ | ||
range: { | ||
timestamp: { | ||
gte: 'now-15m', | ||
igoristic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
lte: 'now', | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
sort: [ | ||
{ | ||
timestamp: { | ||
order: 'desc', | ||
}, | ||
}, | ||
], | ||
_source: { | ||
excludes: ['*'], | ||
}, | ||
}; | ||
|
||
const checkLatestMonitoringIsLegacy = async (context: RequestHandlerContext, index: string) => { | ||
const { client: esClient } = context.core.elasticsearch.legacy; | ||
const result = await esClient.callAsCurrentUser('search', { | ||
index, | ||
body: queryBody, | ||
}); | ||
|
||
const { | ||
hits: { hits }, | ||
} = result; | ||
const counts = { | ||
legacyIndicesCount: 0, | ||
mbIndicesCount: 0, | ||
}; | ||
|
||
if (!hits?.length) { | ||
return counts; | ||
} | ||
|
||
counts.mbIndicesCount = hits.filter(({ _index }: { _index: string }) => | ||
_index.includes('-mb-') | ||
).length; | ||
|
||
counts.legacyIndicesCount = hits.length - counts.mbIndicesCount; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These counts seem off to me. I added this debug code: which results in:
Maybe you can just do a query like:
|
||
|
||
return counts; | ||
}; | ||
|
||
export function internalMonitoringCheckRoute(server: unknown, npRoute: RouteDependencies) { | ||
npRoute.router.get( | ||
{ | ||
path: '/api/monitoring/v1/elasticsearch_settings/check/internal_monitoring', | ||
options: { tags: ['access:monitoring'] }, | ||
validate: false, | ||
}, | ||
async (context, _request, response) => { | ||
try { | ||
const catQuery: Pick<CatIndicesParams, 'format' | 'h'> & { | ||
expand_wildcards: string; | ||
index?: string; | ||
} = { | ||
format: 'json', | ||
h: 'index', | ||
expand_wildcards: 'hidden,all', | ||
index: '.monitoring-*', | ||
const typeCount = { | ||
legacy_indices: 0, | ||
mb_indices: 0, | ||
}; | ||
|
||
const { client: esClient } = context.core.elasticsearch.legacy; | ||
const monitoringIndices = await esClient.callAsInternalUser('transport.request', { | ||
method: 'GET', | ||
path: '/_cat/indices', | ||
query: catQuery, | ||
}); | ||
const { esIndexPattern, kbnIndexPattern, lsIndexPattern } = getIndexPatterns(server); | ||
const indexCounts = await Promise.all([ | ||
checkLatestMonitoringIsLegacy(context, esIndexPattern), | ||
checkLatestMonitoringIsLegacy(context, kbnIndexPattern), | ||
checkLatestMonitoringIsLegacy(context, lsIndexPattern), | ||
]); | ||
|
||
const mbIndices = monitoringIndices.filter(({ index }: { index: string }) => | ||
index.includes('-mb-') | ||
); | ||
indexCounts.forEach((counts) => { | ||
typeCount.legacy_indices += counts.legacyIndicesCount; | ||
typeCount.mb_indices += counts.mbIndicesCount; | ||
}); | ||
|
||
return response.ok({ | ||
body: { | ||
legacy_indices: Boolean(monitoringIndices.length - mbIndices.length), | ||
mb_indices: Boolean(mbIndices.length), | ||
}, | ||
body: typeCount, | ||
}); | ||
} catch (err) { | ||
throw handleError(err); | ||
|
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.
What if we said:
Monitoring will require Metricbeat collection in the next major version (8.0.0).
or maybe @gchaps can help here
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.
How about:
In 8.0.0, you must use Metricbeat to collect monitoring data.