grafana/public/app/plugins/datasource/elasticsearch/config_ctrl.ts

37 lines
1.3 KiB
TypeScript
Raw Normal View History

2017-12-20 19:33:33 +08:00
import _ from 'lodash';
export class ElasticConfigCtrl {
2017-12-20 19:33:33 +08:00
static templateUrl = 'public/app/plugins/datasource/elasticsearch/partials/config.html';
current: any;
/** @ngInject */
constructor($scope) {
this.current.jsonData.timeField = this.current.jsonData.timeField || '@timestamp';
2017-11-17 19:23:40 +08:00
this.current.jsonData.esVersion = this.current.jsonData.esVersion || 5;
this.current.jsonData.maxConcurrentShardRequests = this.current.jsonData.maxConcurrentShardRequests || 256;
}
indexPatternTypes = [
2017-12-20 19:33:33 +08:00
{ name: 'No pattern', value: undefined },
{ name: 'Hourly', value: 'Hourly', example: '[logstash-]YYYY.MM.DD.HH' },
{ name: 'Daily', value: 'Daily', example: '[logstash-]YYYY.MM.DD' },
{ name: 'Weekly', value: 'Weekly', example: '[logstash-]GGGG.WW' },
{ name: 'Monthly', value: 'Monthly', example: '[logstash-]YYYY.MM' },
{ name: 'Yearly', value: 'Yearly', example: '[logstash-]YYYY' },
];
esVersions = [
{ name: '2.x', value: 2 },
{ name: '5.x', value: 5 },
{ name: '5.6+', value: 56 },
{ name: '6.0+', value: 60 },
];
indexPatternTypeChanged() {
const def = _.find(this.indexPatternTypes, {
2017-12-20 19:33:33 +08:00
value: this.current.jsonData.interval,
});
2017-12-20 19:33:33 +08:00
this.current.database = def.example || 'es-index-name';
}
}