Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelhallmann committed Oct 7, 2016
2 parents 23e2ce1 + 9fe13ed commit bdf66fb
Show file tree
Hide file tree
Showing 99 changed files with 242 additions and 5,498 deletions.
32 changes: 8 additions & 24 deletions docs/getting-started.asciidoc
Expand Up @@ -6,7 +6,7 @@ key Kibana functionality. By the end of this tutorial, you will have:

* Loaded a sample data set into your Elasticsearch installation
* Defined at least one index pattern
* Use the <<discover, Discover>> functionality to explore your data
* Used the <<discover, Discover>> functionality to explore your data
* Set up some <<visualize,_visualizations_>> to graphically represent your data
* Assembled visualizations into a <<dashboard,Dashboard>>

Expand All @@ -27,14 +27,15 @@ The tutorials in this section rely on the following data sets:

* The complete works of William Shakespeare, suitably parsed into fields. Download this data set by clicking here:
https://www.elastic.co/guide/en/kibana/3.0/snippets/shakespeare.json[shakespeare.json].
* A set of fictitious accounts with randomly generated data, in CSV format. Download this data set by clicking here:
https://raw.githubusercontent.com/elastic/kibana/master/docs/tutorial/accounts.csv[accounts.csv]
* A set of fictitious accounts with randomly generated data. Download this data set by clicking here:
https://github.com/bly2k/files/blob/master/accounts.zip?raw=true[accounts.zip]
* A set of randomly generated log files. Download this data set by clicking here:
https://download.elastic.co/demos/kibana/gettingstarted/logs.jsonl.gz[logs.jsonl.gz]

Extract the logs with the following command:
Two of the data sets are compressed. Use the following commands to extract the files:

[source,shell]
unzip accounts.zip
gunzip logs.jsonl.gz

The Shakespeare data set is organized in the following schema:
Expand Down Expand Up @@ -81,8 +82,6 @@ field's searchability or whether or not it's _tokenized_, or broken up into sepa

Use the following command to set up a mapping for the Shakespeare data set:

=============
[source,shell]
curl -XPUT http://localhost:9200/shakespeare -d '
{
Expand All @@ -99,8 +98,6 @@ curl -XPUT http://localhost:9200/shakespeare -d '
}
';

=============

This mapping specifies the following qualities for the data set:

* The _speaker_ field is a string that isn't analyzed. The string in this field is treated as a single unit, even if
Expand Down Expand Up @@ -170,29 +167,16 @@ curl -XPUT http://localhost:9200/logstash-2015.05.20 -d '
}
';

At this point we're ready to use the Elasticsearch {ref}/docs-bulk.html[`bulk`] API to load the data sets with the
following commands:
The accounts data set doesn't require any mappings, so at this point we're ready to use the Elasticsearch
{ref}/docs-bulk.html[`bulk`] API to load the data sets with the following commands:

[source,shell]
curl -XPOST 'localhost:9200/bank/account/_bulk?pretty' --data-binary @accounts.json
curl -XPOST 'localhost:9200/shakespeare/_bulk?pretty' --data-binary @shakespeare.json
curl -XPOST 'localhost:9200/_bulk?pretty' --data-binary @logs.jsonl

These commands may take some time to execute, depending on the computing resources available.

To load the Accounts data set, click the *Management* image:images/SettingsButton.jpg[gear icon] tab, the
select *Upload CSV*.

image::images/management-panel.png[kibana management panel]

Click *Select File*, then navigate to the `accounts.csv` file. Review the sample, then click *Next*.

image::images/csv-sample.png[sample csv import]

Review the index pattern built by the CSV import function. You can change any field types from the drop-downs, but for
this tutorial, accept the defaults. Enter `bank` as the name for the index pattern, then click *Save*.

image::images/sample-index.png[sample index pattern]

Verify successful loading with the following command:

[source,shell]
Expand Down
Binary file removed docs/images/csv-sample.png
Binary file not shown.
Binary file removed docs/images/management-panel.png
Binary file not shown.
Binary file removed docs/images/sample-index.png
Binary file not shown.
1 change: 0 additions & 1 deletion docs/kibana-yml.asciidoc
Expand Up @@ -15,7 +15,6 @@ to this Kibana instance.
`kibana.index:`:: *Default: ".kibana"* Kibana uses an index in Elasticsearch to store saved searches, visualizations and
dashboards. Kibana creates a new index if the index doesn’t already exist.
`kibana.defaultAppId:`:: *Default: "discover"* The default application to load.
`kibana.addDataMaxBytes:`:: *Default: 1073741824* The maximum upload size in bytes for the CSV Upload wizard
[[tilemap-settings]]`tilemap.url:`:: *Default: `"https://tiles.elastic.co/v1/default/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana"`* The URL to the tile
service that Kibana uses to display map tiles in tilemap visualizations.
`tilemap.options.minZoom:`:: *Default: 1* The minimum zoom level.
Expand Down
1,001 changes: 0 additions & 1,001 deletions docs/tutorial/accounts.csv

This file was deleted.

3 changes: 0 additions & 3 deletions package.json
Expand Up @@ -97,7 +97,6 @@
"bunyan": "1.7.1",
"commander": "2.8.1",
"css-loader": "0.17.0",
"csv-parse": "1.1.0",
"d3": "3.5.6",
"dragula": "3.7.0",
"elasticsearch": "12.0.0-rc5",
Expand All @@ -116,7 +115,6 @@
"gridster": "0.5.6",
"h2o2": "5.1.1",
"hapi": "14.2.0",
"highland": "2.7.2",
"httpolyglot": "0.1.1",
"imports-loader": "0.6.4",
"inert": "4.0.2",
Expand All @@ -139,7 +137,6 @@
"moment-timezone": "0.5.4",
"node-fetch": "1.3.2",
"node-uuid": "1.4.7",
"papaparse": "4.1.2",
"pegjs": "0.9.0",
"querystring-browser": "1.0.4",
"raw-loader": "0.5.1",
Expand Down
1 change: 0 additions & 1 deletion src/cli/serve/serve.js
Expand Up @@ -39,7 +39,6 @@ function readServerSettings(opts, extraCliOptions) {
set('env', 'development');
set('optimize.lazy', true);
if (opts.ssl && !has('server.ssl.cert') && !has('server.ssl.key')) {
set('server.host', 'localhost');
set('server.ssl.cert', DEV_SSL_CERT_PATH);
set('server.ssl.key', DEV_SSL_KEY_PATH);
}
Expand Down
Expand Up @@ -3,7 +3,6 @@ import { useResizeCheckerProvider } from '../sense_editor_resize';
import $ from 'jquery';
import { initializeInput } from '../input';
import { initializeOutput } from '../output';
import es from '../es';
import init from '../app';
import { SenseTopNavController } from './sense_top_nav_controller';

Expand All @@ -20,7 +19,7 @@ module.run(function (Private, $rootScope) {
module.controller('SenseController', function SenseController(Private, $scope, $timeout, $location, docTitle) {
docTitle.change('Console');

$scope.topNavController = Private(SenseTopNavController)
$scope.topNavController = Private(SenseTopNavController);

// We need to wait for these elements to be rendered before we can select them with jQuery
// and then initialize this app
Expand Down
12 changes: 11 additions & 1 deletion src/core_plugins/console/public/src/directives/sense_settings.js
Expand Up @@ -7,7 +7,7 @@ require('ui/modules')
restrict: 'E',
template: require('./settings.html'),
controllerAs: 'settings',
controller: function ($scope) {
controller: function ($scope, $element) {
const settings = require('../settings');

this.vals = settings.getCurrentSettings();
Expand All @@ -16,6 +16,16 @@ require('ui/modules')
$scope.kbnTopNav.close();
};

const self = this;

function onEnter(event) {
if (event.which === 13) {
self.apply();
}
}

const boundElement = $element.bind('keydown', onEnter);
$scope.$on('$destroy', () => boundElement.unbind('keydown', onEnter));
},
};
});
91 changes: 71 additions & 20 deletions src/core_plugins/elasticsearch/lib/__tests__/map_uri.js
@@ -1,12 +1,23 @@
import expect from 'expect.js';
import mapUri from '../map_uri';
import { get, defaults } from 'lodash';
import sinon from 'sinon';

describe('plugins/elasticsearch', function () {
describe('lib/map_uri', function () {

let request;

function stubServer(settings) {
const values = defaults(settings || {}, {
'elasticsearch.url': 'http://localhost:9200',
'elasticsearch.requestHeadersWhitelist': ['authorization'],
'elasticsearch.customHeaders': {}
});
const config = { get: (key, def) => get(values, key, def) };
return { config: () => config };
}

beforeEach(function () {
request = {
path: '/elasticsearch/some/path',
Expand All @@ -23,10 +34,9 @@ describe('plugins/elasticsearch', function () {
});

it('sends custom headers if set', function () {
const get = sinon.stub();
get.withArgs('elasticsearch.requestHeadersWhitelist').returns([]);
get.withArgs('elasticsearch.customHeaders').returns({ foo: 'bar' });
const server = { config: () => ({ get }) };
const server = stubServer({
'elasticsearch.customHeaders': { foo: 'bar' }
});

mapUri(server)(request, function (err, upstreamUri, upstreamHeaders) {
expect(err).to.be(null);
Expand All @@ -35,10 +45,10 @@ describe('plugins/elasticsearch', function () {
});

it('sends configured custom headers even if the same named header exists in request', function () {
const get = sinon.stub();
get.withArgs('elasticsearch.requestHeadersWhitelist').returns(['x-my-custom-header']);
get.withArgs('elasticsearch.customHeaders').returns({'x-my-custom-header': 'asconfigured'});
const server = { config: () => ({ get }) };
const server = stubServer({
'elasticsearch.requestHeadersWhitelist': ['x-my-custom-header'],
'elasticsearch.customHeaders': {'x-my-custom-header': 'asconfigured'}
});

mapUri(server)(request, function (err, upstreamUri, upstreamHeaders) {
expect(err).to.be(null);
Expand All @@ -47,10 +57,9 @@ describe('plugins/elasticsearch', function () {
});

it('only proxies the whitelisted request headers', function () {
const get = sinon.stub();
get.withArgs('elasticsearch.requestHeadersWhitelist').returns(['x-my-custom-HEADER', 'Authorization']);
get.withArgs('elasticsearch.customHeaders').returns({});
const server = { config: () => ({ get }) };
const server = stubServer({
'elasticsearch.requestHeadersWhitelist': ['x-my-custom-HEADER', 'Authorization'],
});

mapUri(server)(request, function (err, upstreamUri, upstreamHeaders) {
expect(err).to.be(null);
Expand All @@ -61,10 +70,9 @@ describe('plugins/elasticsearch', function () {
});

it('proxies no headers if whitelist is set to []', function () {
const get = sinon.stub();
get.withArgs('elasticsearch.requestHeadersWhitelist').returns([]);
get.withArgs('elasticsearch.customHeaders').returns({});
const server = { config: () => ({ get }) };
const server = stubServer({
'elasticsearch.requestHeadersWhitelist': [],
});

mapUri(server)(request, function (err, upstreamUri, upstreamHeaders) {
expect(err).to.be(null);
Expand All @@ -73,16 +81,59 @@ describe('plugins/elasticsearch', function () {
});

it('proxies no headers if whitelist is set to no value', function () {
const get = sinon.stub();
get.withArgs('elasticsearch.requestHeadersWhitelist').returns([ null ]); // This is how Joi returns it
get.withArgs('elasticsearch.customHeaders').returns({});
const server = { config: () => ({ get }) };
const server = stubServer({
// joi converts `elasticsearch.requestHeadersWhitelist: null` into
// an array with a null inside because of the `array().single()` rule.
'elasticsearch.requestHeadersWhitelist': [ null ],
});

mapUri(server)(request, function (err, upstreamUri, upstreamHeaders) {
expect(err).to.be(null);
expect(Object.keys(upstreamHeaders).length).to.be(0);
});
});

it('strips the /elasticsearch prefix from the path', () => {
request.path = '/elasticsearch/es/path';
const server = stubServer();

mapUri(server)(request, function (err, upstreamUri, upstreamHeaders) {
expect(err).to.be(null);
expect(upstreamUri).to.be('http://localhost:9200/es/path');
});
});

it('extends the es.url path', function () {
request.path = '/elasticsearch/index/type';
const server = stubServer({ 'elasticsearch.url': 'https://localhost:9200/base-path' });

mapUri(server)(request, function (err, upstreamUri, upstreamHeaders) {
expect(err).to.be(null);
expect(upstreamUri).to.be('https://localhost:9200/base-path/index/type');
});
});

it('extends the es.url query string', function () {
request.path = '/elasticsearch/*';
request.query = { foo: 'bar' };
const server = stubServer({ 'elasticsearch.url': 'https://localhost:9200/?base=query' });

mapUri(server)(request, function (err, upstreamUri, upstreamHeaders) {
expect(err).to.be(null);
expect(upstreamUri).to.be('https://localhost:9200/*?foo=bar&base=query');
});
});

it('filters the _ querystring param', function () {
request.path = '/elasticsearch/*';
request.query = { _: Date.now() };
const server = stubServer();

mapUri(server)(request, function (err, upstreamUri, upstreamHeaders) {
expect(err).to.be(null);
expect(upstreamUri).to.be('http://localhost:9200/*');
});
});

});
});
18 changes: 12 additions & 6 deletions src/core_plugins/elasticsearch/lib/__tests__/routes.js
Expand Up @@ -38,12 +38,18 @@ describe('plugins/elasticsearch', function () {
describe(format('%s %s', options.method, options.url), function () {
it('should should return ' + statusCode, function (done) {
kbnTestServer.makeRequest(kbnServer, options, function (res) {
try {
expect(res.statusCode).to.be(statusCode);
if (res.statusCode === statusCode) {
done();
} catch (e) {
done(e);
return;
}

done(new Error(`
Invalid response code from elasticseach:
${res.statusCode} should be ${statusCode}
Response:
${res.payload}
`));
});
});
});
Expand Down Expand Up @@ -93,13 +99,13 @@ describe('plugins/elasticsearch', function () {

testRoute({
method: 'POST',
url: '/elasticsearch/_mget?timeout=0&ignore_unavailable=true&preference=1429574531063',
url: '/elasticsearch/_mget',
payload: {docs: [{_index: '.kibana', _type: 'index-pattern', _id: '[logstash-]YYYY.MM.DD'}]}
});

testRoute({
method: 'POST',
url: '/elasticsearch/_msearch?timeout=0&ignore_unavailable=true&preference=1429577952339',
url: '/elasticsearch/_msearch',
payload: '{"index":"logstash-2015.04.21","ignore_unavailable":true}\n{"size":500,"sort":{"@timestamp":"desc"},"query":{"bool":{"must":[{"query_string":{"analyze_wildcard":true,"query":"*"}},{"bool":{"must":[{"range":{"@timestamp":{"gte":1429577068175,"lte":1429577968175}}}],"must_not":[]}}],"must_not":[]}},"highlight":{"pre_tags":["@kibana-highlighted-field@"],"post_tags":["@/kibana-highlighted-field@"],"fields":{"*":{}}},"aggs":{"2":{"date_histogram":{"field":"@timestamp","interval":"30s","min_doc_count":0,"extended_bounds":{"min":1429577068175,"max":1429577968175}}}},"stored_fields":["*"],"_source": true,"script_fields":{},"docvalue_fields":["timestamp_offset","@timestamp","utc_time"]}\n' // eslint-disable-line max-len
});

Expand Down

0 comments on commit bdf66fb

Please sign in to comment.