Skip to content

Commit

Permalink
Merge branch '7.5' into backport/7.5/pr-50141
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Nov 12, 2019
2 parents 718c205 + bdfe2df commit 4beeaee
Show file tree
Hide file tree
Showing 19 changed files with 517 additions and 65 deletions.
7 changes: 4 additions & 3 deletions docs/getting-started/tutorial-dashboard.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
=== Add visualizations to a dashboard

A dashboard is a collection of visualizations that you can arrange and share.
You'll build a dashboard that contains the visualizations you saved during
You'll build a dashboard that contains the visualizations and map that you saved during
this tutorial.

. Open *Dashboard*.
. On the Dashboard overview page, click *Create new dashboard*.
. Set the time filter to May 18, 2015 to May 20, 2015.
. Click *Add* in the menu bar.
. Add *Bar Example*, *Map Example*, *Markdown Example*, and *Pie Example*.
+
Expand All @@ -26,12 +27,12 @@ is on the lower right.

==== Inspect the data

Seeing visualizations of your data is great,
Seeing visualizations of your data is great,
but sometimes you need to look at the actual data to
understand what's really going on. You can inspect the data behind any visualization
and view the {es} query used to retrieve it.

. In the dashboard, hover the pointer over the pie chart, and then click the icon in the upper right.
. In the dashboard, hover the pointer over the pie chart, and then click the icon in the upper right.
. From the *Options* menu, select *Inspect*.
+
[role="screenshot"]
Expand Down
76 changes: 40 additions & 36 deletions docs/getting-started/tutorial-visualizing.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

In the Visualize application, you can shape your data using a variety
of charts, tables, and maps, and more. In this tutorial, you'll create four
visualizations:
visualizations:

* <<tutorial-visualize-pie, Pie chart>>
* <<tutorial-visualize-bar, Bar chart>>
* <<tutorial-visualize-map, Coordinate map>>
* <<tutorial-visualize-map, Map>>
* <<tutorial-visualize-markdown, Markdown widget>>

[float]
Expand All @@ -25,7 +25,7 @@ types in Kibana.
image::images/tutorial-visualize-wizard-step-1.png[]
. Click *Pie*.

. In *Choose a source*, select the `ba*` index pattern.
. In *Choose a source*, select the `ba*` index pattern.
+
Initially, the pie contains a single "slice."
That's because the default search matched all documents.
Expand Down Expand Up @@ -76,7 +76,7 @@ in a ring around the balance ranges.
[role="screenshot"]
image::images/tutorial-visualize-pie-3.png[]

. To save this chart so you can use it later, click *Save* in
. To save this chart so you can use it later, click *Save* in
the top menu bar and enter `Pie Example`.

[float]
Expand Down Expand Up @@ -123,29 +123,56 @@ you did at the beginning of the tutorial, when you marked the `play_name` field
as `not analyzed`.

[float]
[[tutorial-visualize-map]]
=== Coordinate map
[[tutorial-visualize-markdown]]
=== Markdown

Using a coordinate map, you can visualize geographic information in the log file sample data.
Create a Markdown widget to add formatted text to your dashboard.

. Create a *Markdown* visualization.
. Copy the following text into the text box.
+
[source,markdown]
# This is a tutorial dashboard!
The Markdown widget uses **markdown** syntax.
> Blockquotes in Markdown use the > character.

. Create a *Coordinate map* and set the search source to `logstash*`.
. Click *Apply changes* image:images/apply-changes-button.png[].
+
You haven't defined any buckets yet, so the visualization is a map of the world.
The Markdown renders in the preview pane.
+
[role="screenshot"]
image::images/tutorial-visualize-md-2.png[]

. *Save* this visualization with the name `Markdown Example`.

[float]
[[tutorial-visualize-map]]
=== Map

Using <<maps>>, you can visualize geographic information in the log file sample data.

. Click *Maps* in the New Visualization
menu to create a Map.

. Set the time.
.. In the time filter, click *Show dates*.
.. Click the start date, then *Absolute*.
.. Set the *Start date* to May 18, 2015.
.. In the time filter, click *now*, then *Absolute*.
.. Set the *End date* to May 20, 2015.
.. Click *Update*

. Map the geo coordinates from the log files.

.. In the *Buckets* pane, click *Add > Geo coordinates*.
.. Set *Aggregation* to *Geohash*.
.. Set *Field* to *geo.coordinates*.
.. Click *Add layer*.
.. Click the *Grid aggregation* data source.
.. Set *Index pattern* to *logstash*.
.. Click the *Add layer* button.

. Click *Apply changes* image:images/apply-changes-button.png[].
. Set the layer style.
.. For *Fill color*, select the yellow to red color ramp.
.. For *Border color*, select white.
.. Click *Save & close*.
+
The map now looks like this:
+
Expand All @@ -155,26 +182,3 @@ image::images/tutorial-visualize-map-2.png[]
. Navigate the map by clicking and dragging. Use the controls
on the left to zoom the map and set filters.
. *Save* this map with the name `Map Example`.

[float]
[[tutorial-visualize-markdown]]
=== Markdown

The final visualization is a Markdown widget that renders formatted text.

. Create a *Markdown* visualization.
. Copy the following text into the text box.
+
[source,markdown]
# This is a tutorial dashboard!
The Markdown widget uses **markdown** syntax.
> Blockquotes in Markdown use the > character.

. Click *Apply changes* image:images/apply-changes-button.png[].
+
The Markdown renders in the preview pane.
+
[role="screenshot"]
image::images/tutorial-visualize-md-2.png[]

. *Save* this visualization with the name `Markdown Example`.
Binary file modified docs/images/tutorial-visualize-map-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/maps/maps-getting-started.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ the {es} index `kibana_sample_data_logs` on the shared key iso2 = geo.src.
. Set *Right source* to *kibana_sample_data_logs*.
. Set *Right field* to *geo.src*.

===== Set the vector style
===== Set the layer style

All of the world countries are still a single color because the layer is using <<maps-vector-style-static, static styling>>.
To shade the world countries based on which country is sending the most requests, you'll need to use <<maps-vector-style-data-driven, data driven styling>>.
Expand Down Expand Up @@ -161,9 +161,9 @@ image::maps/images/grid_metrics_both.png[]
. Select *Sum* in the aggregation select.
. Select *bytes* in the field select.

===== Set the vector style
===== Set the layer style

. In *Vector style*, change *Symbol size*:
. In *Layer style*, change *Symbol size*:
.. Set *Min size* to 1.
.. Set *Max size* to 25.
.. In the field select, select *sum of bytes*.
Expand Down
52 changes: 47 additions & 5 deletions src/legacy/core_plugins/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

import * as Rx from 'rxjs';
import { resolve } from 'path';
import JoiNamespace from 'joi';
import { Server } from 'hapi';
Expand Down Expand Up @@ -45,6 +46,14 @@ const telemetry = (kibana: any) => {
config(Joi: typeof JoiNamespace) {
return Joi.object({
enabled: Joi.boolean().default(true),
optIn: Joi.when('allowChangingOptInStatus', {
is: false,
then: Joi.valid(true),
otherwise: Joi.boolean()
.allow(null)
.default(null),
}),
allowChangingOptInStatus: Joi.boolean().default(true),
// `config` is used internally and not intended to be set
config: Joi.string().default(Joi.ref('$defaultConfigPath')),
banner: Joi.boolean().default(true),
Expand Down Expand Up @@ -80,8 +89,25 @@ const telemetry = (kibana: any) => {
},
},
async replaceInjectedVars(originalInjectedVars: any, request: any) {
const config = request.server.config();
const optIn = config.get('telemetry.optIn');
const allowChangingOptInStatus = config.get('telemetry.allowChangingOptInStatus');
const currentKibanaVersion = getCurrentKibanaVersion(request.server);
const telemetryOptedIn = await getTelemetryOptIn({ request, currentKibanaVersion });
let telemetryOptedIn: boolean | null;

if (typeof optIn === 'boolean' && !allowChangingOptInStatus) {
// When not allowed to change optIn status and an optIn value is set, we'll overwrite with that
telemetryOptedIn = optIn;
} else {
telemetryOptedIn = await getTelemetryOptIn({
request,
currentKibanaVersion,
});
if (telemetryOptedIn === null) {
// In the senario there's no value set in telemetryOptedIn, we'll return optIn value
telemetryOptedIn = optIn;
}
}

return {
...originalInjectedVars,
Expand All @@ -93,28 +119,44 @@ const telemetry = (kibana: any) => {
return {
telemetryEnabled: getXpackConfigWithDeprecated(config, 'telemetry.enabled'),
telemetryUrl: getXpackConfigWithDeprecated(config, 'telemetry.url'),
telemetryBanner: getXpackConfigWithDeprecated(config, 'telemetry.banner'),
telemetryOptedIn: null,
telemetryBanner:
config.get('telemetry.allowChangingOptInStatus') !== false &&
getXpackConfigWithDeprecated(config, 'telemetry.banner'),
telemetryOptedIn: config.get('telemetry.optIn'),
allowChangingOptInStatus: config.get('telemetry.allowChangingOptInStatus'),
};
},
hacks: ['plugins/telemetry/hacks/telemetry_init', 'plugins/telemetry/hacks/telemetry_opt_in'],
mappings,
},
init(server: Server) {
async init(server: Server) {
const initializerContext = {
env: {
packageInfo: {
version: getCurrentKibanaVersion(server),
},
},
config: {
create() {
const config = server.config();
return Rx.of({
enabled: config.get('telemetry.enabled'),
optIn: config.get('telemetry.optIn'),
config: config.get('telemetry.config'),
banner: config.get('telemetry.banner'),
url: config.get('telemetry.url'),
allowChangingOptInStatus: config.get('telemetry.allowChangingOptInStatus'),
});
},
},
} as PluginInitializerContext;

const coreSetup = ({
http: { server },
log: server.log,
} as any) as CoreSetup;

telemetryPlugin(initializerContext).setup(coreSetup);
await telemetryPlugin(initializerContext).setup(coreSetup);

// register collectors
server.usage.collectorSet.register(createLocalizationUsageCollector(server));
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export class TelemetryForm extends Component {
queryMatches,
} = this.state;

if (!telemetryOptInProvider.canChangeOptInStatus()) {
return null;
}

if (queryMatches !== null && !queryMatches) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import '../services/telemetry_opt_in.test.mocks';
import { mockInjectedMetadata } from '../services/telemetry_opt_in.test.mocks';
import React from 'react';
import { shallowWithIntl } from 'test_utils/enzyme_helpers';
import { TelemetryForm } from './telemetry_form';
Expand All @@ -33,6 +33,8 @@ const buildTelemetryOptInProvider = () => {
switch (key) {
case '$http':
return mockHttp;
case 'allowChangingOptInStatus':
return true;
default:
return null;
}
Expand All @@ -47,7 +49,23 @@ const buildTelemetryOptInProvider = () => {
};

describe('TelemetryForm', () => {
it('renders as expected', () => {
it('renders as expected when allows to change optIn status', () => {
mockInjectedMetadata({ telemetryOptedIn: null, allowChangingOptInStatus: true });

expect(shallowWithIntl(
<TelemetryForm
spacesEnabled={false}
query={{ text: '' }}
onQueryMatchChange={jest.fn()}
telemetryOptInProvider={buildTelemetryOptInProvider()}
enableSaving={true}
/>)
).toMatchSnapshot();
});

it(`doesn't render form when not allowed to change optIn status`, () => {
mockInjectedMetadata({ telemetryOptedIn: null, allowChangingOptInStatus: false });

expect(shallowWithIntl(
<TelemetryForm
spacesEnabled={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('click_banner', () => {

const optIn = true;
const bannerId = 'bruce-banner';
mockInjectedMetadata({ telemetryOptedIn: optIn });
mockInjectedMetadata({ telemetryOptedIn: optIn, allowChangingOptInStatus: true });
const telemetryOptInProvider = getTelemetryOptInProvider();

telemetryOptInProvider.setBannerId(bannerId);
Expand All @@ -92,7 +92,7 @@ describe('click_banner', () => {
remove: sinon.spy()
};
const optIn = true;
mockInjectedMetadata({ telemetryOptedIn: null });
mockInjectedMetadata({ telemetryOptedIn: null, allowChangingOptInStatus: true });
const telemetryOptInProvider = getTelemetryOptInProvider({ simulateFailure: true });

await clickBanner(telemetryOptInProvider, optIn, { _banners: banners, _toastNotifications: toastNotifications });
Expand All @@ -110,7 +110,7 @@ describe('click_banner', () => {
remove: sinon.spy()
};
const optIn = false;
mockInjectedMetadata({ telemetryOptedIn: null });
mockInjectedMetadata({ telemetryOptedIn: null, allowChangingOptInStatus: true });
const telemetryOptInProvider = getTelemetryOptInProvider({ simulateError: true });

await clickBanner(telemetryOptInProvider, optIn, { _banners: banners, _toastNotifications: toastNotifications });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const getTelemetryOptInProvider = (enabled, { simulateFailure = false } = {}) =>
const chrome = {
addBasePath: url => url
};
mockInjectedMetadata({ telemetryOptedIn: enabled });
mockInjectedMetadata({ telemetryOptedIn: enabled, allowChangingOptInStatus: true });

const $injector = {
get: (key) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const getMockInjector = () => {
};

const getTelemetryOptInProvider = ({ telemetryOptedIn = null } = {}) => {
mockInjectedMetadata({ telemetryOptedIn });
mockInjectedMetadata({ telemetryOptedIn, allowChangingOptInStatus: true });
const injector = getMockInjector();
const chrome = {
addBasePath: (url) => url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('TelemetryOptInProvider', () => {
addBasePath: (url) => url
};

mockInjectedMetadata({ telemetryOptedIn: optedIn });
mockInjectedMetadata({ telemetryOptedIn: optedIn, allowChangingOptInStatus: true });

const mockInjector = {
get: (key) => {
Expand Down
Loading

0 comments on commit 4beeaee

Please sign in to comment.