一、配置文件位置
- /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
或者:参考:
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