config.html 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <h3 class="page-heading">PostgreSQL Connection</h3>
  2. <div class="gf-form-group">
  3. <div class="gf-form max-width-30">
  4. <span class="gf-form-label width-10">Host</span>
  5. <input type="text" class="gf-form-input" ng-model='ctrl.current.url' placeholder="localhost:5432"
  6. bs-typeahead="{{['localhost:5432', 'localhost:5433']}}" required></input>
  7. </div>
  8. <div class="gf-form max-width-30">
  9. <span class="gf-form-label width-10">Database</span>
  10. <input type="text" class="gf-form-input" ng-model='ctrl.current.database' placeholder="database name" required></input>
  11. </div>
  12. <div class="gf-form-inline">
  13. <div class="gf-form max-width-15">
  14. <span class="gf-form-label width-10">User</span>
  15. <input type="text" class="gf-form-input" ng-model='ctrl.current.user' placeholder="user"></input>
  16. </div>
  17. <div class="gf-form">
  18. <secret-form-field
  19. isConfigured="ctrl.current.secureJsonFields.password"
  20. value="ctrl.current.secureJsonData.password"
  21. on-reset="ctrl.onPasswordReset"
  22. on-change="ctrl.onPasswordChange"
  23. inputWidth="9"
  24. aria-label="'Password'"
  25. />
  26. </div>
  27. </div>
  28. <div class="gf-form">
  29. <label class="gf-form-label width-10" for="tls-mode-select">TLS/SSL Mode</label>
  30. <div class="gf-form-select-wrapper max-width-15 gf-form-select-wrapper--has-help-icon">
  31. <select id="tls-mode-select" class="gf-form-input" ng-model="ctrl.current.jsonData.sslmode"
  32. ng-options="mode for mode in ['disable', 'require', 'verify-ca', 'verify-full']"
  33. ng-init="ctrl.current.jsonData.sslmode" ng-change="ctrl.tlsModeMapping()"></select>
  34. <info-popover mode="right-absolute">
  35. This option determines whether or with what priority a secure TLS/SSL TCP/IP connection will be negotiated with the server.
  36. </info-popover>
  37. </div>
  38. </div>
  39. <div class="gf-form" ng-if="ctrl.current.jsonData.sslmode != 'disable'">
  40. <label class="gf-form-label width-10">TLS/SSL Method</label>
  41. <div class="gf-form-select-wrapper max-width-15 gf-form-select-wrapper--has-help-icon">
  42. <select class="gf-form-input" ng-model="ctrl.current.jsonData.tlsConfigurationMethod"
  43. ng-options="f.id as f.label for f in [{ id: 'file-path', label: 'File system path' }, { id: 'file-content', label: 'Certificate content' }]"
  44. ng-init="ctrl.current.jsonData.tlsConfigurationMethod"></select>
  45. <info-popover mode="right-absolute">
  46. This option determines how TLS/SSL certifications are configured. Selecting <i>File system path</i> will allow
  47. you to configure certificates by specifying paths to existing certificates on the local file system where
  48. Grafana is running. Be sure that the file is readable by the user executing the Grafana process.<br><br>
  49. Selecting <i>Certificate content</i> will allow you to configure certificates by specifying its content.
  50. The content will be stored encrypted in Grafana's database. When connecting to the database the certificates
  51. will be written as files to Grafana's configured data path on the local file system.
  52. </info-popover>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="gf-form-group" ng-if="ctrl.current.jsonData.sslmode != 'disable' && ctrl.current.jsonData.tlsConfigurationMethod === 'file-path'">
  57. <div class="gf-form">
  58. <h6>TLS/SSL Auth Details</h6>
  59. </div>
  60. <div class="gf-form max-width-30">
  61. <span class="gf-form-label width-11">TLS/SSL Root Certificate</span>
  62. <input type="text" class="gf-form-input gf-form-input--has-help-icon"
  63. ng-model='ctrl.current.jsonData.sslRootCertFile' placeholder="TLS/SSL root cert file"></input>
  64. <info-popover mode="right-absolute">
  65. If the selected TLS/SSL mode requires a server root certificate, provide the path to the file here.
  66. </info-popover>
  67. </div>
  68. <div class="gf-form max-width-30">
  69. <span class="gf-form-label width-11">TLS/SSL Client Certificate</span>
  70. <input type="text" class="gf-form-input gf-form-input--has-help-icon" ng-model='ctrl.current.jsonData.sslCertFile'
  71. placeholder="TLS/SSL client cert file"></input>
  72. <info-popover mode="right-absolute">
  73. To authenticate with an TLS/SSL client certificate, provide the path to the file here.
  74. Be sure that the file is readable by the user executing the grafana process.
  75. </info-popover>
  76. </div>
  77. <div class="gf-form max-width-30">
  78. <span class="gf-form-label width-11">TLS/SSL Client Key</span>
  79. <input type="text" class="gf-form-input gf-form-input--has-help-icon" ng-model='ctrl.current.jsonData.sslKeyFile'
  80. placeholder="TLS/SSL client key file"></input>
  81. <info-popover mode="right-absolute">
  82. To authenticate with a client TLS/SSL certificate, provide the path to the corresponding key file here.
  83. Be sure that the file is <i>only</i> readable by the user executing the grafana process.
  84. </info-popover>
  85. </div>
  86. </div>
  87. <datasource-tls-auth-settings current="ctrl.current"
  88. ng-if="ctrl.current.jsonData.sslmode != 'disable' && ctrl.current.jsonData.tlsConfigurationMethod === 'file-content'">
  89. </datasource-tls-auth-settings>
  90. <b>Connection limits</b>
  91. <div class="gf-form-group">
  92. <div class="gf-form max-width-15">
  93. <span class="gf-form-label width-7">Max open</span>
  94. <input type="number" min="0" class="gf-form-input gf-form-input--has-help-icon"
  95. ng-model="ctrl.current.jsonData.maxOpenConns" placeholder="unlimited"></input>
  96. <info-popover mode="right-absolute">
  97. The maximum number of open connections to the database. If <i>Max idle connections</i> is greater than 0 and the
  98. <i>Max open connections</i> is less than <i>Max idle connections</i>, then <i>Max idle connections</i> will be
  99. reduced to match the <i>Max open connections</i> limit. If set to 0, there is no limit on the number of open
  100. connections.
  101. </info-popover>
  102. </div>
  103. <div class="gf-form max-width-15">
  104. <span class="gf-form-label width-7">Max idle</span>
  105. <input type="number" min="0" class="gf-form-input gf-form-input--has-help-icon"
  106. ng-model="ctrl.current.jsonData.maxIdleConns" placeholder="2"></input>
  107. <info-popover mode="right-absolute">
  108. The maximum number of connections in the idle connection pool. If <i>Max open connections</i> is greater than 0 but
  109. less than the <i>Max idle connections</i>, then the <i>Max idle connections</i> will be reduced to match the
  110. <i>Max open connections</i> limit. If set to 0, no idle connections are retained.
  111. </info-popover>
  112. </div>
  113. <div class="gf-form max-width-15">
  114. <span class="gf-form-label width-7">Max lifetime</span>
  115. <input type="number" min="0" class="gf-form-input gf-form-input--has-help-icon"
  116. ng-model="ctrl.current.jsonData.connMaxLifetime" placeholder="14400"></input>
  117. <info-popover mode="right-absolute">
  118. The maximum amount of time in seconds a connection may be reused. If set to 0, connections are reused forever.
  119. </info-popover>
  120. </div>
  121. </div>
  122. <h3 class="page-heading">PostgreSQL details</h3>
  123. <div class="gf-form-group">
  124. <div class="gf-form">
  125. <span class="gf-form-label width-9" id="version-label">
  126. Version
  127. <info-popover mode="right-normal" position="top center">
  128. This option controls what functions are available in the PostgreSQL query builder.
  129. </info-popover>
  130. </span>
  131. <span class="gf-form-select-wrapper">
  132. <select class="gf-form-input gf-size-auto" ng-model="ctrl.current.jsonData.postgresVersion"
  133. ng-options="f.value as f.name for f in ctrl.postgresVersions" aria-labelledby="version-label"></select>
  134. </span>
  135. </div>
  136. <div class="gf-form">
  137. <gf-form-switch class="gf-form" label="TimescaleDB" label-class="width-9"
  138. checked="ctrl.current.jsonData.timescaledb" switch-class="max-width-6"></gf-form-switch>
  139. <label class="gf-form-label query-keyword pointer" ng-click="ctrl.toggleTimescaleDBHelp()">
  140. Help&nbsp;
  141. <icon name="'angle-down'" ng-show="ctrl.showTimescaleDBHelp"></icon>
  142. <icon name="'angle-right'" ng-hide="ctrl.showTimescaleDBHelp">&nbsp;</icon>
  143. </label>
  144. </div>
  145. <div class="gf-form-inline">
  146. <div class="gf-form">
  147. <span class="gf-form-label width-9">Min time interval</span>
  148. <input
  149. type="text"
  150. class="gf-form-input width-6 gf-form-input--has-help-icon"
  151. ng-model="ctrl.current.jsonData.timeInterval"
  152. spellcheck='false'
  153. placeholder="1m"
  154. ng-pattern="/^\d+(ms|[Mwdhmsy])$/"
  155. ></input>
  156. <info-popover mode="right-absolute">
  157. A lower limit for the auto group by time interval. Recommended to be set to write frequency,
  158. for example <code>1m</code> if your data is written every minute.
  159. </info-popover>
  160. </div>
  161. </div>
  162. <div class="grafana-info-box alert alert-info" ng-show="ctrl.showTimescaleDBHelp">
  163. <div class="alert-body">
  164. <p>
  165. <a href="https://github.com/timescale/timescaledb" class="pointer" target="_blank">TimescaleDB</a> is a
  166. time-series database built as a PostgreSQL extension. If enabled, Grafana will use <code>time_bucket</code> in
  167. the <code>$__timeGroup</code> macro and display TimescaleDB specific aggregate functions in the query builder.
  168. </p>
  169. </div>
  170. </div>
  171. </div>
  172. <div class="gf-form-group">
  173. <div class="grafana-info-box">
  174. <h5>User Permission</h5>
  175. <p>
  176. The database user should only be granted SELECT permissions on the specified database &amp; tables you want to query.
  177. Grafana does not validate that queries are safe so queries can contain any SQL statement. For example, statements
  178. like <code>DELETE FROM user;</code> and <code>DROP TABLE user;</code> would be executed. To protect against this we
  179. <strong>Highly</strong> recommmend you create a specific PostgreSQL user with restricted permissions.
  180. </p>
  181. </div>
  182. </div>