附12 grafana配置文件


一、配置文件位置

  • /usr/local/opt/grafana/share/grafana/default.ini
  • /usr/local/etc/grafana/grafana.ini

 

二、init格式

1、注釋:

  • 以";"開頭,不管多長或多短,獨占一行

 

三、配置文件調用順序

1、grafana啟動時,首先會調用/usr/local/opt/grafana/share/grafana/default.ini(定義了默認的啟動信息)

2、之后會調用我們寫的--config所指向的配置文件(默認為/usr/local/etc/grafana/grafana.ini),所以通過該文件我們可以覆蓋default.ini的配置

 

四、完整文件及注釋

  1 ##################### Grafana Configuration Example #####################
  2 # use "--config" to specified via command line
  3 # Everything has defaults so you only need to uncomment(解開注釋,去掉";") things you want to
  4 # change
  5 
  6 # possible values : production, development
  7 app_mode = production
  8 
  9 # grafana-server instance name, defaults to HOSTNAME environment variable value or hostname if HOSTNAME var is empty
 10 # Used in logging and internal metrics and in clustering info
 11 # use "echo ${HOSTNAME}" to view ${HOSTNAME} name
 12 instance_name = ${HOSTNAME}
 13 
 14 #################################### Paths ####################################
 15 [paths]
 16 # Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used)
 17 # use "cfg:default.paths.data" to specified via command line
 18 data = /usr/local/var/lib/grafana
 19 #
 20 # Directory where grafana can store logs
 21 # use "cfg:default.paths.logs" to specified via command line
 22 logs = /usr/local/var/log/grafana
 23 #
 24 # Directory where grafana will automatically scan and look for plugins
 25 # use "cfg:default.paths.plugins" to specified via command line
 26 plugins = /usr/local/var/lib/grafana/plugins
 27 
 28 #################################### Server ####################################
 29 [server]
 30 # Protocol (http or https)
 31 protocol = http
 32 
 33 The ip address to bind to, empty will bind to all interfaces
 34 http_addr = 192.168.20.237
 35 
 36 # The http port  to use, defaults to 3000
 37 http_port = 3000
 38 
 39 # The public facing domain name used to access grafana from a browser
 40 domain = mygrafana
 41 
 42 # Redirect to correct domain if host header does not match domain
 43 # Prevents DNS rebinding attacks
 44 ;enforce_domain = false
 45 
 46 # The full public facing url
 47 root_url = %(protocol)s://%(domain)s:%(http_port)s/
 48 
 49 # Log web requests
 50 ;router_logging = false
 51 
 52 # the path relative working path(The path to the directory where the front end files (HTML, JS, and CSS files))
 53 static_root_path = public
 54 
 55 # enable gzip
 56 ;enable_gzip = false
 57 
 58 # https certs & key file(if protocol is set to https)
 59 ;cert_file =
 60 ;cert_key =
 61 
 62 #################################### Database ####################################
 63 [database]
 64 # Grafana needs a database to store users and dashboards (and other things)
 65 # Either "mysql", "postgres" or "sqlite3"(default), it's your choice
 66 ;type = sqlite3
 67 # host : Only applicable to MySQL or Postgres. Includes IP or hostname and port
 68 ;host = 127.0.0.1:3306
 69 # The name of the Grafana database
 70 ;name = grafana
 71 ;user = root
 72 ;password =
 73 
 74 # For "postgres" only, either "disable", "require" or "verify-full"
 75 ;ssl_mode = disable
 76 
 77 # For "sqlite3" only, path relative to data_path setting
 78 ;path = grafana.db
 79 
 80 #################################### Session ####################################
 81 [session]
 82 # Either "memory", "file", "redis", "mysql", "postgres", default is "file"
 83 provider = file
 84 
 85 # Provider config options
 86 # memory: not have any config yet
 87 # file: session dir path, is relative to grafana data_path
 88 # redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=grafana`
 89 # mysql: go-sql-driver/mysql dsn config string, e.g. `user:password@tcp(127.0.0.1:3306)/database_name`
 90 # postgres: user=a password=b host=localhost port=5432 dbname=c sslmode=disable
 91 ;provider_config = sessions
 92 
 93 # Session cookie name
 94 cookie_name = grafana_sess
 95 
 96 # If you use session in https only, default is false
 97 ;cookie_secure = false
 98 
 99 # Session life time, default is 86400(in seconds,24h)
100 session_life_time = 86400
101 
102 #################################### Analytics ####################################
103 [analytics]
104 # Server reporting, sends usage counters to stats.grafana.org every 24 hours.
105 # No ip addresses are being tracked, only simple counters to track
106 # running instances, dashboard and error counts. It is very helpful to us.
107 # Change this option to false to disable reporting.
108 reporting_enabled = true
109 
110 # Set to false to disable all checks to https://grafana.net
111 # for new vesions (grafana itself and plugins), check is used
112 # in some UI views to notify that grafana or plugin update exists
113 # This option does not cause any auto updates, nor send any information
114 # only a GET request to http://grafana.net to get latest versions
115 check_for_updates = true
116 
117 # Google Analytics universal tracking code, only enabled if you specify an id here
118 ;google_analytics_ua_id =
119 
120 #################################### Security ####################################
121 [security]
122 # default admin user, created on startup
123 ;admin_user = admin
124 admin_user = zhaojigang
125 
126 # default admin password, can be changed before first start of grafana,  or in profile settings
127 ;admin_password = admin
128 admin_password = zhaojigang
129 
130 # used for signing(Used for signing keep me logged in / remember me cookies)
131 ;secret_key = SW2YcwTIb9zpOOhoPsMm
132 
133 # Auto-login remember days(The number of days the keep me logged in / remember me cookie lasts)
134 login_remember_days = 7
135 ;cookie_username = grafana_user
136 ;cookie_remember_name = grafana_remember
137 
138 # disable gravatar profile images
139 ;disable_gravatar = false
140 
141 # data source proxy whitelist (ip_or_domain:port separated by spaces)
142 ;data_source_proxy_whitelist =
143 
144 [snapshots]
145 # snapshot sharing options
146 ;external_enabled = true
147 ;external_snapshot_url = https://snapshots-origin.raintank.io
148 ;external_snapshot_name = Publish to snapshot.raintank.io
149 
150 #################################### Users ####################################
151 [users]
152 # disable user signup / registration(Set to false to prohibit users from being able to sign up / create user accounts. Defaults to true. The admin user 
153 # can still create users from the Grafana Admin Pages)
154 allow_sign_up = true
155 
156 # Allow non admin users to create organizations(Set to false to prohibit users from creating new organizations)
157 ;allow_org_create = true
158 
159 # Set to true to automatically assign new users to the default organization (id 1)
160 ;auto_assign_org = true
161 
162 # Default role new users will be automatically assigned (if disabled above is set to true)
163 # other valid options are Admin and Editor and Read-Only Editor
164 auto_assign_org_role = Viewer
165 
166 # Background text for the user field on the login page
167 ;login_hint = email or username
168 
169 # Default UI theme ("dark" or "light")
170 ;default_theme = dark
171 
172 #################################### Anonymous Auth ##########################
173 [auth.anonymous]
174 # enable anonymous access
175 ;enabled = false
176 
177 # specify organization name that should be used for anonymous users
178 ;org_name = Main Org.
179 
180 # Specify role for anonymous users. Defaults to Viewer, other valid options are Editor and Admin
181 ;org_role = Viewer
182 
183 #################################### Github Auth ##########################
184 [auth.github]
185 ;enabled = false
186 ;allow_sign_up = false
187 ;client_id = some_id
188 ;client_secret = some_secret
189 ;scopes = user:email,read:org
190 ;auth_url = https://github.com/login/oauth/authorize
191 ;token_url = https://github.com/login/oauth/access_token
192 ;api_url = https://api.github.com/user
193 ;team_ids =
194 ;allowed_organizations =
195 
196 #################################### Google Auth ##########################
197 [auth.google]
198 ;enabled = false
199 ;allow_sign_up = false
200 ;client_id = some_client_id
201 ;client_secret = some_client_secret
202 ;scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
203 ;auth_url = https://accounts.google.com/o/oauth2/auth
204 ;token_url = https://accounts.google.com/o/oauth2/token
205 ;api_url = https://www.googleapis.com/oauth2/v1/userinfo
206 ;allowed_domains =
207 
208 #################################### Auth Proxy ##########################
209 [auth.proxy]
210 ;enabled = false
211 ;header_name = X-WEBAUTH-USER
212 ;header_property = username
213 ;auto_sign_up = true
214 
215 #################################### Basic Auth ##########################
216 [auth.basic]
217 ;enabled = true
218 
219 #################################### Auth LDAP ##########################
220 [auth.ldap]
221 ;enabled = false
222 ;config_file = /etc/grafana/ldap.toml
223 
224 #################################### SMTP / Emailing ##########################
225 [smtp]
226 ;enabled = false
227 ;host = localhost:25
228 ;user =
229 ;password =
230 ;cert_file =
231 ;key_file =
232 ;skip_verify = false
233 ;from_address = admin@grafana.localhost
234 
235 [emails]
236 ;welcome_email_on_sign_up = false
237 
238 #################################### Logging ##########################
239 [log]
240 # Either "console", "file", "syslog". Default is console and  file
241 # Use space to separate multiple modes, e.g. "console file"
242 ;mode = console, file
243 
244 # Either "trace", "debug", "info", "warn", "error", "critical", default is "info"
245 ;level = info
246 
247 # For "console" mode only
248 [log.console]
249 ;level =
250 
251 # log line format, valid options are text, console and json
252 ;format = console
253 
254 # For "file" mode only
255 [log.file]
256 ;level =
257 
258 # log line format, valid options are text, console and json
259 ;format = text
260 
261 # This enables automated log rotate(switch of following options), default is true
262 ;log_rotate = true
263 
264 # Max line number of single file, default is 1000000
265 ;max_lines = 1000000
266 
267 # Max size shift of single file, default is 28 means 1 << 28, 256MB
268 ;max_size_shift = 28
269 
270 # Segment log daily, default is true
271 ;daily_rotate = true
272 
273 # Expired days of log file(delete after max days), default is 7
274 ;max_days = 7
275 
276 [log.syslog]
277 ;level =
278 
279 # log line format, valid options are text, console and json
280 ;format = text
281 
282 # Syslog network type and address. This can be udp, tcp, or unix. If left blank, the default unix endpoints will be used.
283 ;network =
284 ;address =
285 
286 # Syslog facility. user, daemon and local0 through local7 are valid.
287 ;facility =
288 
289 # Syslog tag. By default, the process' argv[0] is used.
290 ;tag =
291 
292 
293 #################################### AMQP Event Publisher ##########################
294 [event_publisher]
295 ;enabled = false
296 ;rabbitmq_url = amqp://localhost/
297 ;exchange = grafana_events
298 
299 ;#################################### Dashboard JSON files ##########################
300 [dashboards.json]
301 ;enabled = false
302 ;path = /var/lib/grafana/dashboards
303 
304 #################################### Internal Grafana Metrics ##########################
305 # Metrics available at HTTP API Url /api/metrics
306 [metrics]
307 # Disable / Enable internal metrics
308 enabled           = true
309 
310 # Publish interval(Flush/Write interval when sending metrics to external TSDB.)
311 ;interval_seconds  = 10
312 
313 # Include this section if you want to send internal Grafana metrics to Graphite
314 ; [metrics.graphite]
315 ; address = localhost:2003
316 ; prefix = prod.grafana.%(instance_name)s.
317 
318 #################################### Internal Grafana Metrics ##########################
319 # Url used to to import dashboards directly from Grafana.net
320 [grafana_net]
321 url = https://grafana.net

注意:grafana的管理員只是在第一次啟動時設置一次,之后無法再進行設置 。

所以,上邊的admin_user=zhaojigang admin_password=zhaojigang如果不是第一次啟動之前設置的,那么就是不起作用的

https://github.com/grafana/grafana/issues/6156

或者:參考:https://my.oschina.net/guol/blog/515126

  1 app_mode:應用名稱,默認是production
  2 
  3 [path]
  4 data:一個grafana用來存儲sqlite3、臨時文件、回話的地址路徑
  5 logs:grafana存儲logs的路徑
  6 
  7 [server]
  8 http_addr:監聽的ip地址,,默認是0.0.0.0
  9 http_port:監聽的端口,默認是3000
 10 protocol:http或者https,,默認是http
 11 domain:這個設置是root_url的一部分,當你通過瀏覽器訪問grafana時的公開的domian名稱,默認是localhost
 12 enforce_domain:如果主機的header不匹配domian,則跳轉到一個正確的domain上,默認是false
 13 root_url:這是一個web上訪問grafana的全路徑url,默認是%(protocol)s://%(domain)s:%(http_port)s/
 14 router_logging:是否記錄web請求日志,默認是false
 15 cert_file:如果使用https則需要設置
 16 cert_key:如果使用https則需要設置
 17 
 18 [database]
 19 grafana默認需要使用數據庫存儲用戶和dashboard信息,默認使用sqlite3來存儲,你也可以換成其他數據庫
 20 type:可以是mysql、postgres、sqlite3,默認是sqlite3
 21 path:只是sqlite3需要,定義sqlite3的存儲路徑
 22 host:只是mysql、postgres需要,默認是127.0.0.1:3306
 23 name:grafana的數據庫名稱,默認是grafana
 24 user:連接數據庫的用戶
 25 password:數據庫用戶的密碼
 26 ssl_mode:只是postgres使用
 27 
 28 
 29 [security]
 30 admin_user:grafana默認的admin用戶,默認是admin
 31 admin_password:grafana admin的默認密碼,默認是admin
 32 login_remember_days:多少天內保持登錄狀態
 33 secret_key:保持登錄狀態的簽名
 34 disable_gravatar:
 35 
 36 
 37 [users]
 38 allow_sign_up:是否允許普通用戶登錄,如果設置為false,則禁止用戶登錄,默認是true,則admin可以創建用戶,並登錄grafana
 39 allow_org_create:如果設置為false,則禁止用戶創建新組織,默認是true
 40 auto_assign_org:當設置為true的時候,會自動的把新增用戶增加到id為1的組織中,當設置為false的時候,新建用戶的時候會新增一個組織
 41 auto_assign_org_role:新建用戶附加的規則,默認是Viewer,還可以是Admin、Editor
 42 
 43 
 44 [auth.anonymous]
 45 enabled:設置為true,則開啟允許匿名訪問,默認是false
 46 org_name:為匿名用戶設置組織名稱
 47 org_role:為匿名用戶設置的訪問規則,默認是Viewer
 48 
 49 
 50 [auth.github]
 51 針對github項目的,很明顯,呵呵
 52 enabled = false
 53 allow_sign_up = false
 54 client_id = some_id
 55 client_secret = some_secret
 56 scopes = user:email
 57 auth_url = https://github.com/login/oauth/authorize
 58 token_url = https://github.com/login/oauth/access_token
 59 api_url = https://api.github.com/user
 60 team_ids =
 61 allowed_domains =
 62 allowed_organizations =
 63 
 64 
 65 [auth.google]
 66 針對google app的,呵呵
 67 enabled = false
 68 allow_sign_up = false
 69 client_id = some_client_id
 70 client_secret = some_client_secret
 71 scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
 72 auth_url = https://accounts.google.com/o/oauth2/auth
 73 token_url = https://accounts.google.com/o/oauth2/token
 74 api_url = https://www.googleapis.com/oauth2/v1/userinfo
 75 allowed_domains =
 76 
 77 
 78 [auth.basic]
 79 enabled:當設置為true,則http api開啟基本認證
 80 
 81 
 82 [auth.ldap]
 83 enabled:設置為true則開啟LDAP認證,默認是false
 84 config_file:如果開啟LDAP,指定LDAP的配置文件/etc/grafana/ldap.toml
 85 
 86 
 87 [auth.proxy]
 88 允許你在一個HTTP反向代理上進行認證設置
 89 enabled:默認是false
 90 header_name:默認是X-WEBAUTH-USER
 91 header_property:默認是個名稱username
 92 auto_sign_up:默認是true。開啟自動注冊,如果用戶在grafana DB中不存在
 93 
 94 [analytics]
 95 reporting_enabled:如果設置為true,則會發送匿名使用分析到stats.grafana.org,主要用於跟蹤允許實例、版本、dashboard、錯誤統計。默認是true
 96 google_analytics_ua_id:使用GA進行分析,填寫你的GA ID即可
 97 
 98 
 99 [dashboards.json]
100 如果你有一個系統自動產生json格式的dashboard,則可以開啟這個特性試試
101 enabled:默認是false
102 path:一個全路徑用來包含你的json dashboard,默認是/var/lib/grafana/dashboards
103 
104 
105 [session]
106 provider:默認是file,值還可以是memory、mysql、postgres
107 provider_config:這個值的配置由provider的設置來確定,如果provider是file,則是data/xxxx路徑類型,如果provider是mysql,則是user:password@tcp(127.0.0.1:3306)/database_name,如果provider是postgres,則是user=a password=b host=localhost port=5432 dbname=c sslmode=disable
108 cookie_name:grafana的cookie名稱
109 cookie_secure:如果設置為true,則grafana依賴https,默認是false
110 session_life_time:session過期時間,默認是86400秒,24小時
111 
112 
113 以下是官方文檔沒有,配置文件中有的
114 [smtp]
115 enabled = false
116 host = localhost:25
117 user =
118 password =
119 cert_file =
120 key_file =
121 skip_verify = false
122 from_address = admin@grafana.localhost
123 
124 [emails]
125 welcome_email_on_sign_up = false
126 templates_pattern = emails/*.html
127 
128 
129 [log]
130 mode:可以是console、file,默認是console、file,也可以設置多個,用逗號隔開
131 buffer_len:channel的buffer長度,默認是10000
132 level:可以是"Trace", "Debug", "Info", "Warn", "Error", "Critical",默認是info
133 
134 [log.console]
135 level:設置級別
136 
137 [log.file]
138 level:設置級別
139 log_rotate:是否開啟自動輪轉
140 max_lines:單個日志文件的最大行數,默認是1000000
141 max_lines_shift:單個日志文件的最大大小,默認是28,表示256MB
142 daily_rotate:每天是否進行日志輪轉,默認是true
143 max_days:日志過期時間,默認是7,7天后刪除
View Code

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM