alert_def.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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', dynamicLookup: true},
  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. var noDataModes = [
  33. {text: 'OK', value: 'ok'},
  34. {text: 'Alerting', value: 'alerting'},
  35. {text: 'No Data', value: 'no_data'},
  36. ];
  37. function createReducerPart(model) {
  38. var def = new QueryPartDef({type: model.type, defaultParams: []});
  39. return new QueryPart(model, def);
  40. }
  41. function getStateDisplayModel(state) {
  42. switch (state) {
  43. case 'ok': {
  44. return {
  45. text: 'OK',
  46. iconClass: 'icon-gf icon-gf-online',
  47. stateClass: 'alert-state-ok'
  48. };
  49. }
  50. case 'alerting': {
  51. return {
  52. text: 'ALERTING',
  53. iconClass: 'icon-gf icon-gf-critical',
  54. stateClass: 'alert-state-critical'
  55. };
  56. }
  57. case 'no_data': {
  58. return {
  59. text: 'NO DATA',
  60. iconClass: "fa fa-question",
  61. stateClass: 'alert-state-warning'
  62. };
  63. }
  64. case 'execution_error': {
  65. return {
  66. text: 'EXECUTION ERROR',
  67. iconClass: 'icon-gf icon-gf-critical',
  68. stateClass: 'alert-state-critical'
  69. };
  70. }
  71. case 'paused': {
  72. return {
  73. text: 'paused',
  74. iconClass: "fa fa-pause",
  75. stateClass: 'alert-state-paused'
  76. };
  77. }
  78. }
  79. }
  80. export default {
  81. alertQueryDef: alertQueryDef,
  82. getStateDisplayModel: getStateDisplayModel,
  83. conditionTypes: conditionTypes,
  84. evalFunctions: evalFunctions,
  85. noDataModes: noDataModes,
  86. reducerTypes: reducerTypes,
  87. createReducerPart: createReducerPart,
  88. };