annotations_query_ctrl.ts 956 B

123456789101112131415161718192021222324252627282930313233
  1. export class AzureMonitorAnnotationsQueryCtrl {
  2. static templateUrl = 'partials/annotations.editor.html';
  3. datasource: any;
  4. annotation: any;
  5. workspaces: any[];
  6. defaultQuery =
  7. '<your table>\n| where $__timeFilter() \n| project TimeGenerated, Text=YourTitleColumn, Tags="tag1,tag2"';
  8. /** @ngInject */
  9. constructor() {
  10. this.annotation.queryType = this.annotation.queryType || 'Azure Log Analytics';
  11. this.annotation.rawQuery = this.annotation.rawQuery || this.defaultQuery;
  12. this.getWorkspaces();
  13. }
  14. getWorkspaces() {
  15. if (this.workspaces && this.workspaces.length > 0) {
  16. return this.workspaces;
  17. }
  18. return this.datasource
  19. .getAzureLogAnalyticsWorkspaces()
  20. .then(list => {
  21. this.workspaces = list;
  22. if (list.length > 0 && !this.annotation.workspace) {
  23. this.annotation.workspace = list[0].value;
  24. }
  25. return this.workspaces;
  26. })
  27. .catch(() => {});
  28. }
  29. }