# Monitor-your-Nubit-lightnode

By [Loki11](https://paragraph.com/@loki11) · 2024-07-01

---

监控你的轻节点，方便查看在线时长

1.安装prometheus和prometheus node exporter

（Install prometheus and prometheus node exporter）

    sudo apt-get install -y prometheus prometheus-node-exporter
    

2.创建prometheus配置文件

（Create the prometheus.yml config file）

    cat > $HOME/prometheus.yml << EOF
    global:
      scrape_interval: 15s
      evaluation_interval: 15s
    
    rule_files:
      # - "first.rules"
      # - "second.rules"
    
    scrape_configs:
      - job_name: "prometheus"
        scrape_interval: 5s
        static_configs:
          - targets: ["localhost:9090"]
      - job_name: "nubit_node"
        scrape_interval: 5s
        static_configs:
          - targets: ["localhost:9615"]
      - job_name: node
        static_configs:
          - targets: ['localhost:9100']
    EOF
    

3.把配置文件移动到/etc/prometheus/目录

（Move `prometheus.yml` to the correct location）

    sudo mv $HOME/prometheus.yml /etc/prometheus/prometheus.yml
    

4.给文件添加权限

（Update the file permissions）

    sudo chmod 644 /etc/prometheus/prometheus.yml
    

5.启动prometheus服务

（enable prometheus service and start)

    sudo systemctl enable prometheus.service prometheus-node-exporter.service
    sudo systemctl restart prometheus.service prometheus-node-exporter.service
    

6.查看服务状态

（Check the status, ensure Prometheus has started without errors）

    sudo systemctl status prometheus.service prometheus-node-exporter.service
    

7.安装Grafana

（Install Grafana）

    wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
    echo "deb https://packages.grafana.com/oss/deb stable main" > grafana.list
    sudo mv grafana.list /etc/apt/sources.list.d/grafana.list
    sudo apt-get update && sudo apt-get install -y grafana
    

8.启动Grafana服务

（enable Grafana service and start）

    sudo systemctl enable grafana-server.service
    sudo systemctl start grafana-server.service
    

9.查看服务状态

（Check the status, ensure Grafana has started without errors）

    sudo systemctl status grafana-server.service
    

10.开放3000端口

（Ensure port 3000 is open）

    sudo ufw allow 3000/tcp
    

11.打开浏览器，输入

http://<你的IP地址>:3000

（In your browser navigate to http://:3000） 12.输入密码，默认密码是admin/admin （The default login username and password is admin/admin） 13.找到**Home->Connections->Data sources** （Navigate to **Home->Connections->Data sources**） 点击Add new data source选择prometheus （Click on \*\*Add data source，\*\*Click on **Prometheus）** 在**Prometheus server URL 一栏中填** [http://localhost:9090](http://localhost:9090) ，填完拖动到页面底下点击 Save and test按键（Set URL to "localhost:9090", then test and save the connection） 14.回到Home页面，点击右边的**Import dashboard** （Navigate back to your home page, on the top right in the menu select **Import dashboard）** 15.下载下面的模板文件导入到**dashboard里面** （Download the node metrics file and import dashboard) [https://github.com/lokiboss1/Nubit-Light-Node-Monitor-dashboardfile](https://github.com/lokiboss1/Nubit-Light-Node-Monitor-dashboardfile) 16.现在就可以看到你的Uptime了。觉得有用的话可以给我点个关注 （You can check your uptime now) [https://x.com/lokiever11](https://x.com/lokiever11)

---

*Originally published on [Loki11](https://paragraph.com/@loki11/monitor-your-nubit-lightnode)*
