diff --git a/src/plugins/discover/public/application/angular/doc_table/doc_table.ts b/src/plugins/discover/public/application/angular/doc_table/doc_table.ts
index 29ea9d5db9a3..6c2a3cbfc951 100644
--- a/src/plugins/discover/public/application/angular/doc_table/doc_table.ts
+++ b/src/plugins/discover/public/application/angular/doc_table/doc_table.ts
@@ -59,6 +59,10 @@ export function createDocTableDirective(pagerFactory: any, $filter: any) {
$scope.limit += 50;
};
+ $scope.$watch('minimumVisibleRows', (minimumVisibleRows: number) => {
+ $scope.limit = Math.max(minimumVisibleRows || 50, $scope.limit || 50);
+ });
+
$scope.$watch('hits', (hits: any) => {
if (!hits) return;
diff --git a/test/common/services/es_archiver.ts b/test/common/services/es_archiver.ts
index e1b85ddf8bc9..e6d4a8a56af2 100644
--- a/test/common/services/es_archiver.ts
+++ b/test/common/services/es_archiver.ts
@@ -14,7 +14,7 @@ import * as KibanaServer from './kibana_server';
export function EsArchiverProvider({ getService }: FtrProviderContext): EsArchiver {
const config = getService('config');
- const client = getService('legacyEs');
+ const client = getService('es');
const log = getService('log');
const kibanaServer = getService('kibanaServer');
const retry = getService('retry');
diff --git a/test/functional/apps/discover/_doc_table.ts b/test/functional/apps/discover/_doc_table.ts
index f8f45d2bc710..d4818d99565e 100644
--- a/test/functional/apps/discover/_doc_table.ts
+++ b/test/functional/apps/discover/_doc_table.ts
@@ -15,6 +15,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const docTable = getService('docTable');
+ const queryBar = getService('queryBar');
const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker']);
const defaultSettings = {
defaultIndex: 'logstash-*',
@@ -107,6 +108,24 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
// TODO: test something more meaninful here?
});
});
+
+ it('should not close the detail panel actions when data is re-requested', async function () {
+ await retry.try(async function () {
+ const nrOfFetches = await PageObjects.discover.getNrOfFetches();
+ await docTable.clickRowToggle({ isAnchorRow: false, rowIndex: rowToInspect - 1 });
+ const detailsEl = await docTable.getDetailsRows();
+ const defaultMessageEl = await detailsEl[0].findByTestSubject('docTableRowDetailsTitle');
+ expect(defaultMessageEl).to.be.ok();
+ await queryBar.submitQuery();
+ const nrOfFetchesResubmit = await PageObjects.discover.getNrOfFetches();
+ expect(nrOfFetchesResubmit).to.be.above(nrOfFetches);
+ const defaultMessageElResubmit = await detailsEl[0].findByTestSubject(
+ 'docTableRowDetailsTitle'
+ );
+
+ expect(defaultMessageElResubmit).to.be.ok();
+ });
+ });
});
describe('add and remove columns', function () {
diff --git a/vars/githubPr.groovy b/vars/githubPr.groovy
index 5224aa7463d7..eead00c082ba 100644
--- a/vars/githubPr.groovy
+++ b/vars/githubPr.groovy
@@ -300,7 +300,12 @@ def getDocsChangesLink() {
try {
// httpRequest throws on status codes >400 and failures
- httpRequest([ method: "GET", url: url ])
+ def resp = httpRequest([ method: "GET", url: url ])
+
+ if (resp.contains("There aren't any differences!")) {
+ return ""
+ }
+
return "* [Documentation Changes](${url})"
} catch (ex) {
print "Failed to reach ${url}"
diff --git a/vars/kibanaPipeline.groovy b/vars/kibanaPipeline.groovy
index 3032d88c26d9..17349f6b566d 100644
--- a/vars/kibanaPipeline.groovy
+++ b/vars/kibanaPipeline.groovy
@@ -128,9 +128,11 @@ def functionalTestProcess(String name, String script) {
}
}
-def ossCiGroupProcess(ciGroup) {
+def ossCiGroupProcess(ciGroup, withDelay = false) {
return functionalTestProcess("ciGroup" + ciGroup) {
- sleep((ciGroup-1)*30) // smooth out CPU spikes from ES startup
+ if (withDelay) {
+ sleep((ciGroup-1)*30) // smooth out CPU spikes from ES startup
+ }
withEnv([
"CI_GROUP=${ciGroup}",
@@ -143,9 +145,11 @@ def ossCiGroupProcess(ciGroup) {
}
}
-def xpackCiGroupProcess(ciGroup) {
+def xpackCiGroupProcess(ciGroup, withDelay = false) {
return functionalTestProcess("xpack-ciGroup" + ciGroup) {
- sleep((ciGroup-1)*30) // smooth out CPU spikes from ES startup
+ if (withDelay) {
+ sleep((ciGroup-1)*30) // smooth out CPU spikes from ES startup
+ }
withEnv([
"CI_GROUP=${ciGroup}",
"JOB=xpack-kibana-ciGroup${ciGroup}",
diff --git a/vars/prChanges.groovy b/vars/prChanges.groovy
index 2cc22e73857b..d082672c065a 100644
--- a/vars/prChanges.groovy
+++ b/vars/prChanges.groovy
@@ -11,10 +11,8 @@ def getSkippablePaths() {
/^.ci\/.+\.yml$/,
/^.ci\/es-snapshots\//,
/^.ci\/pipeline-library\//,
- /^.ci\/teamcity\//,
/^.ci\/Jenkinsfile_[^\/]+$/,
/^\.github\//,
- /^\.teamcity\//,
/\.md$/,
]
}
diff --git a/vars/tasks.groovy b/vars/tasks.groovy
index 6c4f89769113..7c40966ff5e0 100644
--- a/vars/tasks.groovy
+++ b/vars/tasks.groovy
@@ -51,7 +51,7 @@ def functionalOss(Map params = [:]) {
if (config.ciGroups) {
def ciGroups = 1..12
- tasks(ciGroups.collect { kibanaPipeline.ossCiGroupProcess(it) })
+ tasks(ciGroups.collect { kibanaPipeline.ossCiGroupProcess(it, true) })
}
if (config.firefox) {
@@ -92,7 +92,7 @@ def functionalXpack(Map params = [:]) {
if (config.ciGroups) {
def ciGroups = 1..13
- tasks(ciGroups.collect { kibanaPipeline.xpackCiGroupProcess(it) })
+ tasks(ciGroups.collect { kibanaPipeline.xpackCiGroupProcess(it, true) })
}
if (config.firefox) {
diff --git a/x-pack/plugins/fleet/server/services/agents/crud_so.ts b/x-pack/plugins/fleet/server/services/agents/crud_so.ts
index eb8f389741a6..7111a2413914 100644
--- a/x-pack/plugins/fleet/server/services/agents/crud_so.ts
+++ b/x-pack/plugins/fleet/server/services/agents/crud_so.ts
@@ -12,18 +12,35 @@ import { AgentSOAttributes, Agent, ListWithKuery } from '../../types';
import { escapeSearchQueryPhrase, normalizeKuery, findAllSOs } from '../saved_object';
import { savedObjectToAgent } from './saved_objects';
import { appContextService } from '../../services';
+import { esKuery, KueryNode } from '../../../../../../src/plugins/data/server';
const ACTIVE_AGENT_CONDITION = `${AGENT_SAVED_OBJECT_TYPE}.attributes.active:true`;
const INACTIVE_AGENT_CONDITION = `NOT (${ACTIVE_AGENT_CONDITION})`;
-function _joinFilters(filters: string[], operator = 'AND') {
- return filters.reduce((acc: string | undefined, filter) => {
- if (acc) {
- return `${acc} ${operator} (${filter})`;
- }
-
- return `(${filter})`;
- }, undefined);
+function _joinFilters(filters: Array
) {
+ return filters
+ .filter((filter) => filter !== undefined)
+ .reduce((acc: KueryNode | undefined, kuery: string | KueryNode | undefined):
+ | KueryNode
+ | undefined => {
+ if (kuery === undefined) {
+ return acc;
+ }
+ const kueryNode: KueryNode =
+ typeof kuery === 'string'
+ ? esKuery.fromKueryExpression(normalizeKuery(AGENT_SAVED_OBJECT_TYPE, kuery))
+ : kuery;
+
+ if (!acc) {
+ return kueryNode;
+ }
+
+ return {
+ type: 'function',
+ function: 'and',
+ arguments: [acc, kueryNode],
+ };
+ }, undefined as KueryNode | undefined);
}
export async function listAgents(
@@ -46,19 +63,18 @@ export async function listAgents(
showInactive = false,
showUpgradeable,
} = options;
- const filters = [];
+ const filters: Array = [];
if (kuery && kuery !== '') {
- filters.push(normalizeKuery(AGENT_SAVED_OBJECT_TYPE, kuery));
+ filters.push(kuery);
}
if (showInactive === false) {
filters.push(ACTIVE_AGENT_CONDITION);
}
-
let { saved_objects: agentSOs, total } = await soClient.find({
type: AGENT_SAVED_OBJECT_TYPE,
- filter: _joinFilters(filters),
+ filter: _joinFilters(filters) || '',
sortField,
sortOrder,
page,
@@ -94,7 +110,7 @@ export async function listAllAgents(
const filters = [];
if (kuery && kuery !== '') {
- filters.push(normalizeKuery(AGENT_SAVED_OBJECT_TYPE, kuery));
+ filters.push(kuery);
}
if (showInactive === false) {
diff --git a/x-pack/plugins/fleet/server/services/agents/status.ts b/x-pack/plugins/fleet/server/services/agents/status.ts
index ba8f8fc36385..726d188f723d 100644
--- a/x-pack/plugins/fleet/server/services/agents/status.ts
+++ b/x-pack/plugins/fleet/server/services/agents/status.ts
@@ -11,6 +11,8 @@ import { AGENT_EVENT_SAVED_OBJECT_TYPE, AGENT_SAVED_OBJECT_TYPE } from '../../co
import { AgentStatus } from '../../types';
import { AgentStatusKueryHelper } from '../../../common/services';
+import { esKuery, KueryNode } from '../../../../../../src/plugins/data/server';
+import { normalizeKuery } from '../saved_object';
export async function getAgentStatusById(
soClient: SavedObjectsClientContract,
@@ -26,13 +28,24 @@ export const getAgentStatus = AgentStatusKueryHelper.getAgentStatus;
function joinKuerys(...kuerys: Array) {
return kuerys
.filter((kuery) => kuery !== undefined)
- .reduce((acc, kuery) => {
- if (acc === '') {
- return `(${kuery})`;
+ .reduce((acc: KueryNode | undefined, kuery: string | undefined): KueryNode | undefined => {
+ if (kuery === undefined) {
+ return acc;
}
+ const normalizedKuery: KueryNode = esKuery.fromKueryExpression(
+ normalizeKuery(AGENT_SAVED_OBJECT_TYPE, kuery || '')
+ );
- return `${acc} and (${kuery})`;
- }, '');
+ if (!acc) {
+ return normalizedKuery;
+ }
+
+ return {
+ type: 'function',
+ function: 'and',
+ arguments: [acc, normalizedKuery],
+ };
+ }, undefined as KueryNode | undefined);
}
export async function getAgentStatusForAgentPolicy(
@@ -58,6 +71,7 @@ export async function getAgentStatusForAgentPolicy(
...[
kuery,
filterKuery,
+ `${AGENT_SAVED_OBJECT_TYPE}.attributes.active:true`,
agentPolicyId ? `${AGENT_SAVED_OBJECT_TYPE}.policy_id:"${agentPolicyId}"` : undefined,
]
),
diff --git a/x-pack/plugins/fleet/server/types/rest_spec/common.ts b/x-pack/plugins/fleet/server/types/rest_spec/common.ts
index cdb23da5b6b1..88d60116672d 100644
--- a/x-pack/plugins/fleet/server/types/rest_spec/common.ts
+++ b/x-pack/plugins/fleet/server/types/rest_spec/common.ts
@@ -11,7 +11,12 @@ export const ListWithKuerySchema = schema.object({
sortField: schema.maybe(schema.string()),
sortOrder: schema.maybe(schema.oneOf([schema.literal('desc'), schema.literal('asc')])),
showUpgradeable: schema.maybe(schema.boolean()),
- kuery: schema.maybe(schema.string()),
+ kuery: schema.maybe(
+ schema.oneOf([
+ schema.string(),
+ schema.any(), // KueryNode
+ ])
+ ),
});
export type ListWithKuery = TypeOf;
diff --git a/x-pack/plugins/infra/common/graphql/root/schema.gql.ts b/x-pack/plugins/infra/common/graphql/root/schema.gql.ts
deleted file mode 100644
index 1665334827e8..000000000000
--- a/x-pack/plugins/infra/common/graphql/root/schema.gql.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * 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 gql from 'graphql-tag';
-
-export const rootSchema = gql`
- schema {
- query: Query
- mutation: Mutation
- }
-
- type Query
-
- type Mutation
-`;
diff --git a/x-pack/plugins/infra/common/graphql/shared/fragments.gql_query.ts b/x-pack/plugins/infra/common/graphql/shared/fragments.gql_query.ts
deleted file mode 100644
index c324813b65ef..000000000000
--- a/x-pack/plugins/infra/common/graphql/shared/fragments.gql_query.ts
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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 gql from 'graphql-tag';
-
-export const sharedFragments = {
- InfraTimeKey: gql`
- fragment InfraTimeKeyFields on InfraTimeKey {
- time
- tiebreaker
- }
- `,
- InfraSourceFields: gql`
- fragment InfraSourceFields on InfraSource {
- id
- version
- updatedAt
- origin
- }
- `,
- InfraLogEntryFields: gql`
- fragment InfraLogEntryFields on InfraLogEntry {
- gid
- key {
- time
- tiebreaker
- }
- columns {
- ... on InfraLogEntryTimestampColumn {
- columnId
- timestamp
- }
- ... on InfraLogEntryMessageColumn {
- columnId
- message {
- ... on InfraLogMessageFieldSegment {
- field
- value
- }
- ... on InfraLogMessageConstantSegment {
- constant
- }
- }
- }
- ... on InfraLogEntryFieldColumn {
- columnId
- field
- value
- }
- }
- }
- `,
- InfraLogEntryHighlightFields: gql`
- fragment InfraLogEntryHighlightFields on InfraLogEntry {
- gid
- key {
- time
- tiebreaker
- }
- columns {
- ... on InfraLogEntryMessageColumn {
- columnId
- message {
- ... on InfraLogMessageFieldSegment {
- field
- highlights
- }
- }
- }
- ... on InfraLogEntryFieldColumn {
- columnId
- field
- highlights
- }
- }
- }
- `,
-};
diff --git a/x-pack/plugins/infra/common/graphql/shared/schema.gql.ts b/x-pack/plugins/infra/common/graphql/shared/schema.gql.ts
deleted file mode 100644
index 071313817eff..000000000000
--- a/x-pack/plugins/infra/common/graphql/shared/schema.gql.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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 gql from 'graphql-tag';
-
-export const sharedSchema = gql`
- "A representation of the log entry's position in the event stream"
- type InfraTimeKey {
- "The timestamp of the event that the log entry corresponds to"
- time: Float!
- "The tiebreaker that disambiguates events with the same timestamp"
- tiebreaker: Float!
- }
-
- input InfraTimeKeyInput {
- time: Float!
- tiebreaker: Float!
- }
-
- enum InfraIndexType {
- ANY
- LOGS
- METRICS
- }
-
- enum InfraNodeType {
- pod
- container
- host
- awsEC2
- awsS3
- awsRDS
- awsSQS
- }
-`;
diff --git a/x-pack/plugins/infra/common/graphql/types.ts b/x-pack/plugins/infra/common/graphql/types.ts
deleted file mode 100644
index ee536feb1ce6..000000000000
--- a/x-pack/plugins/infra/common/graphql/types.ts
+++ /dev/null
@@ -1,780 +0,0 @@
-/* tslint:disable */
-
-// ====================================================
-// START: Typescript template
-// ====================================================
-
-// ====================================================
-// Types
-// ====================================================
-
-export interface Query {
- /** Get an infrastructure data source by id.The resolution order for the source configuration attributes is as followswith the first defined value winning:1. The attributes of the saved object with the given 'id'.2. The attributes defined in the static Kibana configuration key'xpack.infra.sources.default'.3. The hard-coded default values.As a consequence, querying a source that doesn't exist doesn't error out,but returns the configured or hardcoded defaults. */
- source: InfraSource;
- /** Get a list of all infrastructure data sources */
- allSources: InfraSource[];
-}
-/** A source of infrastructure data */
-export interface InfraSource {
- /** The id of the source */
- id: string;
- /** The version number the source configuration was last persisted with */
- version?: string | null;
- /** The timestamp the source configuration was last persisted at */
- updatedAt?: number | null;
- /** The origin of the source (one of 'fallback', 'internal', 'stored') */
- origin: string;
- /** The raw configuration of the source */
- configuration: InfraSourceConfiguration;
- /** The status of the source */
- status: InfraSourceStatus;
-
- /** A snapshot of nodes */
- snapshot?: InfraSnapshotResponse | null;
-
- metrics: InfraMetricData[];
-}
-/** A set of configuration options for an infrastructure data source */
-export interface InfraSourceConfiguration {
- /** The name of the data source */
- name: string;
- /** A description of the data source */
- description: string;
- /** The alias to read metric data from */
- metricAlias: string;
- /** The alias to read log data from */
- logAlias: string;
- /** The field mapping to use for this source */
- fields: InfraSourceFields;
- /** The columns to use for log display */
- logColumns: InfraSourceLogColumn[];
-}
-/** A mapping of semantic fields to their document counterparts */
-export interface InfraSourceFields {
- /** The field to identify a container by */
- container: string;
- /** The fields to identify a host by */
- host: string;
- /** The fields to use as the log message */
- message: string[];
- /** The field to identify a pod by */
- pod: string;
- /** The field to use as a tiebreaker for log events that have identical timestamps */
- tiebreaker: string;
- /** The field to use as a timestamp for metrics and logs */
- timestamp: string;
-}
-/** The built-in timestamp log column */
-export interface InfraSourceTimestampLogColumn {
- timestampColumn: InfraSourceTimestampLogColumnAttributes;
-}
-
-export interface InfraSourceTimestampLogColumnAttributes {
- /** A unique id for the column */
- id: string;
-}
-/** The built-in message log column */
-export interface InfraSourceMessageLogColumn {
- messageColumn: InfraSourceMessageLogColumnAttributes;
-}
-
-export interface InfraSourceMessageLogColumnAttributes {
- /** A unique id for the column */
- id: string;
-}
-/** A log column containing a field value */
-export interface InfraSourceFieldLogColumn {
- fieldColumn: InfraSourceFieldLogColumnAttributes;
-}
-
-export interface InfraSourceFieldLogColumnAttributes {
- /** A unique id for the column */
- id: string;
- /** The field name this column refers to */
- field: string;
-}
-/** The status of an infrastructure data source */
-export interface InfraSourceStatus {
- /** Whether the configured metric alias exists */
- metricAliasExists: boolean;
- /** Whether the configured log alias exists */
- logAliasExists: boolean;
- /** Whether the configured alias or wildcard pattern resolve to any metric indices */
- metricIndicesExist: boolean;
- /** Whether the configured alias or wildcard pattern resolve to any log indices */
- logIndicesExist: boolean;
- /** The list of indices in the metric alias */
- metricIndices: string[];
- /** The list of indices in the log alias */
- logIndices: string[];
- /** The list of fields defined in the index mappings */
- indexFields: InfraIndexField[];
-}
-/** A descriptor of a field in an index */
-export interface InfraIndexField {
- /** The name of the field */
- name: string;
- /** The type of the field's values as recognized by Kibana */
- type: string;
- /** Whether the field's values can be efficiently searched for */
- searchable: boolean;
- /** Whether the field's values can be aggregated */
- aggregatable: boolean;
- /** Whether the field should be displayed based on event.module and a ECS allowed list */
- displayable: boolean;
-}
-
-export interface InfraSnapshotResponse {
- /** Nodes of type host, container or pod grouped by 0, 1 or 2 terms */
- nodes: InfraSnapshotNode[];
-}
-
-export interface InfraSnapshotNode {
- path: InfraSnapshotNodePath[];
-
- metric: InfraSnapshotNodeMetric;
-}
-
-export interface InfraSnapshotNodePath {
- value: string;
-
- label: string;
-
- ip?: string | null;
-}
-
-export interface InfraSnapshotNodeMetric {
- name: InfraSnapshotMetricType;
-
- value?: number | null;
-
- avg?: number | null;
-
- max?: number | null;
-}
-
-export interface InfraMetricData {
- id?: InfraMetric | null;
-
- series: InfraDataSeries[];
-}
-
-export interface InfraDataSeries {
- id: string;
-
- label: string;
-
- data: InfraDataPoint[];
-}
-
-export interface InfraDataPoint {
- timestamp: number;
-
- value?: number | null;
-}
-
-export interface Mutation {
- /** Create a new source of infrastructure data */
- createSource: UpdateSourceResult;
- /** Modify an existing source */
- updateSource: UpdateSourceResult;
- /** Delete a source of infrastructure data */
- deleteSource: DeleteSourceResult;
-}
-/** The result of a successful source update */
-export interface UpdateSourceResult {
- /** The source that was updated */
- source: InfraSource;
-}
-/** The result of a source deletion operations */
-export interface DeleteSourceResult {
- /** The id of the source that was deleted */
- id: string;
-}
-
-// ====================================================
-// InputTypes
-// ====================================================
-
-export interface InfraTimerangeInput {
- /** The interval string to use for last bucket. The format is '{value}{unit}'. For example '5m' would return the metrics for the last 5 minutes of the timespan. */
- interval: string;
- /** The end of the timerange */
- to: number;
- /** The beginning of the timerange */
- from: number;
-}
-
-export interface InfraSnapshotGroupbyInput {
- /** The label to use in the results for the group by for the terms group by */
- label?: string | null;
- /** The field to group by from a terms aggregation, this is ignored by the filter type */
- field?: string | null;
-}
-
-export interface InfraSnapshotMetricInput {
- /** The type of metric */
- type: InfraSnapshotMetricType;
-}
-
-export interface InfraNodeIdsInput {
- nodeId: string;
-
- cloudId?: string | null;
-}
-/** The properties to update the source with */
-export interface UpdateSourceInput {
- /** The name of the data source */
- name?: string | null;
- /** A description of the data source */
- description?: string | null;
- /** The alias to read metric data from */
- metricAlias?: string | null;
- /** The alias to read log data from */
- logAlias?: string | null;
- /** The field mapping to use for this source */
- fields?: UpdateSourceFieldsInput | null;
- /** Default view for inventory */
- inventoryDefaultView?: string | null;
- /** Default view for Metrics Explorer */
- metricsExplorerDefaultView?: string | null;
- /** The log columns to display for this source */
- logColumns?: UpdateSourceLogColumnInput[] | null;
-}
-/** The mapping of semantic fields of the source to be created */
-export interface UpdateSourceFieldsInput {
- /** The field to identify a container by */
- container?: string | null;
- /** The fields to identify a host by */
- host?: string | null;
- /** The field to identify a pod by */
- pod?: string | null;
- /** The field to use as a tiebreaker for log events that have identical timestamps */
- tiebreaker?: string | null;
- /** The field to use as a timestamp for metrics and logs */
- timestamp?: string | null;
-}
-/** One of the log column types to display for this source */
-export interface UpdateSourceLogColumnInput {
- /** A custom field log column */
- fieldColumn?: UpdateSourceFieldLogColumnInput | null;
- /** A built-in message log column */
- messageColumn?: UpdateSourceMessageLogColumnInput | null;
- /** A built-in timestamp log column */
- timestampColumn?: UpdateSourceTimestampLogColumnInput | null;
-}
-
-export interface UpdateSourceFieldLogColumnInput {
- id: string;
-
- field: string;
-}
-
-export interface UpdateSourceMessageLogColumnInput {
- id: string;
-}
-
-export interface UpdateSourceTimestampLogColumnInput {
- id: string;
-}
-
-// ====================================================
-// Arguments
-// ====================================================
-
-export interface SourceQueryArgs {
- /** The id of the source */
- id: string;
-}
-export interface SnapshotInfraSourceArgs {
- timerange: InfraTimerangeInput;
-
- filterQuery?: string | null;
-}
-export interface MetricsInfraSourceArgs {
- nodeIds: InfraNodeIdsInput;
-
- nodeType: InfraNodeType;
-
- timerange: InfraTimerangeInput;
-
- metrics: InfraMetric[];
-}
-export interface IndexFieldsInfraSourceStatusArgs {
- indexType?: InfraIndexType | null;
-}
-export interface NodesInfraSnapshotResponseArgs {
- type: InfraNodeType;
-
- groupBy: InfraSnapshotGroupbyInput[];
-
- metric: InfraSnapshotMetricInput;
-}
-export interface CreateSourceMutationArgs {
- /** The id of the source */
- id: string;
-
- sourceProperties: UpdateSourceInput;
-}
-export interface UpdateSourceMutationArgs {
- /** The id of the source */
- id: string;
- /** The properties to update the source with */
- sourceProperties: UpdateSourceInput;
-}
-export interface DeleteSourceMutationArgs {
- /** The id of the source */
- id: string;
-}
-
-// ====================================================
-// Enums
-// ====================================================
-
-export enum InfraIndexType {
- ANY = 'ANY',
- LOGS = 'LOGS',
- METRICS = 'METRICS',
-}
-
-export enum InfraNodeType {
- pod = 'pod',
- container = 'container',
- host = 'host',
- awsEC2 = 'awsEC2',
- awsS3 = 'awsS3',
- awsRDS = 'awsRDS',
- awsSQS = 'awsSQS',
-}
-
-export enum InfraSnapshotMetricType {
- count = 'count',
- cpu = 'cpu',
- load = 'load',
- memory = 'memory',
- tx = 'tx',
- rx = 'rx',
- logRate = 'logRate',
- diskIOReadBytes = 'diskIOReadBytes',
- diskIOWriteBytes = 'diskIOWriteBytes',
- s3TotalRequests = 's3TotalRequests',
- s3NumberOfObjects = 's3NumberOfObjects',
- s3BucketSize = 's3BucketSize',
- s3DownloadBytes = 's3DownloadBytes',
- s3UploadBytes = 's3UploadBytes',
- rdsConnections = 'rdsConnections',
- rdsQueriesExecuted = 'rdsQueriesExecuted',
- rdsActiveTransactions = 'rdsActiveTransactions',
- rdsLatency = 'rdsLatency',
- sqsMessagesVisible = 'sqsMessagesVisible',
- sqsMessagesDelayed = 'sqsMessagesDelayed',
- sqsMessagesSent = 'sqsMessagesSent',
- sqsMessagesEmpty = 'sqsMessagesEmpty',
- sqsOldestMessage = 'sqsOldestMessage',
-}
-
-export enum InfraMetric {
- hostSystemOverview = 'hostSystemOverview',
- hostCpuUsage = 'hostCpuUsage',
- hostFilesystem = 'hostFilesystem',
- hostK8sOverview = 'hostK8sOverview',
- hostK8sCpuCap = 'hostK8sCpuCap',
- hostK8sDiskCap = 'hostK8sDiskCap',
- hostK8sMemoryCap = 'hostK8sMemoryCap',
- hostK8sPodCap = 'hostK8sPodCap',
- hostLoad = 'hostLoad',
- hostMemoryUsage = 'hostMemoryUsage',
- hostNetworkTraffic = 'hostNetworkTraffic',
- hostDockerOverview = 'hostDockerOverview',
- hostDockerInfo = 'hostDockerInfo',
- hostDockerTop5ByCpu = 'hostDockerTop5ByCpu',
- hostDockerTop5ByMemory = 'hostDockerTop5ByMemory',
- podOverview = 'podOverview',
- podCpuUsage = 'podCpuUsage',
- podMemoryUsage = 'podMemoryUsage',
- podLogUsage = 'podLogUsage',
- podNetworkTraffic = 'podNetworkTraffic',
- containerOverview = 'containerOverview',
- containerCpuKernel = 'containerCpuKernel',
- containerCpuUsage = 'containerCpuUsage',
- containerDiskIOOps = 'containerDiskIOOps',
- containerDiskIOBytes = 'containerDiskIOBytes',
- containerMemory = 'containerMemory',
- containerNetworkTraffic = 'containerNetworkTraffic',
- nginxHits = 'nginxHits',
- nginxRequestRate = 'nginxRequestRate',
- nginxActiveConnections = 'nginxActiveConnections',
- nginxRequestsPerConnection = 'nginxRequestsPerConnection',
- awsOverview = 'awsOverview',
- awsCpuUtilization = 'awsCpuUtilization',
- awsNetworkBytes = 'awsNetworkBytes',
- awsNetworkPackets = 'awsNetworkPackets',
- awsDiskioBytes = 'awsDiskioBytes',
- awsDiskioOps = 'awsDiskioOps',
- awsEC2CpuUtilization = 'awsEC2CpuUtilization',
- awsEC2DiskIOBytes = 'awsEC2DiskIOBytes',
- awsEC2NetworkTraffic = 'awsEC2NetworkTraffic',
- awsS3TotalRequests = 'awsS3TotalRequests',
- awsS3NumberOfObjects = 'awsS3NumberOfObjects',
- awsS3BucketSize = 'awsS3BucketSize',
- awsS3DownloadBytes = 'awsS3DownloadBytes',
- awsS3UploadBytes = 'awsS3UploadBytes',
- awsRDSCpuTotal = 'awsRDSCpuTotal',
- awsRDSConnections = 'awsRDSConnections',
- awsRDSQueriesExecuted = 'awsRDSQueriesExecuted',
- awsRDSActiveTransactions = 'awsRDSActiveTransactions',
- awsRDSLatency = 'awsRDSLatency',
- awsSQSMessagesVisible = 'awsSQSMessagesVisible',
- awsSQSMessagesDelayed = 'awsSQSMessagesDelayed',
- awsSQSMessagesSent = 'awsSQSMessagesSent',
- awsSQSMessagesEmpty = 'awsSQSMessagesEmpty',
- awsSQSOldestMessage = 'awsSQSOldestMessage',
- custom = 'custom',
-}
-
-// ====================================================
-// Unions
-// ====================================================
-
-/** All known log column types */
-export type InfraSourceLogColumn =
- | InfraSourceTimestampLogColumn
- | InfraSourceMessageLogColumn
- | InfraSourceFieldLogColumn;
-
-// ====================================================
-// END: Typescript template
-// ====================================================
-
-// ====================================================
-// Documents
-// ====================================================
-
-export namespace MetricsQuery {
- export type Variables = {
- sourceId: string;
- timerange: InfraTimerangeInput;
- metrics: InfraMetric[];
- nodeId: string;
- cloudId?: string | null;
- nodeType: InfraNodeType;
- };
-
- export type Query = {
- __typename?: 'Query';
-
- source: Source;
- };
-
- export type Source = {
- __typename?: 'InfraSource';
-
- id: string;
-
- metrics: Metrics[];
- };
-
- export type Metrics = {
- __typename?: 'InfraMetricData';
-
- id?: InfraMetric | null;
-
- series: Series[];
- };
-
- export type Series = {
- __typename?: 'InfraDataSeries';
-
- id: string;
-
- label: string;
-
- data: Data[];
- };
-
- export type Data = {
- __typename?: 'InfraDataPoint';
-
- timestamp: number;
-
- value?: number | null;
- };
-}
-
-export namespace CreateSourceConfigurationMutation {
- export type Variables = {
- sourceId: string;
- sourceProperties: UpdateSourceInput;
- };
-
- export type Mutation = {
- __typename?: 'Mutation';
-
- createSource: CreateSource;
- };
-
- export type CreateSource = {
- __typename?: 'UpdateSourceResult';
-
- source: Source;
- };
-
- export type Source = {
- __typename?: 'InfraSource';
-
- configuration: Configuration;
-
- status: Status;
- } & InfraSourceFields.Fragment;
-
- export type Configuration = SourceConfigurationFields.Fragment;
-
- export type Status = SourceStatusFields.Fragment;
-}
-
-export namespace SourceQuery {
- export type Variables = {
- sourceId?: string | null;
- };
-
- export type Query = {
- __typename?: 'Query';
-
- source: Source;
- };
-
- export type Source = {
- __typename?: 'InfraSource';
-
- configuration: Configuration;
-
- status: Status;
- } & InfraSourceFields.Fragment;
-
- export type Configuration = SourceConfigurationFields.Fragment;
-
- export type Status = SourceStatusFields.Fragment;
-}
-
-export namespace UpdateSourceMutation {
- export type Variables = {
- sourceId?: string | null;
- sourceProperties: UpdateSourceInput;
- };
-
- export type Mutation = {
- __typename?: 'Mutation';
-
- updateSource: UpdateSource;
- };
-
- export type UpdateSource = {
- __typename?: 'UpdateSourceResult';
-
- source: Source;
- };
-
- export type Source = {
- __typename?: 'InfraSource';
-
- configuration: Configuration;
-
- status: Status;
- } & InfraSourceFields.Fragment;
-
- export type Configuration = SourceConfigurationFields.Fragment;
-
- export type Status = SourceStatusFields.Fragment;
-}
-
-export namespace WaffleNodesQuery {
- export type Variables = {
- sourceId: string;
- timerange: InfraTimerangeInput;
- filterQuery?: string | null;
- metric: InfraSnapshotMetricInput;
- groupBy: InfraSnapshotGroupbyInput[];
- type: InfraNodeType;
- };
-
- export type Query = {
- __typename?: 'Query';
-
- source: Source;
- };
-
- export type Source = {
- __typename?: 'InfraSource';
-
- id: string;
-
- snapshot?: Snapshot | null;
- };
-
- export type Snapshot = {
- __typename?: 'InfraSnapshotResponse';
-
- nodes: Nodes[];
- };
-
- export type Nodes = {
- __typename?: 'InfraSnapshotNode';
-
- path: Path[];
-
- metric: Metric;
- };
-
- export type Path = {
- __typename?: 'InfraSnapshotNodePath';
-
- value: string;
-
- label: string;
-
- ip?: string | null;
- };
-
- export type Metric = {
- __typename?: 'InfraSnapshotNodeMetric';
-
- name: InfraSnapshotMetricType;
-
- value?: number | null;
-
- avg?: number | null;
-
- max?: number | null;
- };
-}
-
-export namespace SourceConfigurationFields {
- export type Fragment = {
- __typename?: 'InfraSourceConfiguration';
-
- name: string;
-
- description: string;
-
- logAlias: string;
-
- metricAlias: string;
-
- fields: Fields;
-
- logColumns: LogColumns[];
-
- inventoryDefaultView: string;
-
- metricsExplorerDefaultView: string;
- };
-
- export type Fields = {
- __typename?: 'InfraSourceFields';
-
- container: string;
-
- host: string;
-
- message: string[];
-
- pod: string;
-
- tiebreaker: string;
-
- timestamp: string;
- };
-
- export type LogColumns =
- | InfraSourceTimestampLogColumnInlineFragment
- | InfraSourceMessageLogColumnInlineFragment
- | InfraSourceFieldLogColumnInlineFragment;
-
- export type InfraSourceTimestampLogColumnInlineFragment = {
- __typename?: 'InfraSourceTimestampLogColumn';
-
- timestampColumn: TimestampColumn;
- };
-
- export type TimestampColumn = {
- __typename?: 'InfraSourceTimestampLogColumnAttributes';
-
- id: string;
- };
-
- export type InfraSourceMessageLogColumnInlineFragment = {
- __typename?: 'InfraSourceMessageLogColumn';
-
- messageColumn: MessageColumn;
- };
-
- export type MessageColumn = {
- __typename?: 'InfraSourceMessageLogColumnAttributes';
-
- id: string;
- };
-
- export type InfraSourceFieldLogColumnInlineFragment = {
- __typename?: 'InfraSourceFieldLogColumn';
-
- fieldColumn: FieldColumn;
- };
-
- export type FieldColumn = {
- __typename?: 'InfraSourceFieldLogColumnAttributes';
-
- id: string;
-
- field: string;
- };
-}
-
-export namespace SourceStatusFields {
- export type Fragment = {
- __typename?: 'InfraSourceStatus';
-
- indexFields: IndexFields[];
-
- logIndicesExist: boolean;
-
- metricIndicesExist: boolean;
- };
-
- export type IndexFields = {
- __typename?: 'InfraIndexField';
-
- name: string;
-
- type: string;
-
- searchable: boolean;
-
- aggregatable: boolean;
-
- displayable: boolean;
- };
-}
-
-export namespace InfraTimeKeyFields {
- export type Fragment = {
- __typename?: 'InfraTimeKey';
-
- time: number;
-
- tiebreaker: number;
- };
-}
-
-export namespace InfraSourceFields {
- export type Fragment = {
- __typename?: 'InfraSource';
-
- id: string;
-
- version?: string | null;
-
- updatedAt?: number | null;
-
- origin: string;
- };
-}
diff --git a/x-pack/plugins/infra/common/http_api/node_details_api.ts b/x-pack/plugins/infra/common/http_api/node_details_api.ts
index 0ef5ae82baeb..6de21da53c36 100644
--- a/x-pack/plugins/infra/common/http_api/node_details_api.ts
+++ b/x-pack/plugins/infra/common/http_api/node_details_api.ts
@@ -17,18 +17,20 @@ const NodeDetailsDataPointRT = rt.intersection([
}),
]);
-const NodeDetailsDataSeries = rt.type({
+const NodeDetailsDataSeriesRT = rt.type({
id: rt.string,
label: rt.string,
data: rt.array(NodeDetailsDataPointRT),
});
+export type NodeDetailsDataSeries = rt.TypeOf;
+
export const NodeDetailsMetricDataRT = rt.intersection([
rt.partial({
id: rt.union([InventoryMetricRT, rt.null]),
}),
rt.type({
- series: rt.array(NodeDetailsDataSeries),
+ series: rt.array(NodeDetailsDataSeriesRT),
}),
]);
diff --git a/x-pack/plugins/infra/common/http_api/source_api.ts b/x-pack/plugins/infra/common/http_api/source_api.ts
index be50989358c7..52a8d43da53b 100644
--- a/x-pack/plugins/infra/common/http_api/source_api.ts
+++ b/x-pack/plugins/infra/common/http_api/source_api.ts
@@ -39,18 +39,30 @@ const SavedSourceConfigurationFieldsRuntimeType = rt.partial({
timestamp: rt.string,
});
+export type InfraSavedSourceConfigurationFields = rt.TypeOf<
+ typeof SavedSourceConfigurationFieldColumnRuntimeType
+>;
+
export const SavedSourceConfigurationTimestampColumnRuntimeType = rt.type({
timestampColumn: rt.type({
id: rt.string,
}),
});
+export type InfraSourceConfigurationTimestampColumn = rt.TypeOf<
+ typeof SavedSourceConfigurationTimestampColumnRuntimeType
+>;
+
export const SavedSourceConfigurationMessageColumnRuntimeType = rt.type({
messageColumn: rt.type({
id: rt.string,
}),
});
+export type InfraSourceConfigurationMessageColumn = rt.TypeOf<
+ typeof SavedSourceConfigurationMessageColumnRuntimeType
+>;
+
export const SavedSourceConfigurationFieldColumnRuntimeType = rt.type({
fieldColumn: rt.type({
id: rt.string,
@@ -64,6 +76,10 @@ export const SavedSourceConfigurationColumnRuntimeType = rt.union([
SavedSourceConfigurationFieldColumnRuntimeType,
]);
+export type InfraSavedSourceConfigurationColumn = rt.TypeOf<
+ typeof SavedSourceConfigurationColumnRuntimeType
+>;
+
export const SavedSourceConfigurationRuntimeType = rt.partial({
name: rt.string,
description: rt.string,
@@ -136,12 +152,30 @@ const SourceConfigurationFieldsRuntimeType = rt.type({
...StaticSourceConfigurationFieldsRuntimeType.props,
});
+export type InfraSourceConfigurationFields = rt.TypeOf;
+
export const SourceConfigurationRuntimeType = rt.type({
...SavedSourceConfigurationRuntimeType.props,
fields: SourceConfigurationFieldsRuntimeType,
logColumns: rt.array(SavedSourceConfigurationColumnRuntimeType),
});
+const SourceStatusFieldRuntimeType = rt.type({
+ name: rt.string,
+ type: rt.string,
+ searchable: rt.boolean,
+ aggregatable: rt.boolean,
+ displayable: rt.boolean,
+});
+
+export type InfraSourceIndexField = rt.TypeOf;
+
+const SourceStatusRuntimeType = rt.type({
+ logIndicesExist: rt.boolean,
+ metricIndicesExist: rt.boolean,
+ indexFields: rt.array(SourceStatusFieldRuntimeType),
+});
+
export const SourceRuntimeType = rt.intersection([
rt.type({
id: rt.string,
@@ -155,31 +189,19 @@ export const SourceRuntimeType = rt.intersection([
rt.partial({
version: rt.string,
updatedAt: rt.number,
+ status: SourceStatusRuntimeType,
}),
]);
+export interface InfraSourceStatus extends rt.TypeOf {}
+
export interface InfraSourceConfiguration
extends rt.TypeOf {}
export interface InfraSource extends rt.TypeOf {}
-const SourceStatusFieldRuntimeType = rt.type({
- name: rt.string,
- type: rt.string,
- searchable: rt.boolean,
- aggregatable: rt.boolean,
- displayable: rt.boolean,
-});
-
-const SourceStatusRuntimeType = rt.type({
- logIndicesExist: rt.boolean,
- metricIndicesExist: rt.boolean,
- indexFields: rt.array(SourceStatusFieldRuntimeType),
-});
-
export const SourceResponseRuntimeType = rt.type({
source: SourceRuntimeType,
- status: SourceStatusRuntimeType,
});
export type SourceResponse = rt.TypeOf;
diff --git a/x-pack/plugins/infra/common/log_entry/log_entry.ts b/x-pack/plugins/infra/common/log_entry/log_entry.ts
index bf3f9ceb0b08..837249b65b2e 100644
--- a/x-pack/plugins/infra/common/log_entry/log_entry.ts
+++ b/x-pack/plugins/infra/common/log_entry/log_entry.ts
@@ -14,7 +14,6 @@ export type LogEntryTime = TimeKey;
/**
* message parts
*/
-
export const logMessageConstantPartRT = rt.type({
constant: rt.string,
});
diff --git a/x-pack/plugins/infra/docs/arch.md b/x-pack/plugins/infra/docs/arch.md
index f3d7312a3491..89b00cd19d1d 100644
--- a/x-pack/plugins/infra/docs/arch.md
+++ b/x-pack/plugins/infra/docs/arch.md
@@ -7,7 +7,7 @@ In this arch, we use 3 main terms to describe the code:
- **Libs / Domain Libs** - Business logic & data formatting (though complex formatting might call utils)
- **Adapters** - code that directly calls 3rd party APIs and data sources, exposing clean easy to stub APIs
- **Composition Files** - composes adapters into libs based on where the code is running
-- **Implementation layer** - The API such as rest endpoints or graphql schema on the server, and the state management / UI on the client
+- **Implementation layer** - The API such as rest endpoints on the server, and the state management / UI on the client
## Arch Visual Example
@@ -85,7 +85,7 @@ An example structure might be...
| | | | |-- kibana_angular // if an adapter has more than one file...
| | | | | |-- index.html
| | | | | |-- index.ts
- | | | | |
+ | | | | |
| | | | |-- ui_harness.ts
| | | |
| | |-- domains
diff --git a/x-pack/plugins/infra/docs/arch_client.md b/x-pack/plugins/infra/docs/arch_client.md
index cdc474635721..b40c9aaf1ff5 100644
--- a/x-pack/plugins/infra/docs/arch_client.md
+++ b/x-pack/plugins/infra/docs/arch_client.md
@@ -26,7 +26,7 @@ However, components that tweak EUI should go into `/public/components/eui/${comp
If using an EUI component that has not yet been typed, types should be placed into `/types/eui.d.ts`
-## Containers (Also: [see GraphQL docs](docs/graphql.md))
+## Containers
- HOC's based on Apollo.
- One folder per data type e.g. `host`. Folder name should be singular.
diff --git a/x-pack/plugins/infra/docs/graphql.md b/x-pack/plugins/infra/docs/graphql.md
deleted file mode 100644
index 5584a5ce7c0d..000000000000
--- a/x-pack/plugins/infra/docs/graphql.md
+++ /dev/null
@@ -1,53 +0,0 @@
-# GraphQL In Infra UI
-
-- The combined graphql schema collected from both the `public` and `server` directories is exported to `common/all.gql_schema.ts` for the purpose of automatic type generation only.
-
-## Server
-
-- Under `/server/graphql` there are files for each domain of data's graph schema and resolvers.
- - Each file has 2 exports `${domain}Schema` e.g. `fieldsSchema`, and `create${domain}Resolvers` e.g. `createFieldResolvers`
-- `/server/infra_server.ts` imports all schema and resolvers and passing the full schema to the server
-- Resolvers should be used to call composed libs, rather than directly performing any meaningful amount of data processing.
-- Resolvers should, however, only pass the required data into libs; that is to say all args for example would not be passed into a lib unless all were needed.
-
-## Client
-
-- Under `/public/containers/${domain}/` there is a file for each container. Each file has two exports, the query name e.g. `AllHosts` and the apollo HOC in the pattern of `with${queryName}` e.g. `withAllHosts`. This is done for two reasons:
-
- 1. It makes the code uniform, thus easier to reason about later.
- 2. If reformatting the data using a transform, it lets us re-type the data clearly.
-
-- Containers should use the apollo props callback to pass ONLY the props and data needed to children. e.g.
-
- ```ts
- import { Hosts, Pods, HostsAndPods } from '../../common/types';
-
- // used to generate the `HostsAndPods` type imported above
- export const hostsAndPods = gql`
- # ...
- `;
-
- type HostsAndPodsProps = {
- hosts: Hosts;
- pods: Pods;
- }
-
- export const withHostsAndPods = graphql<
- {},
- HostsAndPods.Query,
- HostsAndPods.Variables,
- HostsAndPodsProps
- >(hostsAndPods, {
- props: ({ data, ownProps }) => ({
- hosts: hostForMap(data && data.hosts ? data.hosts : []),
-  pods: podsFromHosts(data && data.hosts ? data.hosts : [])
- ...ownProps,
- }),
- });
- ```
-
- as `ownProps` are the props passed to the wrapped component, they should just be forwarded.
-
-## Types
-
-- The command `yarn build-graphql-types` derives the schema, query and mutation types and stores them in `common/types.ts` for use on both the client and server.
diff --git a/x-pack/plugins/infra/public/apps/common_providers.tsx b/x-pack/plugins/infra/public/apps/common_providers.tsx
index ebfa412410dd..ad1c1e1129de 100644
--- a/x-pack/plugins/infra/public/apps/common_providers.tsx
+++ b/x-pack/plugins/infra/public/apps/common_providers.tsx
@@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { ApolloClient } from 'apollo-client';
import { AppMountParameters, CoreStart } from 'kibana/public';
import React, { useMemo } from 'react';
import {
@@ -15,32 +14,28 @@ import { EuiThemeProvider } from '../../../../../src/plugins/kibana_react/common
import { TriggersAndActionsUIPublicPluginStart } from '../../../triggers_actions_ui/public';
import { createKibanaContextForPlugin } from '../hooks/use_kibana';
import { InfraClientStartDeps } from '../types';
-import { ApolloClientContext } from '../utils/apollo_context';
import { HeaderActionMenuProvider } from '../utils/header_action_menu_provider';
import { NavigationWarningPromptProvider } from '../utils/navigation_warning_prompt';
import { TriggersActionsProvider } from '../utils/triggers_actions_context';
import { Storage } from '../../../../../src/plugins/kibana_utils/public';
export const CommonInfraProviders: React.FC<{
- apolloClient: ApolloClient<{}>;
appName: string;
storage: Storage;
triggersActionsUI: TriggersAndActionsUIPublicPluginStart;
setHeaderActionMenu: AppMountParameters['setHeaderActionMenu'];
-}> = ({ apolloClient, children, triggersActionsUI, setHeaderActionMenu, appName, storage }) => {
+}> = ({ children, triggersActionsUI, setHeaderActionMenu, appName, storage }) => {
const [darkMode] = useUiSetting$('theme:darkMode');
return (
-
-
-
-
- {children}
-
-
-
-
+
+
+
+ {children}
+
+
+
);
};
diff --git a/x-pack/plugins/infra/public/apps/logs_app.tsx b/x-pack/plugins/infra/public/apps/logs_app.tsx
index 381c75c4b9a2..8a6a2e273f2c 100644
--- a/x-pack/plugins/infra/public/apps/logs_app.tsx
+++ b/x-pack/plugins/infra/public/apps/logs_app.tsx
@@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { ApolloClient } from 'apollo-client';
import { History } from 'history';
import { CoreStart } from 'kibana/public';
import React from 'react';
@@ -17,7 +16,6 @@ import { NotFoundPage } from '../pages/404';
import { LinkToLogsPage } from '../pages/link_to/link_to_logs';
import { LogsPage } from '../pages/logs';
import { InfraClientStartDeps } from '../types';
-import { createApolloClient } from '../utils/apollo_client';
import { CommonInfraProviders, CoreProviders } from './common_providers';
import { prepareMountElement } from './common_styles';
@@ -26,14 +24,12 @@ export const renderApp = (
plugins: InfraClientStartDeps,
{ element, history, setHeaderActionMenu }: AppMountParameters
) => {
- const apolloClient = createApolloClient(core.http.fetch);
const storage = new Storage(window.localStorage);
prepareMountElement(element);
ReactDOM.render(
;
core: CoreStart;
history: History;
plugins: InfraClientStartDeps;
setHeaderActionMenu: AppMountParameters['setHeaderActionMenu'];
storage: Storage;
-}> = ({ apolloClient, core, history, plugins, setHeaderActionMenu, storage }) => {
+}> = ({ core, history, plugins, setHeaderActionMenu, storage }) => {
const uiCapabilities = core.application.capabilities;
return (
{
- const apolloClient = createApolloClient(core.http.fetch);
const storage = new Storage(window.localStorage);
prepareMountElement(element);
ReactDOM.render(
;
core: CoreStart;
history: History;
plugins: InfraClientStartDeps;
setHeaderActionMenu: AppMountParameters['setHeaderActionMenu'];
storage: Storage;
-}> = ({ apolloClient, core, history, plugins, setHeaderActionMenu, storage }) => {
+}> = ({ core, history, plugins, setHeaderActionMenu, storage }) => {
const uiCapabilities = core.application.capabilities;
return (
{
+export const useSourceConfigurationFormState = (configuration?: InfraSourceConfiguration) => {
const indicesConfigurationFormState = useIndicesConfigurationFormState({
initialFormState: useMemo(
() =>
diff --git a/x-pack/plugins/infra/public/containers/source/create_source.gql_query.ts b/x-pack/plugins/infra/public/containers/source/create_source.gql_query.ts
deleted file mode 100644
index 6727dea712f3..000000000000
--- a/x-pack/plugins/infra/public/containers/source/create_source.gql_query.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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 gql from 'graphql-tag';
-
-import { sharedFragments } from '../../../common/graphql/shared';
-import {
- sourceConfigurationFieldsFragment,
- sourceStatusFieldsFragment,
-} from './source_fields_fragment.gql_query';
-
-export const createSourceMutation = gql`
- mutation CreateSourceConfigurationMutation(
- $sourceId: ID!
- $sourceProperties: UpdateSourceInput!
- ) {
- createSource(id: $sourceId, sourceProperties: $sourceProperties) {
- source {
- ...InfraSourceFields
- configuration {
- ...SourceConfigurationFields
- }
- status {
- ...SourceStatusFields
- }
- }
- }
- }
-
- ${sharedFragments.InfraSourceFields}
- ${sourceConfigurationFieldsFragment}
- ${sourceStatusFieldsFragment}
-`;
diff --git a/x-pack/plugins/infra/public/containers/source/query_source.gql_query.ts b/x-pack/plugins/infra/public/containers/source/query_source.gql_query.ts
deleted file mode 100644
index 21b5192e5725..000000000000
--- a/x-pack/plugins/infra/public/containers/source/query_source.gql_query.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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 gql from 'graphql-tag';
-
-import { sharedFragments } from '../../../common/graphql/shared';
-import {
- sourceConfigurationFieldsFragment,
- sourceStatusFieldsFragment,
-} from './source_fields_fragment.gql_query';
-
-export const sourceQuery = gql`
- query SourceQuery($sourceId: ID = "default") {
- source(id: $sourceId) {
- ...InfraSourceFields
- configuration {
- ...SourceConfigurationFields
- }
- status {
- ...SourceStatusFields
- }
- }
- }
-
- ${sharedFragments.InfraSourceFields}
- ${sourceConfigurationFieldsFragment}
- ${sourceStatusFieldsFragment}
-`;
diff --git a/x-pack/plugins/infra/public/containers/source/source.tsx b/x-pack/plugins/infra/public/containers/source/source.tsx
index 96bbd858c3a4..c84269d6b498 100644
--- a/x-pack/plugins/infra/public/containers/source/source.tsx
+++ b/x-pack/plugins/infra/public/containers/source/source.tsx
@@ -8,20 +8,17 @@ import createContainer from 'constate';
import { useEffect, useMemo, useState } from 'react';
import {
- CreateSourceConfigurationMutation,
- SourceQuery,
- UpdateSourceInput,
- UpdateSourceMutation,
-} from '../../graphql/types';
-import { DependencyError, useApolloClient } from '../../utils/apollo_context';
+ InfraSavedSourceConfiguration,
+ InfraSource,
+ SourceResponse,
+} from '../../../common/http_api/source_api';
import { useTrackedPromise } from '../../utils/use_tracked_promise';
-import { createSourceMutation } from './create_source.gql_query';
-import { sourceQuery } from './query_source.gql_query';
-import { updateSourceMutation } from './update_source.gql_query';
+import { useKibana } from '../../../../../../src/plugins/kibana_react/public';
-type Source = SourceQuery.Query['source'];
-
-export const pickIndexPattern = (source: Source | undefined, type: 'logs' | 'metrics' | 'both') => {
+export const pickIndexPattern = (
+ source: InfraSource | undefined,
+ type: 'logs' | 'metrics' | 'both'
+) => {
if (!source) {
return 'unknown-index';
}
@@ -34,96 +31,79 @@ export const pickIndexPattern = (source: Source | undefined, type: 'logs' | 'met
return `${source.configuration.logAlias},${source.configuration.metricAlias}`;
};
+const DEPENDENCY_ERROR_MESSAGE = 'Failed to load source: No fetch client available.';
+
export const useSource = ({ sourceId }: { sourceId: string }) => {
- const apolloClient = useApolloClient();
- const [source, setSource] = useState