一、配置文件位置

  • /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[] is used.
  290. ;tag =
  291.  
  292. #################################### AMQP Event Publisher ##########################
  293. [event_publisher]
  294. ;enabled = false
  295. ;rabbitmq_url = amqp://localhost/
  296. ;exchange = grafana_events
  297.  
  298. ;#################################### Dashboard JSON files ##########################
  299. [dashboards.json]
  300. ;enabled = false
  301. ;path = /var/lib/grafana/dashboards
  302.  
  303. #################################### Internal Grafana Metrics ##########################
  304. # Metrics available at HTTP API Url /api/metrics
  305. [metrics]
  306. # Disable / Enable internal metrics
  307. enabled = true
  308.  
  309. # Publish interval(Flush/Write interval when sending metrics to external TSDB.)
  310. ;interval_seconds = 10
  311.  
  312. # Include this section if you want to send internal Grafana metrics to Graphite
  313. ; [metrics.graphite]
  314. ; address = localhost:2003
  315. ; prefix = prod.grafana.%(instance_name)s.
  316.  
  317. #################################### Internal Grafana Metrics ##########################
  318. # Url used to to import dashboards directly from Grafana.net
  319. [grafana_net]
  320. 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. logsgrafana存储logs的路径
  6.  
  7. [server]
  8. http_addr:监听的ip地址,,默认是0.0.0.0
  9. http_port:监听的端口,默认是3000
  10. protocolhttp或者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:可以是mysqlpostgressqlite3,默认是sqlite3
  21. path:只是sqlite3需要,定义sqlite3的存储路径
  22. host:只是mysqlpostgres需要,默认是127.0.0.1:3306
  23. namegrafana的数据库名称,默认是grafana
  24. user:连接数据库的用户
  25. password:数据库用户的密码
  26. ssl_mode:只是postgres使用
  27.  
  28. [security]
  29. admin_usergrafana默认的admin用户,默认是admin
  30. admin_passwordgrafana admin的默认密码,默认是admin
  31. login_remember_days:多少天内保持登录状态
  32. secret_key:保持登录状态的签名
  33. disable_gravatar
  34.  
  35. [users]
  36. allow_sign_up:是否允许普通用户登录,如果设置为false,则禁止用户登录,默认是true,则admin可以创建用户,并登录grafana
  37. allow_org_create:如果设置为false,则禁止用户创建新组织,默认是true
  38. auto_assign_org:当设置为true的时候,会自动的把新增用户增加到id1的组织中,当设置为false的时候,新建用户的时候会新增一个组织
  39. auto_assign_org_role:新建用户附加的规则,默认是Viewer,还可以是AdminEditor
  40.  
  41. [auth.anonymous]
  42. enabled:设置为true,则开启允许匿名访问,默认是false
  43. org_name:为匿名用户设置组织名称
  44. org_role:为匿名用户设置的访问规则,默认是Viewer
  45.  
  46. [auth.github]
  47. 针对github项目的,很明显,呵呵
  48. enabled = false
  49. allow_sign_up = false
  50. client_id = some_id
  51. client_secret = some_secret
  52. scopes = user:email
  53. auth_url = https://github.com/login/oauth/authorize
  54. token_url = https://github.com/login/oauth/access_token
  55. api_url = https://api.github.com/user
  56. team_ids =
  57. allowed_domains =
  58. allowed_organizations =
  59.  
  60. [auth.google]
  61. 针对google app的,呵呵
  62. enabled = false
  63. allow_sign_up = false
  64. client_id = some_client_id
  65. client_secret = some_client_secret
  66. scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
  67. auth_url = https://accounts.google.com/o/oauth2/auth
  68. token_url = https://accounts.google.com/o/oauth2/token
  69. api_url = https://www.googleapis.com/oauth2/v1/userinfo
  70. allowed_domains =
  71.  
  72. [auth.basic]
  73. enabled:当设置为true,则http api开启基本认证
  74.  
  75. [auth.ldap]
  76. enabled:设置为true则开启LDAP认证,默认是false
  77. config_file:如果开启LDAP,指定LDAP的配置文件/etc/grafana/ldap.toml
  78.  
  79. [auth.proxy]
  80. 允许你在一个HTTP反向代理上进行认证设置
  81. enabled:默认是false
  82. header_name:默认是X-WEBAUTH-USER
  83. header_property:默认是个名称username
  84. auto_sign_up:默认是true。开启自动注册,如果用户在grafana DB中不存在
  85.  
  86. [analytics]
  87. reporting_enabled:如果设置为true,则会发送匿名使用分析到stats.grafana.org,主要用于跟踪允许实例、版本、dashboard、错误统计。默认是true
  88. google_analytics_ua_id:使用GA进行分析,填写你的GA ID即可
  89.  
  90. [dashboards.json]
  91. 如果你有一个系统自动产生json格式的dashboard,则可以开启这个特性试试
  92. enabled:默认是false
  93. path:一个全路径用来包含你的json dashboard,默认是/var/lib/grafana/dashboards
  94.  
  95. [session]
  96. provider:默认是file,值还可以是memorymysqlpostgres
  97. provider_config:这个值的配置由provider的设置来确定,如果providerfile,则是data/xxxx路径类型,如果providermysql,则是user:password@tcp(127.0.0.1:3306)/database_name,如果providerpostgres,则是user=a password=b host=localhost port=5432 dbname=c sslmode=disable
  98. cookie_namegrafanacookie名称
  99. cookie_secure:如果设置为true,则grafana依赖https,默认是false
  100. session_life_timesession过期时间,默认是86400秒,24小时
  101.  
  102. 以下是官方文档没有,配置文件中有的
  103. [smtp]
  104. enabled = false
  105. host = localhost:25
  106. user =
  107. password =
  108. cert_file =
  109. key_file =
  110. skip_verify = false
  111. from_address = admin@grafana.localhost
  112.  
  113. [emails]
  114. welcome_email_on_sign_up = false
  115. templates_pattern = emails/*.html
  116.  
  117. [log]
  118. mode:可以是console、file,默认是console、file,也可以设置多个,用逗号隔开
  119. buffer_len:channel的buffer长度,默认是10000
  120. level:可以是"Trace", "Debug", "Info", "Warn", "Error", "Critical",默认是info
  121.  
  122. [log.console]
  123. level:设置级别
  124.  
  125. [log.file]
  126. level:设置级别
  127. log_rotate:是否开启自动轮转
  128. max_lines:单个日志文件的最大行数,默认是1000000
  129. max_lines_shift:单个日志文件的最大大小,默认是28,表示256MB
  130. daily_rotate:每天是否进行日志轮转,默认是true
  131. max_days:日志过期时间,默认是7,7天后删除

附12 grafana配置文件的更多相关文章

  1. 【附12】grafana配置文件

    一.配置文件位置 /usr/local/opt/grafana/share/grafana/default.ini /usr/local/etc/grafana/grafana.ini 二.init格 ...

  2. Grafana配置文件

    配置文件位置 /usr/local/opt/grafana/share/grafana/default.ini /usr/local/etc/grafana/grafana.ini 配置文件调用顺序 ...

  3. nginx.conf(centos6, 1.12)主配置文件修改

    #nginx1.12 centos6.xuser admin admin;worker_processes 4; error_log /data/services/logs/nginx_error.l ...

  4. 附001.etcd配置文件详解

    一 示例yml配置文件 # This is the configuration file for the etcd server.   # Human-readable name for this m ...

  5. Gvim打造python编辑器,附自己的配置文件

    一. Gvim简介 Gvim的G指的是GUI,也就是图形化界面.相当于在vim包了一层图形化界面,相比之下gvim拥有更丰富的颜色和字体,还有菜单和滚动条,以及更友好的鼠标操作等,除此之外和vim并无 ...

  6. 【SpringBoot】12.全局配置文件(properties)与yml配置文件

    一.SpringBoot全局配置文件 1.修改内嵌容器端口号 #application.properties server.port=8888 2.自定义属性的配置 使用@Value来给成员变量赋值 ...

  7. grafana 的配置文件,和使用mysql数据库做持久化

    grafana 配置文件 vim /etc/grafana/grafana.ini 下面有些参数在新版中6.x版本中已经过时,请参考下面官网最新帮助文档为准 https://grafana.com/d ...

  8. 【jmeter】基于InfluxDB&Grafana的JMeter实时性能测试数据的监控和展示

    本文主要讲述如何利用JMeter监听器Backend Listener,配合使用InfluxDB+Grafana展示实时性能测试数据 关于JMeter实时测试数据 JMeter从2.11版本开始,命令 ...

  9. influxDB1.6版安装与配置(windows环境)、Jmeter+influxDB+Grafana性能监控

    influxDB1.6版安装与配置(windows环境).Jmeter+influxDB+Grafana性能监控 来源:https://blog.csdn.net/SwTesting/article/ ...

随机推荐

  1. 获取本机MAC地址

    <%@ page contentType="text/html; charset=GBK" %><html><head><meta htt ...

  2. Online Object Tracking: A Benchmark 翻译

    来自http://www.aichengxu.com/view/2426102 摘要 目标跟踪是计算机视觉大量应用中的重要组成部分之一.近年来,尽管在分享源码和数据集方面的努力已经取得了许多进展,开发 ...

  3. coderforces719b

    题目大意:给定一个字符串,这个字符串中只有“r”和"b"组成,每次操作只能交换两个字符的位置或者将一个字符由"r"变"b"(或由" ...

  4. Glide 下载Gif文件

    之前做了一个类似朋友圈里的查看大图功能,现在也要加上保存功能. 保存图片有很多思路,可以从imageview里提取bitmap,可以用url下载到本地.imageview提取的话,gif图就会变成一张 ...

  5. State Machine.(状态机)

    What is a State Machine? Any device that changes its state from one to another due to some actions a ...

  6. 安装Yii框架时init.bat闪退的处理方法

    已经开启了php_openssl扩展还是会闪退 1.右击'计算机'-'属性'-'高级系统属性'-'环境变量(最下边)': 2.在'系统变量'里找到'path',双击,出现'编辑系统变量',在'变量值' ...

  7. PHP下的命令行执行 php -S localhost -t public

    PHP 的命令行模式     以下是 PHP 二进制文件(即 php.exe 程序)提供的命令行模式的选项参数,您随时可以通过 PHP -h 命令来查询这些参数. Usage: php [option ...

  8. mysql备份还原数据库

    1.备份数据库 mysqldump -u root -p test>/home/victor/test.sql 说明:如果提示找不到mysqldump命令,先用一条find命令查找mysqldu ...

  9. CRM 2016 subgrid 的显示隐藏

    function OnLoad() { //这里隐藏添加子记录的(+) 号按钮 hide_add_btn(); //这里隐藏鼠标在子记录上时的(删除)按钮 hide_del_btn(); //这里处理 ...

  10. ThinkPHP5.0完全开发手册

    http://www.kancloud.cn/manual/thinkphp5/118006 www  WEB部署目录(或者子目录) ├─composer.json         composer定 ...