iguazio.dashboard-controls 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iguazio.dashboard-controls",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "main": "dist/js/iguazio.dashboard-controls.js",
5
5
  "description": "Collection of resources (such as CSS styles, fonts and images) and AngularJs 1.x components and services to share among different Iguazio repos.",
6
6
  "repository": {
@@ -169,6 +169,7 @@
169
169
  "LOGGER_DESTINATION": "Logger destination",
170
170
  "LOGGER_LEVEL": "Logger level",
171
171
  "LOGGING": "Logging",
172
+ "LOGS_LINES_LIMITATION": "Note: Only the last 10,000 rows are displayed. <br> To download up to 100,000 rows, click on the 'Download' button.",
172
173
  "MAX": "Max",
173
174
  "MAX_REPLICAS": "Maximum number of replicas (default: {{default}})",
174
175
  "MAX_WORKERS": "Max Workers",
@@ -53,7 +53,7 @@
53
53
  if (queryParams.timeFrame) {
54
54
  searchFrom = 'now-' + queryParams.timeFrame;
55
55
  } else {
56
- searchFrom = lodash.get(queryParams, 'customTimeFrame.from', '1970-01-01T00:00:00Z');
56
+ searchFrom = lodash.get(queryParams, 'customTimeFrame.from');
57
57
  searchTo = lodash.get(queryParams, 'customTimeFrame.to', 'now');
58
58
  }
59
59
  }
@@ -114,10 +114,6 @@
114
114
  });
115
115
  }
116
116
 
117
- if (queryParams.trackTotalHits) {
118
- config.track_total_hits = true;
119
- }
120
-
121
117
  return ElasticsearchService.search(config)
122
118
  .then(function (response) {
123
119
  // Saved log entry can be found in `_source` property
@@ -147,44 +143,47 @@
147
143
 
148
144
  /**
149
145
  * Collects all the logs using chunks, and saved them as an array of strings.
150
- * @returns {Promise.<Array.<Object>>} a promise resolving to an array of logs.
146
+ * @param {Object} queryParams - additional parameters
147
+ * @param {string} queryParams.query - search query text
148
+ * @param {string} queryParams.timeFrame - selected time period to show results for
149
+ * @param {string} [queryParams.lastEntryTimestamp] - time stamp of the last item in a list, used with auto
150
+ * @returns {Promise.<Array>} a promise resolving to an array of logs.
151
151
  */
152
- function collectLogs(query) {
152
+ function collectLogs(queryParams) {
153
153
  var keepAlive = '5m';
154
154
  var size = 10000;
155
155
  var downloadLogsData = [];
156
- var createPitConfig = {
157
- index: 'filebeat*',
158
- keepAlive: keepAlive
159
- };
156
+ var MAX_DOWNLOAD_LOGS = 100000;
160
157
 
161
- return ElasticSearchDataService.createPit(createPitConfig).then(function (pitId) {
162
- return getNextPitLogs(pitId, null);
158
+ return ElasticSearchDataService.createPit(keepAlive).then(function (pitId) {
159
+ return getNextChunk(pitId, null);
163
160
  });
164
161
 
165
- function getNextPitLogs(pitId, searchAfter) {
166
- return ElasticSearchDataService.getNextPitLogs(size, query, keepAlive, pitId, searchAfter).then(function (response) {
167
- var hits = response.hits.hits;
162
+ function getNextChunk(pit, searchAfter) {
163
+ return getNextPitLogs(size, queryParams, keepAlive, pit, searchAfter)
164
+ .then(function (response) {
165
+ var hits = response.hits.hits;
168
166
 
169
- if (hits.length > 0) {
170
- var lastHit = lodash.last(hits);
167
+ if (hits.length > 0 && downloadLogsData.length < MAX_DOWNLOAD_LOGS - size) {
168
+ var lastHit = lodash.last(hits);
171
169
 
172
- downloadLogsData = downloadLogsData.concat(prepareLogs(hits));
170
+ downloadLogsData = downloadLogsData.concat(prepareLogs(hits));
173
171
 
174
- return getNextPitLogs(response.pit_id, lastHit.sort)
175
- } else {
176
- return downloadLogsData;
177
- }
178
- }).catch(function (error) {
179
- throw error;
180
- });
172
+ return getNextChunk(response.pit_id, lastHit.sort);
173
+ } else {
174
+ return downloadLogsData;
175
+ }
176
+ }).catch(function (error) {
177
+ throw error;
178
+ });
181
179
  }
182
180
 
183
181
  function prepareLogs(logs) {
184
182
  return logs.map(function (logData) {
185
183
  var log = lodash.get(logData, '_source', {});
184
+ var level = log.level ? ' (' + log.level + ') ' : '';
186
185
 
187
- return log['@timestamp'] + ' ' + log.name + ' (' + log.level + ') ' +
186
+ return log['@timestamp'] + ' ' + log.name + level +
188
187
  lodash.get(log, 'message', '') + ' ' + JSON.stringify(lodash.get(log, 'more', {}));
189
188
  });
190
189
  }
@@ -238,8 +237,8 @@
238
237
  'nuclio-tutorial-normal-user-model-monitoring-controller-6c4gfcv'
239
238
  ];
240
239
 
241
- logs.total_pages = 30000 / perPage;
242
- logs.total_logs_count = 30000;
240
+ logs.total_pages = 10000 / perPage;
241
+ logs.total_logs_count = 10000;
243
242
 
244
243
  if (withReplicas) {
245
244
  logs.replicas = replicas;
@@ -249,5 +248,71 @@
249
248
 
250
249
  return $q.when(logs);
251
250
  }
251
+
252
+ /**
253
+ * Gets next part of the logs using Pit Id and search after parameters
254
+ * @param {number} size - size of the logs to be requested
255
+ * @param {Object} queryParams - additional parameters
256
+ * @param {string} queryParams.query - search query text
257
+ * @param {string} queryParams.timeFrame - selected time period to show results for
258
+ * @param {string} [queryParams.lastEntryTimestamp] - time stamp of the last item in a list, used with auto
259
+ * @param {boolean} keepAlive - determines how long the PIT ID should be alive
260
+ * @param {string} pitId - PIT ID that is needed to get next chunk of logs
261
+ * @param {Array} searchAfter - An array of identifiers that points to the last provided log
262
+ * @returns {Promise.<Object>} Elasticsearch logs data.
263
+ */
264
+ function getNextPitLogs(size, queryParams, keepAlive, pitId, searchAfter) {
265
+ var searchFrom = '';
266
+ var searchTo = 'now';
267
+
268
+ if (queryParams.timeFrame) {
269
+ searchFrom = 'now-' + queryParams.timeFrame;
270
+ } else {
271
+ searchFrom = lodash.get(queryParams, 'customTimeFrame.from');
272
+ searchTo = lodash.get(queryParams, 'customTimeFrame.to', 'now');
273
+ }
274
+
275
+ var config = {
276
+ size: size,
277
+ body: {
278
+ pit: {
279
+ id: pitId,
280
+ keep_alive: keepAlive
281
+ },
282
+ query: {
283
+ bool: {
284
+ must: [
285
+ {
286
+ range: {
287
+ '@timestamp': {
288
+ gte: searchFrom,
289
+ lte: searchTo
290
+ }
291
+ }
292
+ },
293
+ {
294
+ query_string: {
295
+ query: queryParams.query,
296
+ analyze_wildcard: true,
297
+ default_field: '*'
298
+ }
299
+ }
300
+ ]
301
+ }
302
+ },
303
+ sort: [
304
+ {
305
+ '@timestamp': 'desc'
306
+ }
307
+ ]
308
+ }
309
+ };
310
+
311
+ if (searchAfter) {
312
+ config.body.search_after = searchAfter;
313
+ }
314
+
315
+ return ElasticsearchService.search(config);
316
+ }
252
317
  }
253
318
  }());
@@ -28,11 +28,10 @@ such restriction.
28
28
  controller: NclVersionExecutionLogController
29
29
  });
30
30
 
31
- function NclVersionExecutionLogController(lodash, $interval, i18next, $i18next, $rootScope, moment, ConfigService,
32
- ControlPanelLogsDataService, ExportService, LoginService,PaginationService) {
31
+ function NclVersionExecutionLogController(lodash, $interval, i18next, $i18next, $rootScope, moment, ControlPanelLogsDataService,
32
+ ConfigService, ExportService, LoginService, PaginationService) {
33
33
  var ctrl = this;
34
34
  var lng = i18next.language;
35
- var MAX_DOWNLOAD_LOGS = 2000000;
36
35
 
37
36
  var refreshInterval = null;
38
37
  var initialTimeRange = {
@@ -52,7 +51,7 @@ such restriction.
52
51
  }
53
52
  };
54
53
 
55
- ctrl.downloadButtonIsHidden = true;
54
+ ctrl.downloadButtonIsDisabled = false;
56
55
  ctrl.isSplashShowed = {
57
56
  value: false
58
57
  };
@@ -192,12 +191,6 @@ such restriction.
192
191
 
193
192
  ctrl.page.size = ctrl.perPageValues[0].id;
194
193
 
195
- ControlPanelLogsDataService.logsPaginated(0, 100, { query: generateDefaultQuery(), trackTotalHits: true })
196
- .then(function (logs) {
197
- if (logs.length > 0) {
198
- ctrl.downloadButtonIsHidden = logs.total_logs_count >= MAX_DOWNLOAD_LOGS;
199
- }
200
- });
201
194
  applyFilters();
202
195
  }
203
196
 
@@ -228,10 +221,14 @@ such restriction.
228
221
  function downloadLogFiles() {
229
222
  stopAutoUpdate();
230
223
 
231
- return ControlPanelLogsDataService.collectLogs(generateDefaultQuery())
224
+ ctrl.downloadButtonIsDisabled = true;
225
+ return ControlPanelLogsDataService.collectLogs(queryParams())
232
226
  .then(function (response) {
233
227
  ExportService.exportLogs(response, ctrl.version.metadata.name);
228
+ }).finally(function () {
234
229
  startAutoUpdate();
230
+
231
+ ctrl.downloadButtonIsDisabled = false;
235
232
  });
236
233
  }
237
234
 
@@ -420,25 +417,12 @@ such restriction.
420
417
  ctrl.filterQuery = lodash.join(queries, ' AND ');
421
418
  }
422
419
 
423
- /**
424
- * Generates query string without additional filters
425
- */
426
- function generateDefaultQuery() {
427
- var queries = ['system-id:"' + ConfigService.systemId + '"', '_exists_:nuclio'];
428
-
429
- if (!lodash.isEmpty(ctrl.version.metadata.name)) {
430
- queries.push('name:' + ctrl.version.metadata.name);
431
- }
432
- return lodash.join(queries, ' AND ');
433
- }
434
-
435
420
  /**
436
421
  * Generates query params for ordinary request, for example, when page was changed
437
422
  * @returns {Object}
438
423
  */
439
424
  function queryParams() {
440
425
  return {
441
- trackTotalHits: true,
442
426
  query: ctrl.filterQuery,
443
427
  timeFrame: ctrl.datePreset,
444
428
  customTimeFrame: ctrl.timeRange
@@ -1,7 +1,7 @@
1
1
  .ncl-version-execution-log {
2
2
  .control-panel-log-color-set();
3
3
 
4
- min-width: 1200px;
4
+ min-width: 1250px;
5
5
  padding: 24px 25px 22px 41px;
6
6
 
7
7
  .ncl-version-execution-log-wrapper {
@@ -34,6 +34,10 @@
34
34
  transition: @igz-basic-transition;
35
35
  height: 100%;
36
36
 
37
+ .limitation-message {
38
+ line-height: 20px;
39
+ }
40
+
37
41
  .logs-container {
38
42
  padding-bottom: 50px;
39
43
  }
@@ -110,6 +110,9 @@
110
110
  <igz-info-page-actions-bar>
111
111
  <div class="igz-action-panel">
112
112
  <div class="actions-list">
113
+ <div class="actions-bar-left">
114
+ <span class="limitation-message" data-ng-i18next="[html]functions:LOGS_LINES_LIMITATION"></span>
115
+ </div>
113
116
  <div class="actions-bar-right">
114
117
  <div class="actions-bar-left actions-buttons-block actions-dropdown-block">
115
118
  <igz-default-dropdown data-values-array="$ctrl.refreshRate.options"
@@ -126,10 +129,10 @@
126
129
  data-refresh="$ctrl.searchWithParams($ctrl.page.number, $ctrl.page.size)">
127
130
  </igz-action-item-refresh>
128
131
  </div>
129
- <div class="actions-bar-left" data-ng-hide="$ctrl.downloadButtonIsHidden">
132
+ <div class="actions-bar-left">
130
133
  <div class="igz-action-item"
131
134
  data-ng-click="$ctrl.downloadLogFiles()"
132
- data-ng-class="{'inactive': $ctrl.logsAreDownloading}"
135
+ data-ng-class="{'inactive': $ctrl.logsAreDownloading || $ctrl.downloadButtonIsDisabled}"
133
136
  data-uib-tooltip="{{ 'common:DOWNLOAD' | i18next }}"
134
137
  data-tooltip-placement="bottom"
135
138
  data-tooltip-popup-delay="300"