一篇关于grafana使用与原理的调研文档,点击下载。
正文
以下内容由word文档直接导入,虽然排版差劲一点,但是可以方便大家可以在线查阅。
Grafana配置与简单使用
下面简单记录一下grafana的使用流程。
安装
选择对应的平台,走wget下载二进制即可,别着急启动。
配置文件
解压后,conf目录下defaults.ini是默认配置文件,sample.ini是自定义配置,grafana启动时候需要-config指定加载sample.ini文件,并且会自动load同目录下的defaults.ini作为默认参数,千万不能删除defaults.ini,否则无法启动grafana。
database数据库
我改了一下数据库,grafana所有的配置都会存在数据库里,我用mysql:
[database]
# You can configure the database connection by specifying type, host, name, user and password
# as separate properties or as on string using the url properties.
# Either “mysql”, “postgres” or “sqlite3”, it’s your choice
type = mysql
host = 127.0.0.1:3306
name = grafana
user = root
# If the password contains # or ; you have to wrap it with triple quotes. Ex “””#password;”””
password = xxxxxyyyyy
注意,数据库提前建好:
create database grafana
数据表的话grafana会自动创建出来,Golang的ORM库大多这个风格。
Session登录会话
为了可以部署grafana集群,需要让session存在redis里共享:
[session]
# Either “memory”, “file”, “redis”, “mysql”, “postgres”, default is “file”
provider = redis
# Provider config options
# memory: not have any config yet
# file: session dir path, is relative to grafana data_path
# redis: config like redis server e.g. addr=127.0.0.1:6379,pool_size=100,db=grafana
# mysql: go-sql-driver/mysql dsn config string, e.g. user:password@tcp(127.0.0.1:3306)/database_name
# postgres: user=a password=b host=localhost port=5432 dbname=c sslmode=disable
provider_config = addr=127.0.0.1:6379,pool_size=100,db=grafana
简单配置一下就行。
Security安全
[security]
# default admin user, created on startup
admin_user = admin
# default admin password, can be changed before first start of grafana, or in profile settings
admin_password = admin
默认管理员是admin,admin,也可以登录后修改,届时帐号密码就保存到mysql里了。
认证系统
支持基于数据库的用户系统,或者LDAP,以及github等第三方登录。
默认走数据库。
Ldap相关的:
#################################### Auth LDAP ##########################
[auth.ldap]
;enabled = false
;config_file = /e