Dashboard and graph editor Grafana

Grafana in detail

Grafana is a   dashboard and graph editor for Graphite  and  InfluxDB . Grafana is an open source, full-featured metrics dashboard and graph editor that supports Graphite, InfluxDB and  OpenTSDB .

Grafana main features: flexible and rich graphical options; multiple styles can be mixed; support for day and night modes; multiple data sources; Graphite and InfluxDB query editors, and more.

Graphite metrics editor

  • Graphite metrics expression parser

  • Full-featured query function

  • Quickly add and edit functions and parameters

  • templated query

  • See it in action

Graphical

  • Fast rendering, even with large time spans

  • Click and drag to zoom

  • Multiple Y axes 

  • Bar, Polyline, Point 

  • Smart Y-axis formatting

  • Series switching and color selection 

  • Legend values ​​and formatting options

  • grid threshold, axis labels

  • Annotations

dash board

  • Create, edit, save and search dashboards

  • Modify column width and row height

  • Drag and drop panels to rearrange

  • Use InfluxDB or Elasticsearch as dashboard storage

  • Import and export dashboards (JSON files)

  • Import Dashboards from Graphite

  • template

  • Scripted dashboards

  • Dashboard playlists

  • time frame control

What is Grafana? A Kibana-like thing also displays the back-end data in real time, so what is the difference between Grafana and Kibana? In my opinion, the difference is not big, but in everyone's daily use, Kibana is used together with Logstash, ElasticSearch and other components for log display, indexing, and analysis, creating an illusion that Kibana only has this usage, and Kibana also You can access other data sources, but the longest you use is to display logs. What is Grafana? You may not have heard of this project, and it is relatively young. It usually cooperates with some time series databases to display data, such as Graphite, OpenTSDB, InfluxDB, etc. Let's see how the official explains Grafana:

  • Grafana is an open source program for visualizing large measurement data, which provides a powerful and elegant way to create, share, and browse data. The dashboard displays data from your different metric data sources.
  • Grafana is most commonly used for Internet infrastructure and application analysis, but there are opportunities in other areas as well, such as: industrial sensors, home automation, process control, and more.
  • Grafana has a hot-pluggable control panel and extensible data sources, and currently supports Graphite, InfluxDB, OpenTSDB, and Elasticsearch.

Let's practice and install first:

    Grafana officially has packaged deb and rpm packages and compiled binary packages, and grafana also supports Mac OS X, windows, etc. The download page is at: download

    As the first attempt, we choose the compiled binary package: grafana-2.1.3.linux-x64.tar.gz, and then you can choose deb or rpm after you are proficient. After decompressing the binary package, go to the conf directory, which contains a defaults.ini file. In the conf directory of grafana, rename the defaults.ini configuration file to custom.ini. Enter the bin directory of grafana, there is a grafana-server binary file, directly execute ./grafana-server web to start the application. More detailed installation here: here

grafana and LDAP integration:

    Unfortunately, our company does not have the habit of using AD/LDAP. See the process here: here

Batch installation configuration:

    Grafana supports the installation of puppet, ansible, docker, chef, etc. It feels useless and will not be introduced.

grafana backend data source configuration:

    Grafana mainly supports some time series databases. We are investigating influxdb, so we take influxdb as an example. The interface is configured with a little bit. The main process is here: here


grafana configuration file:

    The configuration file of the grafana backend can be multiple configuration files ending with .ini, and the configuration is mainly read from three configuration files: the default is $WORKING_DIR/conf/defaults.ini, and the second user configuration is $WORKING_DIR/conf/custom.ini , the user configuration can be overridden by re-specifying the configuration file through the --config parameter when starting grafana on the command line. If you installed it by deb or rpm, the default configuration file is /etc/grafana/grafana.ini, which is specified by the --config parameter in the init.d startup script.    

    All configurations in the configuration file can be overridden by environment variables, using the following syntax: GF_<SectionName>_<KeyName>, for example:

[security]
admin_user = admin

[auth.google]
client_secret = 0ldS3cretKey
    If you use environment variables, it is as follows: 

export GF_SECURITY_ADMIN_USER=true
export GF_AUTH_GOOGLE_CLIENT_SECRET=newS3cretKey
Let's take a look at the configuration of each configuration section in detail:

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天后删除
Start grafana:

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


    The following is the initialization process, there will be a large output, and it will not be initialized when grafana is restarted again:


Visit grafana below to see:

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325861042&siteId=291194637