config_ctrl.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. const defaultMaxConcurrentShardRequests = this.current.jsonData.esVersion >= 70 ? 5 : 256;
  10. this.current.jsonData.maxConcurrentShardRequests =
  11. this.current.jsonData.maxConcurrentShardRequests || defaultMaxConcurrentShardRequests;
  12. }
  13. indexPatternTypes = [
  14. { name: 'No pattern', value: undefined },
  15. { name: 'Hourly', value: 'Hourly', example: '[logstash-]YYYY.MM.DD.HH' },
  16. { name: 'Daily', value: 'Daily', example: '[logstash-]YYYY.MM.DD' },
  17. { name: 'Weekly', value: 'Weekly', example: '[logstash-]GGGG.WW' },
  18. { name: 'Monthly', value: 'Monthly', example: '[logstash-]YYYY.MM' },
  19. { name: 'Yearly', value: 'Yearly', example: '[logstash-]YYYY' },
  20. ];
  21. esVersions = [
  22. { name: '2.x', value: 2 },
  23. { name: '5.x', value: 5 },
  24. { name: '5.6+', value: 56 },
  25. { name: '6.0+', value: 60 },
  26. { name: '7.0+', value: 70 },
  27. ];
  28. indexPatternTypeChanged() {
  29. if (
  30. !this.current.database ||
  31. this.current.database.length === 0 ||
  32. this.current.database.startsWith('[logstash-]')
  33. ) {
  34. const def: any = _.find(this.indexPatternTypes, {
  35. value: this.current.jsonData.interval,
  36. });
  37. this.current.database = def.example || 'es-index-name';
  38. }
  39. }
  40. }