[Infra UI] Refactor 'capabilites' to 'metadata'. (#25580)
* Refactor 'capabilites' to 'metadata'. * Better language in inline documentation.
This commit is contained in:
parent
43b1d00128
commit
40960f98ab
|
@ -111,8 +111,8 @@
|
|||
"deprecationReason": null
|
||||
},
|
||||
{
|
||||
"name": "capabilitiesByNode",
|
||||
"description": "A hierarchy of capabilities available on nodes",
|
||||
"name": "metadataByNode",
|
||||
"description": "A hierarchy of metadata entries by node",
|
||||
"args": [
|
||||
{
|
||||
"name": "nodeName",
|
||||
|
@ -141,7 +141,7 @@
|
|||
"ofType": {
|
||||
"kind": "LIST",
|
||||
"name": null,
|
||||
"ofType": { "kind": "OBJECT", "name": "InfraNodeCapability", "ofType": null }
|
||||
"ofType": { "kind": "OBJECT", "name": "InfraNodeMetadata", "ofType": null }
|
||||
}
|
||||
},
|
||||
"isDeprecated": false,
|
||||
|
@ -781,9 +781,8 @@
|
|||
},
|
||||
{
|
||||
"kind": "OBJECT",
|
||||
"name": "InfraNodeCapability",
|
||||
"description":
|
||||
"One specific capability available on a node. A capability corresponds to a fileset or metricset",
|
||||
"name": "InfraNodeMetadata",
|
||||
"description": "One metadata entry for a node.",
|
||||
"fields": [
|
||||
{
|
||||
"name": "name",
|
||||
|
|
|
@ -17,7 +17,7 @@ export interface InfraSource {
|
|||
id: string /** The id of the source */;
|
||||
configuration: InfraSourceConfiguration /** The raw configuration of the source */;
|
||||
status: InfraSourceStatus /** The status of the source */;
|
||||
capabilitiesByNode: (InfraNodeCapability | null)[] /** A hierarchy of capabilities available on nodes */;
|
||||
metadataByNode: (InfraNodeMetadata | null)[] /** A hierarchy of metadata entries by node */;
|
||||
logEntriesAround: InfraLogEntryInterval /** A consecutive span of log entries surrounding a point in time */;
|
||||
logEntriesBetween: InfraLogEntryInterval /** A consecutive span of log entries within an interval */;
|
||||
logSummaryBetween: InfraLogSummaryInterval /** A consecutive span of summary buckets within an interval */;
|
||||
|
@ -56,8 +56,8 @@ export interface InfraIndexField {
|
|||
searchable: boolean /** Whether the field's values can be efficiently searched for */;
|
||||
aggregatable: boolean /** Whether the field's values can be aggregated */;
|
||||
}
|
||||
/** One specific capability available on a node. A capability corresponds to a fileset or metricset */
|
||||
export interface InfraNodeCapability {
|
||||
/** One metadata entry for a node. */
|
||||
export interface InfraNodeMetadata {
|
||||
name: string;
|
||||
source: string;
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ export namespace InfraSourceResolvers {
|
|||
id?: IdResolver /** The id of the source */;
|
||||
configuration?: ConfigurationResolver /** The raw configuration of the source */;
|
||||
status?: StatusResolver /** The status of the source */;
|
||||
capabilitiesByNode?: CapabilitiesByNodeResolver /** A hierarchy of capabilities available on nodes */;
|
||||
metadataByNode?: MetadataByNodeResolver /** A hierarchy of metadata entries by node */;
|
||||
logEntriesAround?: LogEntriesAroundResolver /** A consecutive span of log entries surrounding a point in time */;
|
||||
logEntriesBetween?: LogEntriesBetweenResolver /** A consecutive span of log entries within an interval */;
|
||||
logSummaryBetween?: LogSummaryBetweenResolver /** A consecutive span of summary buckets within an interval */;
|
||||
|
@ -174,11 +174,8 @@ export namespace InfraSourceResolvers {
|
|||
export type IdResolver = Resolver<string>;
|
||||
export type ConfigurationResolver = Resolver<InfraSourceConfiguration>;
|
||||
export type StatusResolver = Resolver<InfraSourceStatus>;
|
||||
export type CapabilitiesByNodeResolver = Resolver<
|
||||
(InfraNodeCapability | null)[],
|
||||
CapabilitiesByNodeArgs
|
||||
>;
|
||||
export interface CapabilitiesByNodeArgs {
|
||||
export type MetadataByNodeResolver = Resolver<(InfraNodeMetadata | null)[], MetadataByNodeArgs>;
|
||||
export interface MetadataByNodeArgs {
|
||||
nodeName: string;
|
||||
nodeType: InfraNodeType;
|
||||
}
|
||||
|
@ -289,8 +286,8 @@ export namespace InfraIndexFieldResolvers {
|
|||
export type SearchableResolver = Resolver<boolean>;
|
||||
export type AggregatableResolver = Resolver<boolean>;
|
||||
}
|
||||
/** One specific capability available on a node. A capability corresponds to a fileset or metricset */
|
||||
export namespace InfraNodeCapabilityResolvers {
|
||||
/** One metadata entry for a node. */
|
||||
export namespace InfraNodeMetadataResolvers {
|
||||
export interface Resolvers {
|
||||
name?: NameResolver;
|
||||
source?: SourceResolver;
|
||||
|
@ -493,7 +490,7 @@ export interface InfraMetricInput {
|
|||
export interface SourceQueryArgs {
|
||||
id: string /** The id of the source */;
|
||||
}
|
||||
export interface CapabilitiesByNodeInfraSourceArgs {
|
||||
export interface MetadataByNodeInfraSourceArgs {
|
||||
nodeName: string;
|
||||
nodeType: InfraNodeType;
|
||||
}
|
||||
|
@ -604,7 +601,7 @@ export enum InfraOperator {
|
|||
/** A segment of the log entry message */
|
||||
export type InfraLogMessageSegment = InfraLogMessageFieldSegment | InfraLogMessageConstantSegment;
|
||||
|
||||
export namespace CapabilitiesQuery {
|
||||
export namespace MetadataQuery {
|
||||
export type Variables = {
|
||||
sourceId: string;
|
||||
nodeId: string;
|
||||
|
@ -619,11 +616,11 @@ export namespace CapabilitiesQuery {
|
|||
export type Source = {
|
||||
__typename?: 'InfraSource';
|
||||
id: string;
|
||||
capabilitiesByNode: (CapabilitiesByNode | null)[];
|
||||
metadataByNode: (MetadataByNode | null)[];
|
||||
};
|
||||
|
||||
export type CapabilitiesByNode = {
|
||||
__typename?: 'InfraNodeCapability';
|
||||
export type MetadataByNode = {
|
||||
__typename?: 'InfraNodeMetadata';
|
||||
name: string;
|
||||
source: string;
|
||||
};
|
||||
|
@ -815,6 +812,7 @@ export namespace SourceQuery {
|
|||
|
||||
export type Source = {
|
||||
__typename?: 'InfraSource';
|
||||
id: string;
|
||||
configuration: Configuration;
|
||||
status: Status;
|
||||
};
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const capabilitiesQuery = gql`
|
||||
query CapabilitiesQuery($sourceId: ID!, $nodeId: String!, $nodeType: InfraNodeType!) {
|
||||
export const metadataQuery = gql`
|
||||
query MetadataQuery($sourceId: ID!, $nodeId: String!, $nodeType: InfraNodeType!) {
|
||||
source(id: $sourceId) {
|
||||
id
|
||||
capabilitiesByNode(nodeName: $nodeId, nodeType: $nodeType) {
|
||||
metadataByNode(nodeName: $nodeId, nodeType: $nodeType) {
|
||||
name
|
||||
source
|
||||
}
|
|
@ -8,34 +8,34 @@ import _ from 'lodash';
|
|||
|
||||
import React from 'react';
|
||||
import { Query } from 'react-apollo';
|
||||
import { CapabilitiesQuery, InfraNodeType } from '../../../common/graphql/types';
|
||||
import { InfraNodeType, MetadataQuery } from '../../../common/graphql/types';
|
||||
import { InfraMetricLayout } from '../../pages/metrics/layouts/types';
|
||||
import { capabilitiesQuery } from './capabilities.gql_query';
|
||||
import { metadataQuery } from './metadata.gql_query';
|
||||
|
||||
interface WithCapabilitiesProps {
|
||||
children: (args: WithCapabilitiesArgs) => React.ReactNode;
|
||||
interface WithMetadataProps {
|
||||
children: (args: WithMetadataArgs) => React.ReactNode;
|
||||
layouts: InfraMetricLayout[];
|
||||
nodeType: InfraNodeType;
|
||||
nodeId: string;
|
||||
sourceId: string;
|
||||
}
|
||||
|
||||
interface WithCapabilitiesArgs {
|
||||
interface WithMetadataArgs {
|
||||
filteredLayouts: InfraMetricLayout[];
|
||||
error?: string | undefined;
|
||||
loading: boolean;
|
||||
}
|
||||
|
||||
export const WithCapabilities = ({
|
||||
export const WithMetadata = ({
|
||||
children,
|
||||
layouts,
|
||||
nodeType,
|
||||
nodeId,
|
||||
sourceId,
|
||||
}: WithCapabilitiesProps) => {
|
||||
}: WithMetadataProps) => {
|
||||
return (
|
||||
<Query<CapabilitiesQuery.Query, CapabilitiesQuery.Variables>
|
||||
query={capabilitiesQuery}
|
||||
<Query<MetadataQuery.Query, MetadataQuery.Variables>
|
||||
query={metadataQuery}
|
||||
fetchPolicy="no-cache"
|
||||
variables={{
|
||||
sourceId,
|
||||
|
@ -44,8 +44,8 @@ export const WithCapabilities = ({
|
|||
}}
|
||||
>
|
||||
{({ data, error, loading }) => {
|
||||
const capabilities = data && data.source && data.source.capabilitiesByNode;
|
||||
const filteredLayouts = getFilteredLayouts(layouts, capabilities);
|
||||
const metadata = data && data.source && data.source.metadataByNode;
|
||||
const filteredLayouts = getFilteredLayouts(layouts, metadata);
|
||||
return children({
|
||||
filteredLayouts,
|
||||
error: error && error.message,
|
||||
|
@ -58,31 +58,31 @@ export const WithCapabilities = ({
|
|||
|
||||
const getFilteredLayouts = (
|
||||
layouts: InfraMetricLayout[],
|
||||
capabilities: Array<CapabilitiesQuery.CapabilitiesByNode | null> | undefined
|
||||
metadata: Array<MetadataQuery.MetadataByNode | null> | undefined
|
||||
): InfraMetricLayout[] => {
|
||||
if (!capabilities) {
|
||||
if (!metadata) {
|
||||
return layouts;
|
||||
}
|
||||
|
||||
const metricCapabilities: Array<string | null> = capabilities
|
||||
.filter(cap => cap && cap.source === 'metrics')
|
||||
.map(cap => cap && cap.name);
|
||||
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, metricCapabilities))
|
||||
.map(layout => getFilteredLayout(layout, metricMetadata))
|
||||
.filter(layout => layout.sections.length > 0);
|
||||
return filteredLayouts;
|
||||
};
|
||||
|
||||
const getFilteredLayout = (
|
||||
layout: InfraMetricLayout,
|
||||
metricCapabilities: Array<string | null>
|
||||
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, metricCapabilities).length > 0
|
||||
section => _.intersection(section.requires, metricMetadata).length > 0
|
||||
);
|
||||
return { ...layout, sections: filteredSections };
|
||||
};
|
|
@ -25,7 +25,7 @@ import { Header } from '../../components/header';
|
|||
import { Metrics } from '../../components/metrics';
|
||||
import { MetricsTimeControls } from '../../components/metrics/time_controls';
|
||||
import { ColumnarPage, PageContent } from '../../components/page';
|
||||
import { WithCapabilities } from '../../containers/capabilities/with_capabilites';
|
||||
import { WithMetadata } from '../../containers/metadata/with_metadata';
|
||||
import { WithMetrics } from '../../containers/metrics/with_metrics';
|
||||
import {
|
||||
WithMetricsTime,
|
||||
|
@ -88,7 +88,7 @@ class MetricDetailPage extends React.PureComponent<Props> {
|
|||
startMetricsAutoReload,
|
||||
stopMetricsAutoReload,
|
||||
}) => (
|
||||
<WithCapabilities
|
||||
<WithMetadata
|
||||
layouts={layouts}
|
||||
sourceId={sourceId}
|
||||
nodeType={nodeType}
|
||||
|
@ -183,7 +183,7 @@ class MetricDetailPage extends React.PureComponent<Props> {
|
|||
</WithMetrics>
|
||||
);
|
||||
}}
|
||||
</WithCapabilities>
|
||||
</WithMetadata>
|
||||
)}
|
||||
</WithMetricsTime>
|
||||
)}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
import { rootSchema } from '../../common/graphql/root/schema.gql';
|
||||
import { sharedSchema } from '../../common/graphql/shared/schema.gql';
|
||||
import { capabilitiesSchema } from './capabilities/schema.gql';
|
||||
import { logEntriesSchema } from './log_entries/schema.gql';
|
||||
import { metadataSchema } from './metadata/schema.gql';
|
||||
import { metricsSchema } from './metrics/schema.gql';
|
||||
import { nodesSchema } from './nodes/schema.gql';
|
||||
import { sourceStatusSchema } from './source_status/schema.gql';
|
||||
|
@ -16,7 +16,7 @@ import { sourcesSchema } from './sources/schema.gql';
|
|||
export const schemas = [
|
||||
rootSchema,
|
||||
sharedSchema,
|
||||
capabilitiesSchema,
|
||||
metadataSchema,
|
||||
logEntriesSchema,
|
||||
nodesSchema,
|
||||
sourcesSchema,
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export { createCapabilitiesResolvers } from './resolvers';
|
||||
export { capabilitiesSchema } from './schema.gql';
|
||||
export { createMetadataResolvers } from './resolvers';
|
||||
export { metadataSchema } from './schema.gql';
|
|
@ -6,31 +6,26 @@
|
|||
|
||||
import { InfraSourceResolvers } from '../../../common/graphql/types';
|
||||
import { InfraResolvedResult, InfraResolverOf } from '../../lib/adapters/framework';
|
||||
import { InfraCapabilitiesDomain } from '../../lib/domains/capabilities_domain';
|
||||
import { InfraMetadataDomain } from '../../lib/domains/metadata_domain';
|
||||
import { InfraContext } from '../../lib/infra_types';
|
||||
import { QuerySourceResolver } from '../sources/resolvers';
|
||||
|
||||
type InfraSourceCapabilitiesByNodeResolver = InfraResolverOf<
|
||||
InfraSourceResolvers.CapabilitiesByNodeResolver,
|
||||
type InfraSourceMetadataByNodeResolver = InfraResolverOf<
|
||||
InfraSourceResolvers.MetadataByNodeResolver,
|
||||
InfraResolvedResult<QuerySourceResolver>,
|
||||
InfraContext
|
||||
>;
|
||||
|
||||
export const createCapabilitiesResolvers = (libs: {
|
||||
capabilities: InfraCapabilitiesDomain;
|
||||
export const createMetadataResolvers = (libs: {
|
||||
metadata: InfraMetadataDomain;
|
||||
}): {
|
||||
InfraSource: {
|
||||
capabilitiesByNode: InfraSourceCapabilitiesByNodeResolver;
|
||||
metadataByNode: InfraSourceMetadataByNodeResolver;
|
||||
};
|
||||
} => ({
|
||||
InfraSource: {
|
||||
async capabilitiesByNode(source, args, { req }) {
|
||||
const result = await libs.capabilities.getCapabilities(
|
||||
req,
|
||||
source.id,
|
||||
args.nodeName,
|
||||
args.nodeType
|
||||
);
|
||||
async metadataByNode(source, args, { req }) {
|
||||
const result = await libs.metadata.getMetadata(req, source.id, args.nodeName, args.nodeType);
|
||||
return result;
|
||||
},
|
||||
},
|
|
@ -6,15 +6,15 @@
|
|||
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const capabilitiesSchema = gql`
|
||||
"One specific capability available on a node. A capability corresponds to a fileset or metricset"
|
||||
type InfraNodeCapability {
|
||||
export const metadataSchema = gql`
|
||||
"One metadata entry for a node."
|
||||
type InfraNodeMetadata {
|
||||
name: String!
|
||||
source: String!
|
||||
}
|
||||
|
||||
extend type InfraSource {
|
||||
"A hierarchy of capabilities available on nodes"
|
||||
capabilitiesByNode(nodeName: String!, nodeType: InfraNodeType!): [InfraNodeCapability]!
|
||||
"A hierarchy of metadata entries by node"
|
||||
metadataByNode(nodeName: String!, nodeType: InfraNodeType!): [InfraNodeMetadata]!
|
||||
}
|
||||
`;
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
import { IResolvers, makeExecutableSchema } from 'graphql-tools';
|
||||
import { schemas } from './graphql';
|
||||
import { createCapabilitiesResolvers } from './graphql/capabilities';
|
||||
import { createLogEntriesResolvers } from './graphql/log_entries';
|
||||
import { createMetadataResolvers } from './graphql/metadata';
|
||||
import { createMetricResolvers } from './graphql/metrics/resolvers';
|
||||
import { createNodeResolvers } from './graphql/nodes';
|
||||
import { createSourceStatusResolvers } from './graphql/source_status';
|
||||
|
@ -18,7 +18,7 @@ import { initLegacyLoggingRoutes } from './logging_legacy';
|
|||
export const initInfraServer = (libs: InfraBackendLibs) => {
|
||||
const schema = makeExecutableSchema({
|
||||
resolvers: [
|
||||
createCapabilitiesResolvers(libs) as IResolvers,
|
||||
createMetadataResolvers(libs) as IResolvers,
|
||||
createLogEntriesResolvers(libs) as IResolvers,
|
||||
createNodeResolvers(libs) as IResolvers,
|
||||
createSourcesResolvers(libs) as IResolvers,
|
||||
|
|
|
@ -148,15 +148,15 @@ export interface InfraDateRangeAggregationResponse {
|
|||
buckets: InfraDateRangeAggregationBucket[];
|
||||
}
|
||||
|
||||
export interface InfraCapabilityAggregationBucket {
|
||||
export interface InfraMetadataAggregationBucket {
|
||||
key: string;
|
||||
names?: {
|
||||
buckets: InfraCapabilityAggregationBucket[];
|
||||
buckets: InfraMetadataAggregationBucket[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface InfraCapabilityAggregationResponse {
|
||||
buckets: InfraCapabilityAggregationBucket[];
|
||||
export interface InfraMetadataAggregationResponse {
|
||||
buckets: InfraMetadataAggregationBucket[];
|
||||
}
|
||||
|
||||
export interface InfraFieldsResponse {
|
||||
|
|
|
@ -5,19 +5,19 @@
|
|||
*/
|
||||
|
||||
import { InfraSourceConfiguration } from '../../sources';
|
||||
import { InfraCapabilityAggregationBucket, InfraFrameworkRequest } from '../framework';
|
||||
import { InfraFrameworkRequest, InfraMetadataAggregationBucket } from '../framework';
|
||||
|
||||
export interface InfraCapabilitiesAdapter {
|
||||
getMetricCapabilities(
|
||||
export interface InfraMetadataAdapter {
|
||||
getMetricMetadata(
|
||||
req: InfraFrameworkRequest,
|
||||
sourceConfiguration: InfraSourceConfiguration,
|
||||
nodeName: string,
|
||||
nodeType: string
|
||||
): Promise<InfraCapabilityAggregationBucket[]>;
|
||||
getLogCapabilities(
|
||||
): Promise<InfraMetadataAggregationBucket[]>;
|
||||
getLogMetadata(
|
||||
req: InfraFrameworkRequest,
|
||||
sourceConfiguration: InfraSourceConfiguration,
|
||||
nodeName: string,
|
||||
nodeType: string
|
||||
): Promise<InfraCapabilityAggregationBucket[]>;
|
||||
): Promise<InfraMetadataAggregationBucket[]>;
|
||||
}
|
|
@ -7,24 +7,24 @@
|
|||
import { InfraSourceConfiguration } from '../../sources';
|
||||
import {
|
||||
InfraBackendFrameworkAdapter,
|
||||
InfraCapabilityAggregationBucket,
|
||||
InfraCapabilityAggregationResponse,
|
||||
InfraFrameworkRequest,
|
||||
InfraMetadataAggregationBucket,
|
||||
InfraMetadataAggregationResponse,
|
||||
} from '../framework';
|
||||
import { InfraCapabilitiesAdapter } from './adapter_types';
|
||||
import { InfraMetadataAdapter } from './adapter_types';
|
||||
|
||||
export class ElasticsearchCapabilitiesAdapter implements InfraCapabilitiesAdapter {
|
||||
export class ElasticsearchMetadataAdapter implements InfraMetadataAdapter {
|
||||
private framework: InfraBackendFrameworkAdapter;
|
||||
constructor(framework: InfraBackendFrameworkAdapter) {
|
||||
this.framework = framework;
|
||||
}
|
||||
|
||||
public async getMetricCapabilities(
|
||||
public async getMetricMetadata(
|
||||
req: InfraFrameworkRequest,
|
||||
sourceConfiguration: InfraSourceConfiguration,
|
||||
nodeName: string,
|
||||
nodeType: 'host' | 'container' | 'pod'
|
||||
): Promise<InfraCapabilityAggregationBucket[]> {
|
||||
): Promise<InfraMetadataAggregationBucket[]> {
|
||||
const idFieldName = getIdFieldName(sourceConfiguration, nodeType);
|
||||
const metricQuery = {
|
||||
index: sourceConfiguration.metricAlias,
|
||||
|
@ -58,7 +58,7 @@ export class ElasticsearchCapabilitiesAdapter implements InfraCapabilitiesAdapte
|
|||
|
||||
const response = await this.framework.callWithRequest<
|
||||
any,
|
||||
{ metrics?: InfraCapabilityAggregationResponse }
|
||||
{ metrics?: InfraMetadataAggregationResponse }
|
||||
>(req, 'search', metricQuery);
|
||||
|
||||
return response.aggregations && response.aggregations.metrics
|
||||
|
@ -66,12 +66,12 @@ export class ElasticsearchCapabilitiesAdapter implements InfraCapabilitiesAdapte
|
|||
: [];
|
||||
}
|
||||
|
||||
public async getLogCapabilities(
|
||||
public async getLogMetadata(
|
||||
req: InfraFrameworkRequest,
|
||||
sourceConfiguration: InfraSourceConfiguration,
|
||||
nodeName: string,
|
||||
nodeType: 'host' | 'container' | 'pod'
|
||||
): Promise<InfraCapabilityAggregationBucket[]> {
|
||||
): Promise<InfraMetadataAggregationBucket[]> {
|
||||
const idFieldName = getIdFieldName(sourceConfiguration, nodeType);
|
||||
const logQuery = {
|
||||
index: sourceConfiguration.logAlias,
|
||||
|
@ -105,7 +105,7 @@ export class ElasticsearchCapabilitiesAdapter implements InfraCapabilitiesAdapte
|
|||
|
||||
const response = await this.framework.callWithRequest<
|
||||
any,
|
||||
{ metrics?: InfraCapabilityAggregationResponse }
|
||||
{ metrics?: InfraMetadataAggregationResponse }
|
||||
>(req, 'search', logQuery);
|
||||
|
||||
return response.aggregations && response.aggregations.metrics
|
|
@ -6,18 +6,18 @@
|
|||
|
||||
import { Server } from 'hapi';
|
||||
|
||||
import { ElasticsearchCapabilitiesAdapter } from '../adapters/capabilities/elasticsearch_capabilities_adapter';
|
||||
import { InfraKibanaConfigurationAdapter } from '../adapters/configuration/kibana_configuration_adapter';
|
||||
import { FrameworkFieldsAdapter } from '../adapters/fields/framework_fields_adapter';
|
||||
import { InfraKibanaBackendFrameworkAdapter } from '../adapters/framework/kibana_framework_adapter';
|
||||
import { InfraKibanaLogEntriesAdapter } from '../adapters/log_entries/kibana_log_entries_adapter';
|
||||
import { ElasticsearchMetadataAdapter } from '../adapters/metadata/elasticsearch_metadata_adapter';
|
||||
import { KibanaMetricsAdapter } from '../adapters/metrics/kibana_metrics_adapter';
|
||||
import { ElasticsearchNodesAdapter } from '../adapters/nodes/elasticsearch_nodes_adapter';
|
||||
import { InfraElasticsearchSourceStatusAdapter } from '../adapters/source_status';
|
||||
import { InfraConfigurationSourcesAdapter } from '../adapters/sources/configuration_sources_adapter';
|
||||
import { InfraCapabilitiesDomain } from '../domains/capabilities_domain';
|
||||
import { InfraFieldsDomain } from '../domains/fields_domain';
|
||||
import { InfraLogEntriesDomain } from '../domains/log_entries_domain';
|
||||
import { InfraMetadataDomain } from '../domains/metadata_domain';
|
||||
import { InfraMetricsDomain } from '../domains/metrics_domain';
|
||||
import { InfraNodesDomain } from '../domains/nodes_domain';
|
||||
import { InfraBackendLibs, InfraConfiguration, InfraDomainLibs } from '../infra_types';
|
||||
|
@ -33,7 +33,7 @@ export function compose(server: Server): InfraBackendLibs {
|
|||
});
|
||||
|
||||
const domainLibs: InfraDomainLibs = {
|
||||
capabilities: new InfraCapabilitiesDomain(new ElasticsearchCapabilitiesAdapter(framework), {
|
||||
metadata: new InfraMetadataDomain(new ElasticsearchMetadataAdapter(framework), {
|
||||
sources,
|
||||
}),
|
||||
fields: new InfraFieldsDomain(new FrameworkFieldsAdapter(framework), {
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export * from './capabilities_domain';
|
||||
export * from './metadata_domain';
|
|
@ -4,54 +4,49 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { InfraCapabilitiesAdapter } from '../../adapters/capabilities';
|
||||
import { InfraCapabilityAggregationBucket, InfraFrameworkRequest } from '../../adapters/framework';
|
||||
import { InfraFrameworkRequest, InfraMetadataAggregationBucket } from '../../adapters/framework';
|
||||
import { InfraMetadataAdapter } from '../../adapters/metadata';
|
||||
import { InfraSources } from '../../sources';
|
||||
|
||||
export class InfraCapabilitiesDomain {
|
||||
export class InfraMetadataDomain {
|
||||
constructor(
|
||||
private readonly adapter: InfraCapabilitiesAdapter,
|
||||
private readonly adapter: InfraMetadataAdapter,
|
||||
private readonly libs: { sources: InfraSources }
|
||||
) {}
|
||||
|
||||
public async getCapabilities(
|
||||
public async getMetadata(
|
||||
req: InfraFrameworkRequest,
|
||||
sourceId: string,
|
||||
nodeName: string,
|
||||
nodeType: string
|
||||
) {
|
||||
const sourceConfiguration = await this.libs.sources.getConfiguration(sourceId);
|
||||
const metricsPromise = this.adapter.getMetricCapabilities(
|
||||
req,
|
||||
sourceConfiguration,
|
||||
nodeName,
|
||||
nodeType
|
||||
);
|
||||
const logsPromise = this.adapter.getLogCapabilities(
|
||||
const metricsPromise = this.adapter.getMetricMetadata(
|
||||
req,
|
||||
sourceConfiguration,
|
||||
nodeName,
|
||||
nodeType
|
||||
);
|
||||
const logsPromise = this.adapter.getLogMetadata(req, sourceConfiguration, nodeName, nodeType);
|
||||
|
||||
const metrics = await metricsPromise;
|
||||
const logs = await logsPromise;
|
||||
|
||||
const metricCapabilities = pickCapabilities(metrics).map(metricCapability => {
|
||||
return { name: metricCapability, source: 'metrics' };
|
||||
const metricMetadata = pickMetadata(metrics).map(entry => {
|
||||
return { name: entry, source: 'metrics' };
|
||||
});
|
||||
|
||||
const logCapabilities = pickCapabilities(logs).map(logCapability => {
|
||||
return { name: logCapability, source: 'logs' };
|
||||
const logMetadata = pickMetadata(logs).map(entry => {
|
||||
return { name: entry, source: 'logs' };
|
||||
});
|
||||
|
||||
return metricCapabilities.concat(logCapabilities);
|
||||
return metricMetadata.concat(logMetadata);
|
||||
}
|
||||
}
|
||||
|
||||
const pickCapabilities = (buckets: InfraCapabilityAggregationBucket[]): string[] => {
|
||||
const pickMetadata = (buckets: InfraMetadataAggregationBucket[]): string[] => {
|
||||
if (buckets) {
|
||||
const capabilities = buckets
|
||||
const metadata = buckets
|
||||
.map(module => {
|
||||
if (module.names) {
|
||||
return module.names.buckets.map(name => {
|
||||
|
@ -62,7 +57,7 @@ const pickCapabilities = (buckets: InfraCapabilityAggregationBucket[]): string[]
|
|||
}
|
||||
})
|
||||
.reduce((a: string[], b: string[]) => a.concat(b), []);
|
||||
return capabilities;
|
||||
return metadata;
|
||||
} else {
|
||||
return [];
|
||||
}
|
|
@ -6,16 +6,16 @@
|
|||
|
||||
import { InfraConfigurationAdapter } from './adapters/configuration';
|
||||
import { InfraBackendFrameworkAdapter, InfraFrameworkRequest } from './adapters/framework';
|
||||
import { InfraCapabilitiesDomain } from './domains/capabilities_domain';
|
||||
import { InfraFieldsDomain } from './domains/fields_domain';
|
||||
import { InfraLogEntriesDomain } from './domains/log_entries_domain';
|
||||
import { InfraMetadataDomain } from './domains/metadata_domain';
|
||||
import { InfraMetricsDomain } from './domains/metrics_domain';
|
||||
import { InfraNodesDomain } from './domains/nodes_domain';
|
||||
import { InfraSourceStatus } from './source_status';
|
||||
import { InfraSourceConfigurations, InfraSources } from './sources';
|
||||
|
||||
export interface InfraDomainLibs {
|
||||
capabilities: InfraCapabilitiesDomain;
|
||||
metadata: InfraMetadataDomain;
|
||||
fields: InfraFieldsDomain;
|
||||
logEntries: InfraLogEntriesDomain;
|
||||
nodes: InfraNodesDomain;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
export default function ({ loadTestFile }) {
|
||||
describe('InfraOps GraphQL Endpoints', () => {
|
||||
loadTestFile(require.resolve('./capabilities'));
|
||||
loadTestFile(require.resolve('./metadata'));
|
||||
loadTestFile(require.resolve('./log_entries'));
|
||||
loadTestFile(require.resolve('./log_summary'));
|
||||
loadTestFile(require.resolve('./metrics'));
|
||||
|
|
|
@ -5,22 +5,22 @@
|
|||
*/
|
||||
|
||||
import expect from 'expect.js';
|
||||
import { CapabilitiesQuery } from '../../../../plugins/infra/common/graphql/types';
|
||||
import { capabilitiesQuery } from '../../../../plugins/infra/public/containers/capabilities/capabilities.gql_query';
|
||||
import { MetadataQuery } from '../../../../plugins/infra/common/graphql/types';
|
||||
import { metadataQuery } from '../../../../plugins/infra/public/containers/metadata/metadata.gql_query';
|
||||
import { KbnTestProvider } from './types';
|
||||
|
||||
const capabilitiesTests: KbnTestProvider = ({ getService }) => {
|
||||
const metadataTests: KbnTestProvider = ({ getService }) => {
|
||||
const esArchiver = getService('esArchiver');
|
||||
const client = getService('infraOpsGraphQLClient');
|
||||
|
||||
describe('capabilities', () => {
|
||||
describe('metadata', () => {
|
||||
before(() => esArchiver.load('infra'));
|
||||
after(() => esArchiver.unload('infra'));
|
||||
|
||||
it('supports the capabilities container query', () => {
|
||||
it('supports the metadata container query', () => {
|
||||
return client
|
||||
.query<CapabilitiesQuery.Query>({
|
||||
query: capabilitiesQuery,
|
||||
.query<MetadataQuery.Query>({
|
||||
query: metadataQuery,
|
||||
variables: {
|
||||
sourceId: 'default',
|
||||
nodeId: 'demo-stack-nginx-01',
|
||||
|
@ -28,12 +28,12 @@ const capabilitiesTests: KbnTestProvider = ({ getService }) => {
|
|||
},
|
||||
})
|
||||
.then(resp => {
|
||||
const capabilities = resp.data.source.capabilitiesByNode;
|
||||
expect(capabilities.length).to.be(14);
|
||||
const metadata = resp.data.source.metadataByNode;
|
||||
expect(metadata.length).to.be(14);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// tslint:disable-next-line no-default-export
|
||||
export default capabilitiesTests;
|
||||
export default metadataTests;
|
Loading…
Reference in a new issue