chkconfig grafana-server on
service grafana-server start
配置:
http://docs.grafana.org/installation/configuration/#database
配置文件里分段给出了非常详细的说明,非常人性化
默认使用的是sqlite3,这里调整为mysql
1.创建数据库和用户
CREATE DATABASE grafana DEFAULT CHARACTER SET utf8;
GRANT ALL ON grafana.* TO grafana@'localhost' IDENTIFIED BY 'grafanapassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
2.指定数据库及认证信息
cp /etc/grafana/grafana.ini{,.default}
vim /etc/grafana/grafana.ini
[database]
# Either "mysql", "postgres" or "sqlite3", it's your choice
type = mysql
host = 127.0.0.1:3306
name = grafana
user
=
password = grafanapassword
# For "postgres" only, either "disable", "require" or "verify-full"
ssl_mode = true
ca_cert_path = /opt/mariadb/mariadb-ca.pem
client_key_path = /opt/mariadb/mariadb-client.key
client_cert_path = /opt/mariadb/mariadb-client.pem
server_cert_name = jlive.example.com
[session]
# Either "memory", "file", "redis", "mysql", "postgres", default is "file"
provider = redis
provider_config = addr=127.0.0.1:6379,pool_size=100,db=grafana
cookie_name = grafana_sess
cookie_secure = false
session_life_time = 86400
3.重启grafana
service grafana-server restart
tail -f /var/log/grafana/grafana.log
2016/05/01 15:40:25 [I] Starting Grafana
2016/05/01 15:40:25 [I] Version: 3.0.0-beta6, Commit: v3.0.0-beta6, Build date: 2016-04-29 14:40:53 +0800 CST
2016/05/01 15:40:25 [I] Configuration Info
Config files:
Command lines overrides:
Paths:
2016/05/01 15:40:25 [I] Database: mysql
2016/05/01 15:40:25 [I] Migrator: Starting DB migration
2016/05/01 15:40:25 [I] Migrator: exec migration id: create migration_log table
2016/05/01 15:40:25 [I] Migrator: exec migration id: create user table
2016/05/01 15:40:25 [I] Migrator: exec migration id: add unique index user.login
2016/05/01 15:40:25 [I] Migrator: exec migration id: add unique index user.email
2016/05/01 15:40:25 [I] Migrator: exec migration id: drop index UQE_user_login - v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: drop index UQE_user_email - v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: Rename table user to user_v1 - v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: create user table v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index UQE_user_login - v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index UQE_user_email - v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: copy data_source v1 to v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: Drop old table user_v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: create temp user table v1-7
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index IDX_temp_user_email - v1-7
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index IDX_temp_user_org_id - v1-7
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index IDX_temp_user_code - v1-7
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index IDX_temp_user_status - v1-7
2016/05/01 15:40:25 [I] Migrator: exec migration id: create star table
2016/05/01 15:40:25 [I] Migrator: exec migration id: add unique index star.user_id_dashboard_id
2016/05/01 15:40:25 [I] Migrator: exec migration id: create org table v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index UQE_org_name - v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: create org_user table v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index IDX_org_user_org_id - v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index UQE_org_user_org_id_user_id - v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: copy data account to org
2016/05/01 15:40:25 [I] Migrator: skipping migration id: copy data account to org, condition not fulfilled
2016/05/01 15:40:25 [I] Migrator: exec migration id: copy data account_user to org_user
2016/05/01 15:40:25 [I] Migrator: skipping migration id: copy data account_user to org_user, condition not fulfilled
2016/05/01 15:40:25 [I] Migrator: exec migration id: Drop old table account
2016/05/01 15:40:25 [I] Migrator: exec migration id: Drop old table account_user
2016/05/01 15:40:25 [I] Migrator: exec migration id: create dashboard table
2016/05/01 15:40:25 [I] Migrator: exec migration id: add index dashboard.account_id
2016/05/01 15:40:25 [I] Migrator: exec migration id: add unique index dashboard_account_id_slug
2016/05/01 15:40:25 [I] Migrator: exec migration id: create dashboard_tag table
2016/05/01 15:40:25 [I] Migrator: exec migration id: add unique index dashboard_tag.dasboard_id_term
2016/05/01 15:40:25 [I] Migrator: exec migration id: drop index UQE_dashboard_tag_dashboard_id_term - v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: Rename table dashboard to dashboard_v1 - v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: create dashboard v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index IDX_dashboard_org_id - v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index UQE_dashboard_org_id_slug - v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: copy dashboard v1 to v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: drop table dashboard_v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: alter dashboard.data to mediumtext v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: Add column updated_by in dashboard - v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: Add column created_by in dashboard - v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: create data_source table
2016/05/01 15:40:25 [I] Migrator: exec migration id: add index data_source.account_id
2016/05/01 15:40:25 [I] Migrator: exec migration id: add unique index data_source.account_id_name
2016/05/01 15:40:25 [I] Migrator: exec migration id: drop index IDX_data_source_account_id - v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: drop index UQE_data_source_account_id_name - v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: Rename table data_source to data_source_v1 - v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: create data_source table v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index IDX_data_source_org_id - v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index UQE_data_source_org_id_name - v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: copy data_source v1 to v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: Drop old table data_source_v1 #2
2016/05/01 15:40:25 [I] Migrator: exec migration id: Add column with_credentials
2016/05/01 15:40:25 [I] Migrator: exec migration id: create api_key table
2016/05/01 15:40:25 [I] Migrator: exec migration id: add index api_key.account_id
2016/05/01 15:40:25 [I] Migrator: exec migration id: add index api_key.key
2016/05/01 15:40:25 [I] Migrator: exec migration id: add index api_key.account_id_name
2016/05/01 15:40:25 [I] Migrator: exec migration id: drop index IDX_api_key_account_id - v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: drop index UQE_api_key_key - v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: drop index UQE_api_key_account_id_name - v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: Rename table api_key to api_key_v1 - v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: create api_key table v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index IDX_api_key_org_id - v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index UQE_api_key_key - v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index UQE_api_key_org_id_name - v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: copy api_key v1 to v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: Drop old table api_key_v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: create dashboard_snapshot table v4
2016/05/01 15:40:25 [I] Migrator: exec migration id: drop table dashboard_snapshot_v4 #1
2016/05/01 15:40:25 [I] Migrator: exec migration id: create dashboard_snapshot table v5 #2
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index UQE_dashboard_snapshot_key - v5
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index UQE_dashboard_snapshot_delete_key - v5
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index IDX_dashboard_snapshot_user_id - v5
2016/05/01 15:40:25 [I] Migrator: exec migration id: alter dashboard_snapshot to mediumtext v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: create quota table v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index UQE_quota_org_id_user_id_target - v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: create plugin_setting table
2016/05/01 15:40:25 [I] Migrator: exec migration id: create index UQE_plugin_setting_org_id_plugin_id - v1
2016/05/01 15:40:25 [I] Migrator: exec migration id: create session table
2016/05/01 15:40:25 [I] Migrator: exec migration id: Drop old table playlist table
2016/05/01 15:40:25 [I] Migrator: exec migration id: Drop old table playlist_item table
2016/05/01 15:40:25 [I] Migrator: exec migration id: create playlist table v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: create playlist item table v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: drop preferences table v2
2016/05/01 15:40:25 [I] Migrator: exec migration id: drop preferences table v3
2016/05/01 15:40:25 [I] Migrator: exec migration id: create preferences table v3
2016/05/01 15:40:25 [I] Created default admin user: admin
2016/05/01 15:40:25 [I] Creating json dashboard index for path: /var/lib/grafana/dashboards
2016/05/01 15:40:25 [I] Plugins: Scan starting
2016/05/01 15:40:25 [T] Checking for updates
2016/05/01 15:40:25 [I] Listen: http://0.0.0.0:3000
Dashboard
192.168.130.254:3000
默认用户名:admin
默认用户名密码:admin
登录后一片空白,所以需要安装相应插件
grafana-zabbix插件
https://github.com/alexanderzobnin/grafana-zabbix
http://play.grafana-zabbix.org/
http://docs.grafana-zabbix.org/installation/
http://docs.grafana-zabbix.org/installation/configuration/
1.安装插件
grafana-cli plugins install alexanderzobnin-zabbix-app
root@jlive:grafana#grafana-cli plugins install alexanderzobnin-zabbix-app
installing alexanderzobnin-zabbix-app @ 3.0.0-beta7
from url: https://grafana.net/api/plugins/alexanderzobnin-zabbix-app/versions/3.0.0-beta7/download
into: /var/lib/grafana/plugins
✔
Installed
alexanderzobnin-zabbix-app
successfully
Restart grafana after installing plugins .
root@jlive:grafana#service grafana-server restart
Restarting
grafana-server (via systemctl):
2.配置zabbix数据源
http://192.168.130.254/zabbix/api_jsonrpc.php
注意:api_jsonrpc.php是zabbix的API调用接口