alert_def.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. ///<reference path="../../headers/common.d.ts" />
  2. import {
  3. QueryPartDef,
  4. QueryPart,
  5. } from 'app/core/components/query_part/query_part';
  6. var alertQueryDef = new QueryPartDef({
  7. type: 'query',
  8. params: [
  9. {name: "queryRefId", type: 'string', options: ['A', 'B', 'C', 'D', 'E', 'F']},
  10. {name: "from", type: "string", options: ['1s', '10s', '1m', '5m', '10m', '15m', '1h']},
  11. {name: "to", type: "string", options: ['now']},
  12. ],
  13. defaultParams: ['#A', '5m', 'now', 'avg']
  14. });
  15. var conditionTypes = [
  16. {text: 'Query', value: 'query'},
  17. ];
  18. var evalFunctions = [
  19. {text: 'IS ABOVE', value: 'gt'},
  20. {text: 'IS BELOW', value: 'lt'},
  21. {text: 'IS OUTSIDE RANGE', value: 'outside_range'},
  22. {text: 'IS WITHIN RANGE', value: 'within_range'},
  23. {text: 'HAS NO VALUE' , value: 'no_value'}
  24. ];
  25. var reducerTypes = [
  26. {text: 'avg()', value: 'avg'},
  27. {text: 'min()', value: 'min'},
  28. {text: 'max()', value: 'max'},
  29. {text: 'sum()' , value: 'sum'},
  30. {text: 'count()', value: 'count'},
  31. ];
  32. function createReducerPart(model) {
  33. var def = new QueryPartDef({type: model.type, defaultParams: []});
  34. return new QueryPart(model, def);
  35. }
  36. var severityLevels = {
  37. 'critical': {text: 'Critical', iconClass: 'icon-gf icon-gf-critical', stateClass: 'alert-state-critical'},
  38. 'warning': {text: 'Warning', iconClass: 'icon-gf icon-gf-warning', stateClass: 'alert-state-warning'},
  39. };
  40. function getStateDisplayModel(state) {
  41. switch (state) {
  42. case 'ok': {
  43. return {
  44. text: 'OK',
  45. iconClass: 'icon-gf icon-gf-online',
  46. stateClass: 'alert-state-ok'
  47. };
  48. }
  49. case 'critical': {
  50. return {
  51. text: 'CRITICAL',
  52. iconClass: 'icon-gf icon-gf-critical',
  53. stateClass: 'alert-state-critical'
  54. };
  55. }
  56. case 'warning': {
  57. return {
  58. text: 'WARNING',
  59. iconClass: 'icon-gf icon-gf-warning',
  60. stateClass: 'alert-state-warning'
  61. };
  62. }
  63. case 'pending': {
  64. return {
  65. text: 'PENDING',
  66. iconClass: "fa fa-question",
  67. stateClass: 'alert-state-warning'
  68. };
  69. }
  70. case 'paused': {
  71. return {
  72. text: 'paused',
  73. iconClass: "fa fa-pause",
  74. stateClass: 'alert-state-paused'
  75. };
  76. }
  77. }
  78. }
  79. export default {
  80. alertQueryDef: alertQueryDef,
  81. getStateDisplayModel: getStateDisplayModel,
  82. conditionTypes: conditionTypes,
  83. evalFunctions: evalFunctions,
  84. severityLevels: severityLevels,
  85. reducerTypes: reducerTypes,
  86. createReducerPart: createReducerPart,
  87. };