liusheng / liusheng.github.io

Liusheng's blog
http://liusheng.github.io
5 stars 1 forks source link

graphite and grafana #9

Open liusheng opened 5 years ago

liusheng commented 5 years ago

使用如下命令可以重置grafana的管理员密码

sudo sqlite2 /var/lib/grafana/grafana.db
update user set password = '59acf18b94d7eb0694c61e60ce44c110c7a683ac6a8f09580d626f90f4a242000746579358d77dd9e570e83fa24faa88a8a6', salt = 'F3FAxVm33R' where login = 'admin';

注意:如果只是暂时重置管理员密码,最好记录下之前的password字符串以及对应的salt,等操作完成后,可以再重置回去。

TroubleShooting

在执行更新grafana的panels的时候提示401错误 http://docs.grafana.org/installation/configuration/#session

将grafana的session的provider配置为mysql而不是默认的file /etc/grafana/grafana.ini

create database grafana;
GRANT ALL PRIVILEGES ON grafana.* TO 'grafana'@'localhost' IDENTIFIED BY 'grafana';
GRANT ALL PRIVILEGES ON grafana.* TO 'grafana'@'%' IDENTIFIED BY 'grafana';
CREATE TABLE `session` (
    `key`       CHAR(16) NOT NULL,
    `data`      BLOB,
    `expiry`    INT(11) UNSIGNED NOT NULL,
    PRIMARY KEY (`key`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

provider_config = grafana:grafana@tcp(127.0.0.1:3306)/grafana

grafana-dashboard update /opt/project-config/grafana/nodepool.yaml grafana-dashboard update /opt/project-config/grafana/zuul-status.yaml

如果报No 'Access-Control-Allow-Origin' header is present类似于这样的错误,则需要在graphite的apache配置文件中加上

Header set Access-Control-Allow-Origin    "http://mygrafana.com:5656"
Header set Access-Control-Allow-Methods   "GET, OPTIONS"
Header set Access-Control-Allow-Headers   "origin, authorization, accept"
Header set Access-Control-Allow-Credentials true

并且a2enmod headers, 然后重启apache