templating_editor.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <div ng-controller="TemplateEditorCtrl" ng-init="init()"> <div class="dashboard-editor-header">
  2. <div class="dashboard-editor-title">
  3. <i class="icon icon-code"></i>
  4. Templating
  5. </div>
  6. <div ng-model="editor.index" bs-tabs style="text-transform:capitalize;">
  7. <div ng-repeat="tab in ['Variables', 'Add', 'Edit']" data-title="{{tab}}">
  8. </div>
  9. </div>
  10. </div>
  11. <div class="dashboard-editor-body">
  12. <div ng-if="editor.index == 0">
  13. <div class="editor-row row">
  14. <div class="span8">
  15. <div ng-if="variables.length === 0">
  16. <em>No template variables defined</em>
  17. </div>
  18. <table class="grafana-options-table">
  19. <tr ng-repeat="variable in variables">
  20. <td style="width: 1%">
  21. <span class="template-variable">
  22. ${{variable.name}}
  23. </span>
  24. </td>
  25. <td class="max-width" style="max-width: 200px;">
  26. {{variable.query}}
  27. </td>
  28. <td style="width: 1%">
  29. <a ng-click="edit(variable)" class="btn btn-success btn-mini">
  30. <i class="icon-edit"></i>
  31. Edit
  32. </a>
  33. </td>
  34. <td style="width: 1%"><i ng-click="_.move(variables,$index,$index-1)" ng-hide="$first" class="pointer icon-arrow-up"></i></td>
  35. <td style="width: 1%"><i ng-click="_.move(variables,$index,$index+1)" ng-hide="$last" class="pointer icon-arrow-down"></i></td>
  36. <td style="width: 1%">
  37. <a ng-click="removeVariable(variable)" class="btn btn-danger btn-mini">
  38. <i class="icon-remove"></i>
  39. </a>
  40. </td>
  41. </tr>
  42. </table>
  43. </div>
  44. </div>
  45. </div>
  46. <div ng-if="editor.index == 1 || (editor.index == 2 && !currentIsNew)">
  47. <div class="row">
  48. <div class="editor-option">
  49. <div class="editor-row">
  50. <div class="editor-option">
  51. <label class="small">Variable name</label>
  52. <input type="text" class="input-medium" ng-model='current.name' placeholder="name"></input>
  53. </div>
  54. <div class="editor-option">
  55. <label class="small">Type</label>
  56. <select class="input-medium" ng-model="current.type" ng-options="f for f in ['query', 'interval', 'custom']" ng-change="typeChanged()"></select>
  57. </div>
  58. <div class="editor-option" ng-show="current.type === 'query'">
  59. <label class="small">Datasource</label>
  60. <select class="input input-medium" ng-model="current.datasource" ng-options="f.value as f.name for f in datasources"></select>
  61. </div>
  62. <div class="editor-option text-center" ng-show="current.type === 'query'">
  63. <label class="small">Refresh on load <tip>Check if you want values to be updated on dashboard load, will slow down dashboard load time.</tip></label>
  64. <input type="checkbox" ng-model="current.refresh" ng-checked="current.refresh">
  65. </div>
  66. </div>
  67. <div ng-show="current.type === 'interval'">
  68. <div class="editor-row">
  69. <div class="editor-option">
  70. <label class="small">Values</label>
  71. <input type="text" class="input-xxlarge" ng-model='current.query' ng-blur="runQuery()" placeholder="name"></input>
  72. </div>
  73. </div>
  74. <div class="editor-row">
  75. <div class="editor-option text-center">
  76. <label class="small">Include auto interval</label>
  77. <input type="checkbox" ng-model="current.auto" ng-checked="current.auto" ng-change="runQuery()">
  78. </div>
  79. <div class="editor-option" ng-show="current.auto">
  80. <label class="small">Auto interval steps <tip>How many steps, roughly, the interval is rounded and will not always match this count<tip></label>
  81. <select class="input-mini" ng-model="current.auto_count" ng-options="f for f in [3,5,10,30,50,100,200]" ng-change="runQuery()"></select>
  82. </div>
  83. </div>
  84. </div>
  85. <div ng-show="current.type === 'custom'">
  86. <div class="editor-row">
  87. <div class="editor-option">
  88. <label class="small">Values seperated by comma</label>
  89. <input type="text" class="input-xxlarge" ng-model='current.query' ng-blur="runQuery()" placeholder="1, 10, 20, myvalue"></input>
  90. </div>
  91. </div>
  92. </div>
  93. <div ng-show="current.type === 'query'">
  94. <div class="editor-row">
  95. <div class="editor-option form-inline">
  96. <label class="small">Variable values query</label>
  97. <input type="text" class="input-xxlarge" ng-model='current.query' placeholder="apps.servers.*"></input>
  98. <button class="btn btn-small btn-success" ng-click="runQuery()" bs-tooltip="'Execute query'" data-placement="right"><i class="icon-play"></i></button>
  99. </div>
  100. </div>
  101. <div class="editor-row" style="margin: 15px 0">
  102. <div class="editor-option form-inline">
  103. <label class="small">regex (optional, if you want to extract part of a series name or metric node segment)</label>
  104. <input type="text" class="input-xxlarge" ng-model='current.regex' placeholder="/.*-(.*)-.*/"></input>
  105. <button class="btn btn-small btn-success" ng-click="runQuery()" bs-tooltip="'execute query'" data-placement="right"><i class="icon-play"></i></button>
  106. </div>
  107. </div>
  108. <div class="editor-row" style="margin: 15px 0">
  109. <div class="editor-option text-center">
  110. <label class="small">All option</label>
  111. <input type="checkbox" ng-model="current.includeAll" ng-checked="current.includeAll" ng-change="runQuery()">
  112. </div>
  113. <div class="editor-option" ng-show="current.includeAll">
  114. <label class="small">All format</label>
  115. <select class="input-medium" ng-model="current.allFormat" ng-change="runQuery()" ng-options="f for f in ['glob', 'wildcard', 'regex wildcard', 'regex values']"></select>
  116. </div>
  117. <div class="editor-option" ng-show="current.includeAll">
  118. <label class="small">All value</label>
  119. <input type="text" class="input-xlarge" ng-model='current.options[0].value'></input>
  120. </div>
  121. </div>
  122. </div>
  123. </div>
  124. <div class="editor-option">
  125. <div class="editor-row">
  126. <div class="editor-option" >
  127. <label class="small">Variable values (showing 20/{{current.options.length}})</label>
  128. <ul class="grafana-options-list">
  129. <li ng-repeat="option in current.options | limitTo: 20">
  130. {{option.text}}
  131. </li>
  132. </ul>
  133. </div>
  134. </div>
  135. </div>
  136. </div>
  137. </div>
  138. </div>
  139. <div class="dashboard-editor-footer">
  140. <button type="button" class="btn btn-success pull-left" ng-show="editor.index === 2" ng-click="update();">Update</button>
  141. <button type="button" class="btn btn-success pull-left" ng-show="editor.index === 1" ng-click="add();">Add</button>
  142. <button type="button" class="btn btn-success pull-right" ng-click="dismiss();">Close</button>
  143. </div>
  144. </div>
  145. <!-- <div class="span4"> -->
  146. <!-- <tip class="info&#45;box"> -->
  147. <!-- <i class="icon&#45;question&#45;sign"></i> -->
  148. <!-- The templating feature in Grafana lets easily create and manage templated queries. Templated queries use [[replacement]] syntax -->
  149. <!-- to replace a part of your metric key or query. By using this feature you can make your dashboards more generic. You can for example create -->
  150. <!-- a query replacement for your cluster name or server name. Then use that replacement in your metric queries and change -->
  151. <!-- it globably for all graphs on the dashboard. -->
  152. <!-- <br/><br/> -->
  153. <!-- </tip> -->
  154. <!-- </div> -->