【Grafana】Grafana安装

Posted by 西维蜀黍 on 2021-08-21, Last Modified on 2022-04-01

安装

Ubuntu

$ sudo apt-get install -y apt-transport-https
$ sudo apt-get install -y software-properties-common wget
$ wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -

Add this repository for stable releases:

$ echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list 

After you add the repository:

$ sudo apt-get update
$ sudo apt-get install grafana

macOS

$ brew update
$ brew install grafana

启动

Linux

# 查看服务状态
$ sudo systemctl status grafana-server   
# 启动服务
$ sudo systemctl start grafana-server  
# 开机自启动
$ sudo systemctl enable grafana-server 

macOS

# start
$ brew services start grafana
# stop
$ brew services stop grafana

  • http://192.168.2.204:3000/login
  • 默认管理员账号和密码 admin admin

Docker

# 如果希望设置为在宿主机开机后,这个 grafana Docker instance 也一直运行
# 不能用sudo,如果用sudo,可能出现在当前用户下docker ps后看不到已经启动的instance
$ docker run -d \
--restart unless-stopped \
-p 3000:3000 \
--name grafana \
-v /etc/localtime:/etc/localtime:ro \
-v /etc/timezone:/etc/timezone \
grafana/grafana

默认管理员账号和密码都是 admin。

Debug

如果无法连接上Prometheus,则可以将 Grafana container和 Prometheus container加入到同一个 docker network,具体参考 https://swsmile.info/post/docker-container-network/

Reference