28.grafana配置

发表于 linux 分类,标签:

grafana一般是和一些时间序列数据库进行配合来展示数据的,例如:Graphite、OpenTSDB、InfluxDB等

grafana是用于可视化大型测量数据的开源程序,他提供了强大和优雅的方式去创建、共享、浏览数据。dashboard中显示了你不同metric数据源中的数据。

grafana最常用于因特网基础设施和应用分析,但在其他领域也有机会用到,比如:工业传感器、家庭自动化、过程控制等等。

grafana有热插拔控制面板和可扩展的数据源,目前已经支持Graphite、InfluxDB、OpenTSDB、Elasticsearch。

grafana安装:

http://docs.grafana.org/installation/rpm/

 

grafana后端数据源配置:

http://docs.grafana.org/datasources/overview/

 

grafana的配置文件:

grafana后端的配置文件可以是多个以.ini结尾的配置文件,主要从三个配置文件读取配置:

默认是$WORKING_DIR/conf/defaults.ini,

其次用户配置是$WORKING_DIR/conf/custom.ini,用户配置则可以在命令行启动grafana时通过--config参数重新指定配置文件来覆盖。

如果你是以deb或者rpm安装的,则默认的配置文件是/etc/grafana/grafana.ini,这个文件是在init.d的启动脚本中通过--config参数指定的。 

所有在配置文件中的配置都可以通过环境变量来覆盖,使用的语法如下:GF_<SectionName>_<KeyName>,例如:

[security]

admin_user = admin


[auth.google]

client_secret = 0ldS3cretKey

如果使用环境变量,则是如下: 

export GF_SECURITY_ADMIN_USER=true

export GF_AUTH_GOOGLE_CLIENT_SECRET=newS3cretKey

配置文件详解:

app_mode:应用名称,默认是production

[path]
data:一个grafana用来存储sqlite3、临时文件、回话的地址路径
logs:grafana存储logs的路径

[server]
http_addr:监听的ip地址,,默认是0.0.0.0
http_port:监听的端口,默认是3000
protocol:http或者https,,默认是http
domain:这个设置是root_url的一部分,当你通过浏览器访问grafana时的公开的domian名称,默认是localhost
enforce_domain:如果主机的header不匹配domian,则跳转到一个正确的domain上,默认是false
root_url:这是一个web上访问grafana的全路径url,默认是%(protocol)s://%(domain)s:%(http_port)s/
router_logging:是否记录web请求日志,默认是false
cert_file:如果使用https则需要设置
cert_key:如果使用https则需要设置

[database]
grafana默认需要使用数据库存储用户和dashboard信息,默认使用sqlite3来存储,你也可以换成其他数据库
type:可以是mysql、postgres、sqlite3,默认是sqlite3
path:只是sqlite3需要,定义sqlite3的存储路径
host:只是mysql、postgres需要,默认是127.0.0.1:3306
name:grafana的数据库名称,默认是grafana
user:连接数据库的用户
password:数据库用户的密码
ssl_mode:只是postgres使用


[security]
admin_user:grafana默认的admin用户,默认是admin
admin_password:grafana admin的默认密码,默认是admin
login_remember_days:多少天内保持登录状态
secret_key:保持登录状态的签名
disable_gravatar:


[users]
allow_sign_up:是否允许普通用户登录,如果设置为false,则禁止用户登录,默认是true,则admin可以创建用户,并登录grafana
allow_org_create:如果设置为false,则禁止用户创建新组织,默认是true
auto_assign_org:当设置为true的时候,会自动的把新增用户增加到id为1的组织中,当设置为false的时候,新建用户的时候会新增一个组织
auto_assign_org_role:新建用户附加的规则,默认是Viewer,还可以是Admin、Editor


[auth.anonymous]
enabled:设置为true,则开启允许匿名访问,默认是false
org_name:为匿名用户设置组织名称
org_role:为匿名用户设置的访问规则,默认是Viewer


[auth.github]
针对github项目的
enabled = false
allow_sign_up = false
client_id = some_id
client_secret = some_secret
scopes = user:email
auth_url = https://github.com/login/oauth/authorize
token_url = https://github.com/login/oauth/access_token
api_url = https://api.github.com/user
team_ids =
allowed_domains =
allowed_organizations =


[auth.google]
针对google app
enabled = false
allow_sign_up = false
client_id = some_client_id
client_secret = some_client_secret
scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
auth_url = https://accounts.google.com/o/oauth2/auth
token_url = https://accounts.google.com/o/oauth2/token
api_url = https://www.googleapis.com/oauth2/v1/userinfo
allowed_domains =


[auth.basic]
enabled:当设置为true,则http api开启基本认证


[auth.ldap]
enabled:设置为true则开启LDAP认证,默认是false
config_file:如果开启LDAP,指定LDAP的配置文件/etc/grafana/ldap.toml


[auth.proxy]
允许你在一个HTTP反向代理上进行认证设置
enabled:默认是false
header_name:默认是X-WEBAUTH-USER
header_property:默认是个名称username
auto_sign_up:默认是true。开启自动注册,如果用户在grafana DB中不存在

[analytics]
reporting_enabled:如果设置为true,则会发送匿名使用分析到stats.grafana.org,主要用于跟踪允许实例、版本、dashboard、错误统计。默认是true
google_analytics_ua_id:使用GA进行分析,填写你的GA ID即可


[dashboards.json]
如果你有一个系统自动产生json格式的dashboard,则可以开启这个特性试试
enabled:默认是false
path:一个全路径用来包含你的json dashboard,默认是/var/lib/grafana/dashboards


[session]
provider:默认是file,值还可以是memory、mysql、postgres
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
cookie_name:grafana的cookie名称
cookie_secure:如果设置为true,则grafana依赖https,默认是false
session_life_time:session过期时间,默认是86400秒,24小时


以下是官方文档没有,配置文件中有的
[smtp]
enabled = false
host = localhost:25
user =
password =
cert_file =
key_file =
skip_verify = false
from_address = admin@grafana.localhost

[emails]
welcome_email_on_sign_up = false
templates_pattern = emails/*.html


[log]
mode:可以是console、file,默认是console、file,也可以设置多个,用逗号隔开
buffer_len:channel的buffer长度,默认是10000
level:可以是"Trace", "Debug", "Info", "Warn", "Error", "Critical",默认是info

[log.console]
level:设置级别

[log.file]
level:设置级别
log_rotate:是否开启自动轮转
max_lines:单个日志文件的最大行数,默认是1000000
max_lines_shift:单个日志文件的最大大小,默认是28,表示256MB
daily_rotate:每天是否进行日志轮转,默认是true
max_days:日志过期时间,默认是7,7天后删除

启动grafana:

./grafana-server -config="/opt/grafana-2.1.3/conf/custom.ini"

初始化之后web访问 ip:3000端口


0 篇评论

发表我的评论