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

[Infra UI] Add cloud metrics and cloud/host info to metadata endpoint #41836

Merged
merged 21 commits into from
Aug 2, 2019
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5aa4519
[Infra UI] Add cloud metrics and cloud/host info to metadata endpoint
simianhacker Jul 23, 2019
b7848ec
Adding cloud metrics
simianhacker Jul 23, 2019
7cb8831
Correcting the pod host/cloud info
simianhacker Jul 24, 2019
afccd9a
Adding tests to metadata for new cloud/host info
simianhacker Jul 24, 2019
338918e
Fixing test to include machine.type
simianhacker Jul 25, 2019
50c9639
Merge branch 'master' of github.com:elastic/kibana into fixes-39280
simianhacker Jul 25, 2019
dc6fcaa
Merge branch 'master' of github.com:elastic/kibana into fixes-39280
simianhacker Jul 25, 2019
87240a4
Adding aws test data
simianhacker Jul 25, 2019
2a3dcda
Merge branch 'master' of github.com:elastic/kibana into fixes-39280
simianhacker Jul 26, 2019
4abae3b
Merge branch 'master' of github.com:elastic/kibana into fixes-39280
simianhacker Jul 29, 2019
44b3659
Refactor metadata container into hook
simianhacker Jul 31, 2019
18943b6
Merge branch 'master' of github.com:elastic/kibana into fixes-39280
simianhacker Jul 31, 2019
69e1acc
Functionally complete
simianhacker Jul 31, 2019
a2c6aff
Merge branch 'fixes-39280' of github.com:simianhacker/kibana into fix…
simianhacker Jul 31, 2019
3eb5a0e
updating tests
simianhacker Jul 31, 2019
9f1212e
Removing Metadata GraphQL endpoint and supporting files
simianhacker Jul 31, 2019
21371a9
Moving types under common/http_api and prefixing with Infra
simianhacker Aug 1, 2019
0662c46
adding filter for aws.ec2 dataset
simianhacker Aug 1, 2019
b46c035
move away from fetch to useHTTPRequest
simianhacker Aug 1, 2019
6cdd1ce
Add decode function to useHTTPRequest; rename data to response;
simianhacker Aug 1, 2019
ebb3b0b
Changing from Typescript types to IO-TS types and adding checks at cl…
simianhacker Aug 1, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 0 additions & 59 deletions x-pack/legacy/plugins/infra/common/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ export interface InfraSource {
configuration: InfraSourceConfiguration;
/** The status of the source */
status: InfraSourceStatus;
/** A hierarchy of metadata entries by node */
metadataByNode: InfraNodeMetadata;
/** A consecutive span of log entries surrounding a point in time */
logEntriesAround: InfraLogEntryInterval;
/** A consecutive span of log entries within an interval */
Expand Down Expand Up @@ -132,20 +130,6 @@ export interface InfraIndexField {
/** Whether the field's values can be aggregated */
aggregatable: boolean;
}
/** One metadata entry for a node. */
export interface InfraNodeMetadata {
id: string;

name: string;

features: InfraNodeFeature[];
}

export interface InfraNodeFeature {
name: string;

source: string;
}
/** A consecutive sequence of log entries */
export interface InfraLogEntryInterval {
/** The key corresponding to the start of the interval covered by the entries */
Expand Down Expand Up @@ -424,11 +408,6 @@ export interface SourceQueryArgs {
/** The id of the source */
id: string;
}
export interface MetadataByNodeInfraSourceArgs {
nodeId: string;

nodeType: InfraNodeType;
}
export interface LogEntriesAroundInfraSourceArgs {
/** The sort key that corresponds to the point in time */
key: InfraTimeKeyInput;
Expand Down Expand Up @@ -722,44 +701,6 @@ export namespace LogSummary {
};
}

export namespace MetadataQuery {
export type Variables = {
sourceId: string;
nodeId: string;
nodeType: InfraNodeType;
};

export type Query = {
__typename?: 'Query';

source: Source;
};

export type Source = {
__typename?: 'InfraSource';

id: string;

metadataByNode: MetadataByNode;
};

export type MetadataByNode = {
__typename?: 'InfraNodeMetadata';

name: string;

features: Features[];
};

export type Features = {
__typename?: 'InfraNodeFeature';

name: string;

source: string;
};
}

export namespace MetricsQuery {
export type Variables = {
sourceId: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import { EuiButton, EuiComboBox, EuiForm, EuiFormRow } from '@elastic/eui';
import { InjectedIntl, injectI18n } from '@kbn/i18n/react';
import React from 'react';
import { InfraIndexField } from '../../../server/graphql/types';
import { FieldType } from 'ui/index_patterns';
interface Props {
onSubmit: (field: string) => void;
fields: InfraIndexField[];
fields: FieldType[];
intl: InjectedIntl;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
} from '@elastic/eui';
import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react';
import React from 'react';
import { InfraIndexField, InfraNodeType, InfraSnapshotGroupbyInput } from '../../graphql/types';
import { FieldType } from 'ui/index_patterns';
import { InfraNodeType, InfraSnapshotGroupbyInput } from '../../graphql/types';
import { InfraGroupByOptions } from '../../lib/lib';
import { CustomFieldPanel } from './custom_field_panel';
import { fieldToName } from './lib/field_to_display_name';
Expand All @@ -26,7 +27,7 @@ interface Props {
groupBy: InfraSnapshotGroupbyInput[];
onChange: (groupBy: InfraSnapshotGroupbyInput[]) => void;
onChangeCustomOptions: (options: InfraGroupByOptions[]) => void;
fields: InfraIndexField[];
fields: FieldType[];
intl: InjectedIntl;
customOptions: InfraGroupByOptions[];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { MetadataFeature } from '../../../../server/routes/metadata/types';
import { InfraMetricLayout } from '../../../pages/metrics/layouts/types';

export const getFilteredLayouts = (
layouts: InfraMetricLayout[],
metadata: Array<MetadataFeature | null> | undefined
): InfraMetricLayout[] => {
if (!metadata) {
return layouts;
}

const metricMetadata: Array<string | null> = metadata
.filter(data => data && data.source === 'metrics')
.map(data => data && data.name);

// After filtering out sections that can't be displayed, a layout may end up empty and can be removed.
const filteredLayouts = layouts
.map(layout => getFilteredLayout(layout, metricMetadata))
.filter(layout => layout.sections.length > 0);
return filteredLayouts;
};

export const getFilteredLayout = (
layout: InfraMetricLayout,
metricMetadata: Array<string | null>
): InfraMetricLayout => {
// A section is only displayed if at least one of its requirements is met
// All others are filtered out.
const filteredSections = layout.sections.filter(
section => _.intersection(section.requires, metricMetadata).length > 0
);
return { ...layout, sections: filteredSections };
};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { useState, useEffect } from 'react';
import { InfraNodeType } from '../../graphql/types';
import { InfraMetricLayout } from '../../pages/metrics/layouts/types';
import { Metadata } from '../../../server/routes/metadata/types';
simianhacker marked this conversation as resolved.
Show resolved Hide resolved
import { fetch } from '../../utils/fetch';
simianhacker marked this conversation as resolved.
Show resolved Hide resolved
import { getFilteredLayouts } from './lib/get_filtered_layouts';

export function useMetadata(
nodeId: string,
nodeType: InfraNodeType,
layouts: InfraMetricLayout[],
sourceId: string
) {
const [error, setError] = useState<Error | null>(null);
const [loading, setLoading] = useState<boolean>(true);
const [data, setData] = useState<Metadata | null>(null);

useEffect(() => {
(async () => {
setLoading(true);
try {
const response = await fetch.post<Metadata>('../api/infra/metadata', {
simianhacker marked this conversation as resolved.
Show resolved Hide resolved
nodeId,
nodeType,
sourceId,
});
setData(response.data);
} catch (e) {
setError(e);
}
setLoading(false);
})();
}, [nodeId, nodeType, sourceId]);
return {
name: (data && data.name) || '',
filteredLayouts: (data && getFilteredLayouts(layouts, data.features)) || [],
error: (error && error.message) || null,
loading,
};
}

This file was deleted.

Loading