add graph sample data (#54558)

This commit is contained in:
Joe Reuter 2020-01-14 18:02:49 +01:00 committed by GitHub
parent b298dd4c20
commit 8c878bcaa8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 2573 additions and 4 deletions

View file

@ -0,0 +1,11 @@
/*
* 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.
*/
export const APP_ICON = 'graphApp';
export function createWorkspacePath(id: string) {
return `/app/graph/#/workspace/${id}`;
}

View file

@ -5,6 +5,7 @@
*/
import Boom from 'boom';
import { map } from 'rxjs/operators';
import { Observable, Subscription } from 'rxjs';
import { ILicense } from '../../../licensing/common/types';
import { checkLicense, GraphLicenseInformation } from '../../common/check_license';
@ -12,13 +13,15 @@ import { checkLicense, GraphLicenseInformation } from '../../common/check_licens
export class LicenseState {
private licenseInformation: GraphLicenseInformation = checkLicense(undefined);
private subscription: Subscription | null = null;
private observable: Observable<GraphLicenseInformation> | null = null;
private updateInformation(license: ILicense | undefined) {
this.licenseInformation = checkLicense(license);
private updateInformation(licenseInformation: GraphLicenseInformation) {
this.licenseInformation = licenseInformation;
}
public start(license$: Observable<ILicense>) {
this.subscription = license$.subscribe(this.updateInformation.bind(this));
this.observable = license$.pipe(map(checkLicense));
this.subscription = this.observable.subscribe(this.updateInformation.bind(this));
}
public stop() {
@ -30,6 +33,10 @@ export class LicenseState {
public getLicenseInformation() {
return this.licenseInformation;
}
public getLicenseInformation$() {
return this.observable;
}
}
export function verifyApiAccess(licenseState: LicenseState) {

View file

@ -9,15 +9,24 @@ import { LicensingPluginSetup } from '../../licensing/server';
import { LicenseState } from './lib/license_state';
import { registerSearchRoute } from './routes/search';
import { registerExploreRoute } from './routes/explore';
import { HomeServerPluginSetup } from '../../../../src/plugins/home/server';
import { registerSampleData } from './sample_data';
export class GraphPlugin implements Plugin {
private licenseState: LicenseState | null = null;
public async setup(core: CoreSetup, { licensing }: { licensing: LicensingPluginSetup }) {
public async setup(
core: CoreSetup,
{ licensing, home }: { licensing: LicensingPluginSetup; home?: HomeServerPluginSetup }
) {
const licenseState = new LicenseState();
licenseState.start(licensing.license$);
this.licenseState = licenseState;
if (home) {
registerSampleData(home.sampleData, licenseState);
}
const router = core.http.createRouter();
registerSearchRoute({ licenseState, router });
registerExploreRoute({ licenseState, router });

View file

@ -0,0 +1,391 @@
/*
* 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 { i18n } from '@kbn/i18n';
import { SampleDataRegistrySetup } from '../../../../../src/plugins/home/server';
import { APP_ICON, createWorkspacePath } from '../../common/constants';
const datasetId = 'ecommerce';
const wsState: any = {
selectedFields: [
{
name: 'customer_gender',
hopSize: 5,
lastValidHopSize: 5,
color: '#7B000B',
selected: true,
iconClass: 'fa-user',
},
{
name: 'geoip.continent_name',
hopSize: 5,
lastValidHopSize: 5,
color: '#B0916F',
selected: true,
iconClass: 'fa-map-marker',
},
{
name: 'products.category.keyword',
hopSize: 5,
lastValidHopSize: 5,
color: '#34130C',
selected: true,
iconClass: 'fa-heart',
},
],
blacklist: [
{
x: 491.3880229084531,
y: 572.375603969653,
label: 'South America',
color: '#B0916F',
field: 'geoip.continent_name',
term: 'South America',
parent: null,
size: 15,
},
],
vertices: [
{
x: 458.033767981859,
y: 181.9021747060339,
label: "Women's Shoes",
color: '#34130C',
field: 'products.category.keyword',
term: "Women's Shoes",
parent: null,
size: 15,
},
{
x: 236.16141155056786,
y: 371.69388982857515,
label: "Men's Accessories",
color: '#34130C',
field: 'products.category.keyword',
term: "Men's Accessories",
parent: null,
size: 15,
},
{
x: 334.27149182482333,
y: 244.99855207230468,
label: "Women's Accessories",
color: '#34130C',
field: 'products.category.keyword',
term: "Women's Accessories",
parent: null,
size: 15,
},
{
x: 452.21475063865597,
y: 330.39076195279216,
label: 'Asia',
color: '#B0916F',
field: 'geoip.continent_name',
term: 'Asia',
parent: null,
size: 15,
},
{
x: 397.79868111013536,
y: 280.55152377990424,
label: 'Europe',
color: '#B0916F',
field: 'geoip.continent_name',
term: 'Europe',
parent: null,
size: 15,
},
{
x: 324.72030800021247,
y: 352.6641597050945,
label: "Men's Shoes",
color: '#34130C',
field: 'products.category.keyword',
term: "Men's Shoes",
parent: null,
size: 15,
},
{
x: 372.16854727881645,
y: 390.62646298282147,
label: "Men's Clothing",
color: '#34130C',
field: 'products.category.keyword',
term: "Men's Clothing",
parent: null,
size: 15,
},
{
x: 508.049093768632,
y: 242.4089619805834,
label: "Women's Clothing",
color: '#34130C',
field: 'products.category.keyword',
term: "Women's Clothing",
parent: null,
size: 15,
},
{
x: 440.1331838313072,
y: 289.96431350734645,
label: 'Africa',
color: '#B0916F',
field: 'geoip.continent_name',
term: 'Africa',
parent: null,
size: 15,
},
{
x: 387.0908385779075,
y: 210.10263143650025,
label: 'FEMALE',
color: '#7B000B',
field: 'customer_gender',
term: 'FEMALE',
parent: null,
size: 15,
},
{
x: 290.59483393305874,
y: 298.89363320612324,
label: 'MALE',
color: '#7B000B',
field: 'customer_gender',
term: 'MALE',
parent: null,
size: 15,
},
{
x: 413.02719526683677,
y: 322.2286023727188,
label: 'North America',
color: '#B0916F',
field: 'geoip.continent_name',
term: 'North America',
parent: null,
size: 15,
},
],
links: [
{
weight: 0.005857130017177792,
width: 8.232101279777059,
inferred: false,
source: 7,
target: 7,
},
{ weight: 0.00040740358951793883, width: 2, inferred: false, source: 2, target: 10 },
{ weight: 0.00013791546585173228, width: 2, inferred: false, source: 5, target: 1 },
{ weight: 0.0004858267848737237, width: 2, inferred: false, source: 4, target: 2 },
{ weight: 0.0010153751000293245, width: 2, inferred: false, source: 10, target: 11 },
{ weight: 0.0028264125846644674, width: 2, inferred: false, source: 2, target: 9 },
{ weight: 0.0005650580249547761, width: 2, inferred: false, source: 3, target: 0 },
{ weight: 0.0009324185728321393, width: 2, inferred: false, source: 6, target: 11 },
{
weight: 0.0014323721292750112,
width: 2.0131758052049205,
inferred: false,
source: 4,
target: 4,
},
{
weight: 0.002342547575207893,
width: 3.2924126381437944,
inferred: false,
source: 0,
target: 0,
},
{ weight: 0.000591872989689757, width: 2, inferred: false, source: 8, target: 5 },
{ weight: 0.0008255717897066532, width: 2, inferred: false, source: 3, target: 5 },
{ weight: 0.0006448216532672799, width: 2, inferred: false, source: 7, target: 8 },
{ weight: 0.0002511052407839208, width: 2, inferred: false, source: 8, target: 0 },
{ weight: 0.0013789044568299467, width: 2, inferred: false, source: 8, target: 10 },
{ weight: 0.000783301409144887, width: 2, inferred: false, source: 8, target: 9 },
{
weight: 0.00560336629275442,
width: 7.875440479272377,
inferred: false,
source: 10,
target: 6,
},
{ weight: 0.0005016633048258001, width: 2, inferred: false, source: 5, target: 11 },
{ weight: 0.0003926052511049418, width: 2, inferred: false, source: 2, target: 3 },
{ weight: 0.0008115500826586831, width: 2, inferred: false, source: 8, target: 8 },
{ weight: 0.0014948001891181592, width: 2, inferred: false, source: 3, target: 9 },
{ weight: 0.000029981623011246145, width: 2, inferred: false, source: 2, target: 5 },
{
weight: 0.002480454462292142,
width: 3.4862385321100913,
inferred: false,
source: 9,
target: 4,
},
{ weight: 0.002025814694014704, width: 2, inferred: false, source: 11, target: 7 },
{
weight: 0.0026700604482252604,
width: 2.137643910722111,
inferred: false,
source: 3,
target: 10,
},
{ weight: 0.00010444018788598492, width: 2, inferred: false, source: 9, target: 6 },
{
weight: 0.0024519155063363668,
width: 3.44612749220522,
inferred: false,
source: 6,
target: 3,
},
{ weight: 0.0006267747531045212, width: 2, inferred: false, source: 10, target: 1 },
{ weight: 0.00016502073678324177, width: 2, inferred: false, source: 2, target: 8 },
{ weight: 0.0005870783606720878, width: 2, inferred: false, source: 6, target: 4 },
{ weight: 0.00038852356835608306, width: 2, inferred: false, source: 6, target: 2 },
{
weight: 0.001950556798534224,
width: 2.741475956722648,
inferred: false,
source: 5,
target: 5,
},
{ weight: 0.0005728452602402718, width: 2, inferred: false, source: 2, target: 11 },
{
weight: 0.0068966839555125534,
width: 9.693177486223698,
inferred: false,
source: 9,
target: 9,
},
{
weight: 0.003985530212040768,
width: 3.2924126381437944,
inferred: false,
source: 0,
target: 7,
},
{ weight: 0.0005390262876698882, width: 2, inferred: false, source: 4, target: 10 },
{ weight: 0.001230534654985059, width: 2, inferred: false, source: 3, target: 7 },
{ weight: 0.0012265720435530507, width: 2, inferred: false, source: 2, target: 2 },
{ weight: 0.00010444018788598492, width: 2, inferred: false, source: 9, target: 5 },
{ weight: 0.00246087192706352, width: 2, inferred: false, source: 11, target: 9 },
{ weight: 0.001266247444586856, width: 2, inferred: false, source: 6, target: 8 },
{
weight: 0.0040928391377725235,
width: 5.752419052533403,
inferred: false,
source: 10,
target: 5,
},
{
weight: 0.003998804111234147,
width: 2.741475956722648,
inferred: false,
source: 5,
target: 6,
},
{ weight: 0.0000201191575509262, width: 2, inferred: false, source: 2, target: 1 },
{ weight: 0.0019559590149107486, width: 2, inferred: false, source: 4, target: 7 },
{
weight: 0.005399134008600699,
width: 7.588395315032752,
inferred: false,
source: 10,
target: 10,
},
{ weight: 0.0008406249972756651, width: 2, inferred: false, source: 11, target: 0 },
{ weight: 0.002434040312854235, width: 2, inferred: false, source: 2, target: 7 },
{ weight: 0.0007632277713300751, width: 2, inferred: false, source: 4, target: 0 },
{ weight: 0.007114987799732724, width: 10, inferred: false, source: 9, target: 7 },
{ weight: 0.00029149607092423423, width: 2, inferred: false, source: 4, target: 5 },
{
weight: 0.004628005825697707,
width: 3.2924126381437944,
inferred: false,
source: 0,
target: 9,
},
{ weight: 0.0001769629690348846, width: 2, inferred: false, source: 0, target: 2 },
{
weight: 0.0017862657198589743,
width: 2.510567509231816,
inferred: false,
source: 11,
target: 11,
},
{
weight: 0.0023385207220538266,
width: 3.286752961321555,
inferred: false,
source: 3,
target: 3,
},
{ weight: 0.0005977285667016662, width: 2, inferred: false, source: 6, target: 1 },
{
weight: 0.00523765988442745,
width: 7.361446051424297,
inferred: false,
source: 6,
target: 6,
},
],
urlTemplates: [
{
url:
'/app/kibana#/discover?_a=(columns%3A!(_source)%2Cindex%3Aff959d40-b880-11e8-a6d9-e546fe2bba5f%2Cinterval%3Aauto%2Cquery%3A(language%3Akuery%2Cquery%3A{{gquery}})%2Csort%3A!(_score%2Cdesc))',
description: 'Raw documents',
isDefault: true,
encoderID: 'kql-loose',
},
],
exploreControls: {
useSignificance: false,
sampleSize: 2000,
timeoutMillis: 5000,
maxValuesPerDoc: 1,
minDocCount: 3,
},
indexPatternRefName: 'indexPattern_0',
};
export function registerEcommerceSampleData(sampleDataRegistry: SampleDataRegistrySetup) {
sampleDataRegistry.addSavedObjectsToSampleDataset(datasetId, [
{
type: 'graph-workspace',
id: '46fa9d30-319c-11ea-bbe4-818d9c786051',
version: '2',
attributes: {
title: 'Kibana Sample Data - eCommerce',
description:
'This is a sample graph based on an eCommerce data set. It shows the gender, continent, and product category of purchases. The thicker the line is, there are more correlated documents between the vertices.',
numLinks: 57,
numVertices: 12,
version: 1,
wsState: JSON.stringify(JSON.stringify(wsState)),
},
references: [
{
name: 'indexPattern_0',
type: 'index-pattern',
id: 'kibana_sample_data_ecommerce',
},
],
migrationVersion: {
'graph-workspace': '7.0.0',
},
updated_at: '2020-01-09T16:40:36.122Z',
},
]);
}
export function registerEcommerceSampleDataLink(sampleDataRegistry: SampleDataRegistrySetup) {
sampleDataRegistry.addAppLinksToSampleDataset(datasetId, [
{
path: createWorkspacePath('46fa9d30-319c-11ea-bbe4-818d9c786051'),
label: i18n.translate('xpack.graph.sampleData.label', { defaultMessage: 'Graph' }),
icon: APP_ICON,
},
]);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
/*
* 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.
*/
export { registerSampleData } from './register_sample_data';

View file

@ -0,0 +1,463 @@
/*
* 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 { i18n } from '@kbn/i18n';
import { SampleDataRegistrySetup } from '../../../../../src/plugins/home/server';
import { APP_ICON, createWorkspacePath } from '../../common/constants';
const datasetId = 'logs';
const wsState: any = {
selectedFields: [
{
name: 'agent.keyword',
hopSize: 5,
lastValidHopSize: 5,
color: '#CE0060',
selected: true,
iconClass: 'fa-key',
},
{
name: 'extension.keyword',
hopSize: 5,
lastValidHopSize: 5,
color: '#B0916F',
selected: true,
iconClass: 'fa-key',
},
{
name: 'geo.src',
hopSize: 5,
lastValidHopSize: 5,
color: '#1EA593',
selected: true,
iconClass: 'fa-map-marker',
},
{
name: 'response.keyword',
hopSize: 5,
lastValidHopSize: 5,
color: '#7B000B',
selected: true,
iconClass: 'fa-key',
},
],
blacklist: [
{
x: 349.9814471314239,
y: 274.1259761174194,
label: '200',
color: '#7B000B',
field: 'response.keyword',
term: '200',
parent: null,
size: 15,
},
{
x: 264.83032783224775,
y: 149.28911778947068,
label: '404',
color: '#7B000B',
field: 'response.keyword',
term: '404',
parent: null,
size: 15,
},
],
vertices: [
{
x: 705.0456564066692,
y: 40.62170801995693,
label: 'US',
color: '#1EA593',
field: 'geo.src',
term: 'US',
parent: null,
size: 15,
},
{
x: 403.9630841139531,
y: 343.70678387260784,
label: 'rpm',
color: '#B0916F',
field: 'extension.keyword',
term: 'rpm',
parent: null,
size: 15,
},
{
x: 725.3403430314892,
y: 531.7559897276761,
label: 'NG',
color: '#1EA593',
field: 'geo.src',
term: 'NG',
parent: null,
size: 15,
},
{
x: 226.82596303052026,
y: 412.0884666842448,
label: 'Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1',
color: '#CE0060',
field: 'agent.keyword',
term: 'Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1',
parent: null,
size: 15,
},
{
x: 292.5918164195066,
y: 268.48941070600534,
label: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)',
color: '#CE0060',
field: 'agent.keyword',
term: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)',
parent: null,
size: 15,
},
{
x: 778.0887942801058,
y: 182.63288692820015,
label: 'LK',
color: '#1EA593',
field: 'geo.src',
term: 'LK',
parent: null,
size: 15,
},
{
x: 341.01411891217134,
y: 416.2991570121247,
label: 'CN',
color: '#1EA593',
field: 'geo.src',
term: 'CN',
parent: null,
size: 15,
},
{
x: 190.18900623537502,
y: 474.94911053447447,
label: 'deb',
color: '#B0916F',
field: 'extension.keyword',
term: 'deb',
parent: null,
size: 15,
},
{
x: 232.7845499845522,
y: 292.79169517403824,
label: 'zip',
color: '#B0916F',
field: 'extension.keyword',
term: 'zip',
parent: null,
size: 15,
},
{
x: 138.90354356936942,
y: 439.57743024730985,
label: 'gz',
color: '#B0916F',
field: 'extension.keyword',
term: 'gz',
parent: null,
size: 15,
},
{
x: 365.6408169826396,
y: 249.99925380062638,
label:
'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24',
color: '#CE0060',
field: 'agent.keyword',
term:
'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24',
parent: null,
size: 15,
},
{
x: 265.07380044771776,
y: 329.42267335684767,
label: 'css',
color: '#B0916F',
field: 'extension.keyword',
term: 'css',
parent: null,
size: 15,
},
{
x: 580.3896044080259,
y: 667.66318599786,
label: 'ET',
color: '#1EA593',
field: 'geo.src',
term: 'ET',
parent: null,
size: 15,
},
{
x: 568.0601884734044,
y: -49.27073508690644,
label: 'ZW',
color: '#1EA593',
field: 'geo.src',
term: 'ZW',
parent: null,
size: 15,
},
{
x: 227.5383201433136,
y: 199.48377517208598,
label: '',
color: '#B0916F',
field: 'extension.keyword',
term: '',
parent: null,
size: 15,
},
{
x: 288.39123736592035,
y: 393.4288970445101,
label: 'GT',
color: '#1EA593',
field: 'geo.src',
term: 'GT',
parent: null,
size: 15,
},
{
x: 155.466542394056,
y: 339.05104397852546,
label: 'ES',
color: '#1EA593',
field: 'geo.src',
term: 'ES',
parent: null,
size: 15,
},
{
x: 401.32323264585983,
y: -108.02214607103728,
label: 'CO',
color: '#1EA593',
field: 'geo.src',
term: 'CO',
parent: null,
size: 15,
},
{
x: 792.1054319493805,
y: 358.6366312643674,
label: 'PA',
color: '#1EA593',
field: 'geo.src',
term: 'PA',
parent: null,
size: 15,
},
{
x: 314.32050042836784,
y: 319.42284908520816,
label: '503',
color: '#7B000B',
field: 'response.keyword',
term: '503',
parent: null,
size: 15,
},
{
x: 340.8606114563168,
y: 186.9348337340475,
label: 'IN',
color: '#1EA593',
field: 'geo.src',
term: 'IN',
parent: null,
size: 15,
},
{
x: 164.94735578931335,
y: 303.33721636577303,
label: 'SY',
color: '#1EA593',
field: 'geo.src',
term: 'SY',
parent: null,
size: 15,
},
{
x: 301.2853960233053,
y: 435.9520992987688,
label: 'MM',
color: '#1EA593',
field: 'geo.src',
term: 'MM',
parent: null,
size: 15,
},
{
x: 184.25271122815448,
y: 64.76252387726619,
label: 'BI',
color: '#1EA593',
field: 'geo.src',
term: 'BI',
parent: null,
size: 15,
},
{
x: 547.7017436962481,
y: 363.41281417686463,
label: 'JP',
color: '#1EA593',
field: 'geo.src',
term: 'JP',
parent: null,
size: 15,
},
{
x: 530.0067122142244,
y: 267.5235740844544,
label: 'IT',
color: '#1EA593',
field: 'geo.src',
term: 'IT',
parent: null,
size: 15,
},
{
x: 502.58809919406076,
y: 453.01592357006285,
label: 'YE',
color: '#1EA593',
field: 'geo.src',
term: 'YE',
parent: null,
size: 15,
},
],
links: [
{ weight: 0.0040634810444444, width: 2, inferred: false, source: 8, target: 6 },
{ weight: 0.00001660379672906535, width: 2, inferred: false, source: 11, target: 3 },
{ weight: 0.00001687128485592423, width: 2, inferred: false, source: 1, target: 4 },
{ weight: 0.000042381532626601156, width: 2, inferred: false, source: 3, target: 7 },
{ weight: 0.0020092062171401465, width: 2, inferred: false, source: 6, target: 11 },
{ weight: 0.009186429989786131, width: 2, inferred: false, source: 6, target: 7 },
{ weight: 0.0000305247789830849, width: 2, inferred: false, source: 8, target: 4 },
{ weight: 0.000001708437364178419, width: 2, inferred: false, source: 11, target: 10 },
{ weight: 0.004598490556833276, width: 2, inferred: false, source: 1, target: 6 },
{ weight: 0.0000010807159115480025, width: 2, inferred: false, source: 3, target: 9 },
{ weight: 0.011760987925777693, width: 2, inferred: false, source: 6, target: 3 },
{ weight: 0.00000572246876958705, width: 2, inferred: false, source: 3, target: 8 },
{ weight: 0.00003799465167914097, width: 2, inferred: false, source: 1, target: 10 },
{ weight: 0.00019306796701208605, width: 2, inferred: false, source: 20, target: 10 },
{ weight: 0.001410620591413074, width: 2, inferred: false, source: 16, target: 19 },
{ weight: 0.00000260088891060836, width: 2, inferred: false, source: 16, target: 8 },
{ weight: 0.000004221034247288931, width: 2, inferred: false, source: 21, target: 9 },
{ weight: 0.0003983945660073508, width: 2, inferred: false, source: 19, target: 3 },
{ weight: 8.558271008580196e-7, width: 2, inferred: false, source: 14, target: 23 },
{ weight: 0.00002868576516354896, width: 2, inferred: false, source: 14, target: 10 },
{ weight: 0.0000016586853264248163, width: 2, inferred: false, source: 21, target: 4 },
{ weight: 5.648882390462957e-7, width: 2, inferred: false, source: 21, target: 14 },
{ weight: 0.00003419153715339904, width: 2, inferred: false, source: 19, target: 4 },
{ weight: 0.0005988902747672857, width: 2, inferred: false, source: 8, target: 19 },
{ weight: 0.000993973548776136, width: 2, inferred: false, source: 19, target: 1 },
{ weight: 3.835478702669183e-7, width: 2, inferred: false, source: 20, target: 1 },
{ weight: 0.00000739937347045766, width: 2, inferred: false, source: 16, target: 3 },
{ weight: 0.0014120620624644335, width: 2, inferred: false, source: 21, target: 19 },
{ weight: 0.00011448660448075209, width: 2, inferred: false, source: 20, target: 14 },
{ weight: 0.000029650891466752718, width: 2, inferred: false, source: 10, target: 19 },
{ weight: 0.0016870823187632464, width: 2, inferred: false, source: 19, target: 15 },
{ weight: 0.000008712259181870499, width: 2, inferred: false, source: 8, target: 20 },
{ weight: 0.0006524448834525575, width: 2, inferred: false, source: 19, target: 6 },
{ weight: 0.000003916666394077713, width: 2, inferred: false, source: 8, target: 10 },
{ weight: 0.0000018561676077277568, width: 2, inferred: false, source: 16, target: 9 },
{ weight: 0.000006461917090181791, width: 2, inferred: false, source: 20, target: 19 },
{ weight: 0.000813581545225818, width: 2, inferred: false, source: 19, target: 22 },
{ weight: 0.0000790962811304827, width: 2, inferred: false, source: 14, target: 19 },
{ weight: 0.0000038232332387185065, width: 2, inferred: false, source: 8, target: 15 },
{ weight: 1.3666472391330093e-8, width: 2, inferred: false, source: 4, target: 22 },
{ weight: 6.868214506521744e-7, width: 2, inferred: false, source: 15, target: 7 },
{ weight: 0.000005170326226968777, width: 2, inferred: false, source: 22, target: 1 },
{ weight: 0.000018344494132865016, width: 2, inferred: false, source: 3, target: 22 },
{ weight: 0.000020468166046825227, width: 2, inferred: false, source: 3, target: 1 },
{ weight: 0.0000020332506548392678, width: 2, inferred: false, source: 21, target: 11 },
{ weight: 0.0000019831315870577016, width: 2, inferred: false, source: 21, target: 7 },
{ weight: 3.630137259008554e-7, width: 2, inferred: false, source: 22, target: 9 },
{ weight: 0.000003238006460439622, width: 2, inferred: false, source: 4, target: 15 },
{ weight: 0.0000010228580484196547, width: 2, inferred: false, source: 4, target: 6 },
{ weight: 7.524068083846899e-7, width: 2, inferred: false, source: 1, target: 24 },
{ weight: 0.00000647545523418574, width: 2, inferred: false, source: 22, target: 8 },
{ weight: 0.000005887870505895788, width: 2, inferred: false, source: 15, target: 10 },
{ weight: 8.428178658580805e-7, width: 2, inferred: false, source: 16, target: 14 },
{ weight: 4.0006658216459443e-7, width: 2, inferred: false, source: 1, target: 25 },
{ weight: 9.694642023468333e-7, width: 2, inferred: false, source: 1, target: 26 },
{ weight: 4.714506544331047e-7, width: 2, inferred: false, source: 3, target: 21 },
{ weight: 8.212604651861594e-7, width: 2, inferred: false, source: 16, target: 11 },
{ weight: 3.477810450648006e-7, width: 2, inferred: false, source: 16, target: 7 },
{ weight: 9.208171070957436e-8, width: 2, inferred: false, source: 3, target: 15 },
{ weight: 0.0000010905102327000433, width: 2, inferred: false, source: 4, target: 16 },
{ weight: 0.000014782307685187607, width: 2, inferred: false, source: 15, target: 9 },
],
urlTemplates: [
{
url:
'/app/kibana#/discover?_a=(columns%3A!(_source)%2Cindex%3A%2790943e30-9a47-11e8-b64d-95841ca0b247%27%2Cinterval%3Aauto%2Cquery%3A(language%3Akuery%2Cquery%3A{{gquery}})%2Csort%3A!(_score%2Cdesc))',
description: 'Raw documents',
isDefault: true,
encoderID: 'kql-loose',
},
],
exploreControls: {
useSignificance: true,
sampleSize: 2000,
timeoutMillis: 5000,
maxValuesPerDoc: 1,
minDocCount: 3,
},
indexPatternRefName: 'indexPattern_0',
};
export function registerLogsSampleData(sampleDataRegistry: SampleDataRegistrySetup) {
sampleDataRegistry.addSavedObjectsToSampleDataset(datasetId, [
{
type: 'graph-workspace',
id: 'e2141080-32fa-11ea-bbe4-818d9c786051',
version: '2',
attributes: {
title: 'Kibana Sample Data - Data Logs',
description:
'This is a sample graph based on the data logs index, which shows agents, extensions, source geography of the log, and response codes. The graph has 200 and 404 response codes blocked, as they have low cardinality.',
numLinks: 61,
numVertices: 27,
version: 1,
wsState: JSON.stringify(JSON.stringify(wsState)),
},
references: [
{
name: 'indexPattern_0',
type: 'index-pattern',
id: 'kibana_sample_data_logs',
},
],
migrationVersion: {
'graph-workspace': '7.0.0',
},
updated_at: '2020-01-09T16:40:36.122Z',
},
]);
}
export function registerLogsSampleDataLink(sampleDataRegistry: SampleDataRegistrySetup) {
sampleDataRegistry.addAppLinksToSampleDataset(datasetId, [
{
path: createWorkspacePath('e2141080-32fa-11ea-bbe4-818d9c786051'),
label: i18n.translate('xpack.graph.sampleData.label', { defaultMessage: 'Graph' }),
icon: APP_ICON,
},
]);
}

View file

@ -0,0 +1,36 @@
/*
* 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 { SampleDataRegistrySetup } from '../../../../../src/plugins/home/server';
import { registerLogsSampleData, registerLogsSampleDataLink } from './logs';
import { registerEcommerceSampleData, registerEcommerceSampleDataLink } from './ecommerce';
import { registerFlightsSampleData, registerFlightsSampleDataLink } from './flights';
import { LicenseState } from '../lib/license_state';
export function registerSampleData(
sampleDataRegistry: SampleDataRegistrySetup,
licenseState: LicenseState
) {
// always register the saved objects...
registerEcommerceSampleData(sampleDataRegistry);
registerFlightsSampleData(sampleDataRegistry);
registerLogsSampleData(sampleDataRegistry);
// but wait for a license actually supporting Graph to add links to the sample data panels
const licenseUpdates = licenseState.getLicenseInformation$();
if (licenseUpdates === null) {
throw new Error('License state has to be initialized before registering sample data');
}
let registered = false;
licenseUpdates.subscribe(licenseInformation => {
if (!registered && licenseInformation.showAppLink) {
registered = true;
registerEcommerceSampleDataLink(sampleDataRegistry);
registerFlightsSampleDataLink(sampleDataRegistry);
registerLogsSampleDataLink(sampleDataRegistry);
}
});
}