[Monitoring] Cloud property not properly passed when no monitoring data found (#87649)
* Fix parameter usage * Fix up incorrect usage again * Add another check * Fix tests Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
103e8f91c8
commit
33603e749d
|
@ -12,10 +12,13 @@ export function handleResponse(response, isCloudEnabled) {
|
||||||
for (const source of sources) {
|
for (const source of sources) {
|
||||||
const monitoringSettings = get(response[source], 'xpack.monitoring');
|
const monitoringSettings = get(response[source], 'xpack.monitoring');
|
||||||
if (monitoringSettings !== undefined) {
|
if (monitoringSettings !== undefined) {
|
||||||
const check = findReason(monitoringSettings, {
|
const check = findReason(
|
||||||
context: `cluster ${source}`,
|
monitoringSettings,
|
||||||
isCloudEnabled,
|
{
|
||||||
});
|
context: `cluster ${source}`,
|
||||||
|
},
|
||||||
|
isCloudEnabled
|
||||||
|
);
|
||||||
|
|
||||||
if (check.found) {
|
if (check.found) {
|
||||||
return check;
|
return check;
|
||||||
|
|
|
@ -57,7 +57,6 @@ describe('Elasticsearch Cluster Settings', () => {
|
||||||
reason: {
|
reason: {
|
||||||
context: `cluster ${source}`,
|
context: `cluster ${source}`,
|
||||||
data: '-1',
|
data: '-1',
|
||||||
isCloudEnabled: false,
|
|
||||||
property: 'xpack.monitoring.collection.interval',
|
property: 'xpack.monitoring.collection.interval',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -87,7 +86,6 @@ describe('Elasticsearch Cluster Settings', () => {
|
||||||
reason: {
|
reason: {
|
||||||
context: `cluster ${source}`,
|
context: `cluster ${source}`,
|
||||||
data: 'Remote exporters indicate a possible misconfiguration: myCoolExporter',
|
data: 'Remote exporters indicate a possible misconfiguration: myCoolExporter',
|
||||||
isCloudEnabled: false,
|
|
||||||
property: 'xpack.monitoring.exporters',
|
property: 'xpack.monitoring.exporters',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -117,7 +115,6 @@ describe('Elasticsearch Cluster Settings', () => {
|
||||||
reason: {
|
reason: {
|
||||||
context: `cluster ${source}`,
|
context: `cluster ${source}`,
|
||||||
data: 'false',
|
data: 'false',
|
||||||
isCloudEnabled: false,
|
|
||||||
property: 'xpack.monitoring.enabled',
|
property: 'xpack.monitoring.enabled',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,15 +7,19 @@
|
||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
import { findReason } from './find_reason';
|
import { findReason } from './find_reason';
|
||||||
|
|
||||||
export function handleResponse({ nodes = {} } = {}) {
|
export function handleResponse({ nodes = {} } = {}, isCloudEnabled) {
|
||||||
const nodeIds = Object.keys(nodes);
|
const nodeIds = Object.keys(nodes);
|
||||||
for (const nodeId of nodeIds) {
|
for (const nodeId of nodeIds) {
|
||||||
const nodeSettings = get(nodes, [nodeId, 'settings']);
|
const nodeSettings = get(nodes, [nodeId, 'settings']);
|
||||||
if (nodeSettings !== undefined) {
|
if (nodeSettings !== undefined) {
|
||||||
const monitoringSettings = get(nodeSettings, 'xpack.monitoring');
|
const monitoringSettings = get(nodeSettings, 'xpack.monitoring');
|
||||||
const check = findReason(monitoringSettings, {
|
const check = findReason(
|
||||||
context: `nodeId: ${nodeId}`,
|
monitoringSettings,
|
||||||
});
|
{
|
||||||
|
context: `nodeId: ${nodeId}`,
|
||||||
|
},
|
||||||
|
isCloudEnabled
|
||||||
|
);
|
||||||
|
|
||||||
if (check.found) {
|
if (check.found) {
|
||||||
return check;
|
return check;
|
||||||
|
@ -28,11 +32,13 @@ export function handleResponse({ nodes = {} } = {}) {
|
||||||
|
|
||||||
export async function checkNodesSettings(req) {
|
export async function checkNodesSettings(req) {
|
||||||
const { callWithRequest } = req.server.plugins.elasticsearch.getCluster('admin');
|
const { callWithRequest } = req.server.plugins.elasticsearch.getCluster('admin');
|
||||||
|
const { cloud } = req.server.newPlatform.setup.plugins;
|
||||||
|
const isCloudEnabled = !!(cloud && cloud.isCloudEnabled);
|
||||||
const response = await callWithRequest(req, 'transport.request', {
|
const response = await callWithRequest(req, 'transport.request', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
path: '/_nodes/settings',
|
path: '/_nodes/settings',
|
||||||
filter_path: ['nodes'], // NOTE: this doesn't seem to do anything when used with elasticsearch-js. In Console, it does work though
|
filter_path: ['nodes'], // NOTE: this doesn't seem to do anything when used with elasticsearch-js. In Console, it does work though
|
||||||
});
|
});
|
||||||
|
|
||||||
return handleResponse(response);
|
return handleResponse(response, isCloudEnabled);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,15 @@ describe('Elasticsearch Nodes Settings', () => {
|
||||||
const getReq = (response) => {
|
const getReq = (response) => {
|
||||||
return {
|
return {
|
||||||
server: {
|
server: {
|
||||||
|
newPlatform: {
|
||||||
|
setup: {
|
||||||
|
plugins: {
|
||||||
|
cloud: {
|
||||||
|
isCloudEnabled: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
plugins: {
|
plugins: {
|
||||||
elasticsearch: {
|
elasticsearch: {
|
||||||
getCluster() {
|
getCluster() {
|
||||||
|
|
Loading…
Reference in a new issue