config_ctrl.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import _ from 'lodash';
  2. export class ElasticConfigCtrl {
  3. static templateUrl = 'public/app/plugins/datasource/elasticsearch/partials/config.html';
  4. current: any;
  5. /** @ngInject */
  6. constructor($scope) {
  7. this.current.jsonData.timeField = this.current.jsonData.timeField || '@timestamp';
  8. this.current.jsonData.esVersion = this.current.jsonData.esVersion || 5;
  9. this.current.jsonData.maxConcurrentShardRequests = this.current.jsonData.maxConcurrentShardRequests || 256;
  10. }
  11. indexPatternTypes = [
  12. { name: 'No pattern', value: undefined },
  13. { name: 'Hourly', value: 'Hourly', example: '[logstash-]YYYY.MM.DD.HH' },
  14. { name: 'Daily', value: 'Daily', example: '[logstash-]YYYY.MM.DD' },
  15. { name: 'Weekly', value: 'Weekly', example: '[logstash-]GGGG.WW' },
  16. { name: 'Monthly', value: 'Monthly', example: '[logstash-]YYYY.MM' },
  17. { name: 'Yearly', value: 'Yearly', example: '[logstash-]YYYY' },
  18. ];
  19. esVersions = [
  20. { name: '2.x', value: 2 },
  21. { name: '5.x', value: 5 },
  22. { name: '5.6+', value: 56 },
  23. { name: '6.0+', value: 60 },
  24. ];
  25. indexPatternTypeChanged() {
  26. if (!this.current.database ||
  27. this.current.database.length === 0 ||
  28. this.current.database.startsWith('[logstash-]')) {
  29. const def = _.find(this.indexPatternTypes, {
  30. value: this.current.jsonData.interval,
  31. });
  32. this.current.database = def.example || 'es-index-name';
  33. }
  34. }
  35. }