Make CSV upload limit configurable

Kibana's Upload CSV feature isn't intended for gigantic import jobs, so
I originally set a sane default of 1GB. Some users exprssed a desire to
import slightly larger files, they should be able to import something
that's 1.1GB without being blocked by an arbitrary limit. So I've made
the limit configurable via kibana.yml.

This change includes a few pieces:
* Added optional `kibana.addDataMaxBytes` key to kibana.yml with 1GB
  default
* Set upload data route payload limit based on new config value
* Updated help text in UI to use the dynamic config value on the parse
  csv page
* Updated parse csv page to check file size and fail early if the
  selected file is too big

Resolves: https://github.com/elastic/kibana/issues/7671
This commit is contained in:
Matthew Bargar 2016-09-12 14:13:44 -04:00
parent 4f940ee989
commit 0503aa8a31
5 changed files with 22 additions and 7 deletions

View file

@ -14,6 +14,7 @@ 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 doesnt 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.

View file

@ -14,10 +14,13 @@ module.exports = function (kibana) {
return new kibana.Plugin({
id: 'kibana',
config: function (Joi) {
const ONE_GIGABYTE = 1024 * 1024 * 1024;
return Joi.object({
enabled: Joi.boolean().default(true),
defaultAppId: Joi.string().default('discover'),
index: Joi.string().default('.kibana')
index: Joi.string().default('.kibana'),
addDataMaxBytes: Joi.number().default(ONE_GIGABYTE)
}).default();
},
@ -41,7 +44,8 @@ module.exports = function (kibana) {
let config = server.config();
return {
kbnDefaultAppId: config.get('kibana.defaultAppId'),
tilemap: config.get('tilemap')
tilemap: config.get('tilemap'),
addDataMaxBytes: config.get('kibana.addDataMaxBytes')
};
},
},

View file

@ -9,7 +9,7 @@
<button class="btn btn-primary btn-lg controls upload" ng-click>
Select File
</button>
<div>Maximum upload file size: 1 GB</div>
<div>Maximum upload file size: {{ wizard.maxBytesFormatted }}</div>
</div>
</file-upload>

View file

@ -4,9 +4,10 @@ import modules from 'ui/modules';
import validateHeaders from './lib/validate_headers';
import template from './parse_csv_step.html';
import './styles/_add_data_parse_csv_step.less';
import numeral from '@spalger/numeral';
modules.get('apps/management')
.directive('parseCsvStep', function () {
.directive('parseCsvStep', function (addDataMaxBytes) {
return {
restrict: 'E',
template: template,
@ -21,6 +22,8 @@ modules.get('apps/management')
const maxSampleRows = 10;
const maxSampleColumns = 20;
this.maxBytesFormatted = numeral(addDataMaxBytes).format('0 b');
this.delimiterOptions = [
{
label: 'comma',
@ -55,6 +58,13 @@ modules.get('apps/management')
this.formattedErrors = [];
this.formattedWarnings = [];
if (this.file.size > addDataMaxBytes) {
this.formattedErrors.push(
`File size (${this.file.size} bytes) is greater than the configured limit of ${addDataMaxBytes} bytes`
);
return;
}
const config = _.assign(
{
header: true,

View file

@ -6,16 +6,16 @@ import { patternToIngest } from '../../../../common/lib/convert_pattern_and_inge
import { PassThrough } from 'stream';
import JSONStream from 'JSONStream';
const ONE_GIGABYTE = 1024 * 1024 * 1024;
export function registerData(server) {
const maxBytes = server.config().get('kibana.addDataMaxBytes');
server.route({
path: '/api/kibana/{id}/_data',
method: 'POST',
config: {
payload: {
output: 'stream',
maxBytes: ONE_GIGABYTE
maxBytes
}
},
handler: function (req, reply) {