# doc-grafana+loki+promtail **Repository Path**: tasbox/doc-grafana-loki-promtail ## Basic Information - **Project Name**: doc-grafana+loki+promtail - **Description**: grafana+loki+promtail 安装教程 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 0 - **Created**: 2021-06-18 - **Last Updated**: 2024-02-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # grafana + loki + promtail 安装教程 ## [程序下载](https://github.com/grafana/loki/releases/) ## [官方文档](https://grafana.com/docs/loki/latest/installation/local/) ## 注意事项 1.注意端口占用和防火墙,测试阶段可以把端口全部开了,防止出错。 ## 安装所需插件 ### **unzip** ```shell yum -y install unzip ``` ## loki 日志处理程序 ### 下载程序 ```shell wget https://github.com/grafana/loki/releases/download/v2.2.1/loki-linux-amd64.zip ``` ### **解压程序** ```shell unzip loki-linux-amd64.zip ``` ### 下载配置文件 ```shell wget https://raw.githubusercontent.com/grafana/loki/master/cmd/loki/loki-local-config.yaml ``` ### 启动程序 ```shell nohup ./loki-linux-amd64 -config.file=loki-local-config.yaml & ``` ### 浏览器访问 ```http http://localhost:3100/metrics ``` ## promtail 日志收集程序 ### 下载程序 #### linux ```shell wget https://github.com/grafana/loki/releases/download/v2.2.1/promtail-linux-amd64.zip ``` ##### 解压程序 ```shell unzip promtail-linux-amd64.zip ``` #### windows > windows 看这里,不要管上面的linux,但是配置文件都是同一个。 ```HTTP https://github.com/grafana/loki/releases/download/v2.2.1/promtail-windows-amd64.exe.zip ``` > windows 解压出来就只有一个exe程序 **windows运行程序** ```shell .\promtail-windows-amd64.exe --config.file=promtail-local-config.yaml ``` ### 下载配置文件 ```shell wget https://raw.githubusercontent.com/grafana/loki/main/clients/cmd/promtail/promtail-local-config.yaml ``` ### 启动程序 ```shell nohup ./promtail-linux-amd64 -config.file=promtail-local-config.yaml & ``` ### 浏览器访问 ```http http://localhost:9080/ ``` ## grafana 日志UI展示 ### [官方文档](https://grafana.com/grafana/download) ### 下载程序 ```shell wget https://dl.grafana.com/oss/release/grafana-8.0.2-1.x86_64.rpm ``` ### 安装程序 ```shell yum install -y grafana-8.0.2-1.x86_64.rpm ``` ### 更新配置 ```shell systemctl daemon-reload ``` ### 设置自启 ```shell systemctl enable grafana-server ``` ### 常用命令 ```shell # 启动 systemctl start grafana-server # 查看状态 systemctl status grafana-server # 重新启动 systemctl restart grafana-server # 停止 systemctl stop grafana-server ``` ### 浏览器访问 > 第一次登录时账号和密码都是`admin` > > 登录成功后就会提示设置管理员密码 ```http http://localhost:3000/ ``` ## 配置loki ![image-20210618001653444](/grafana%20labs.assets/image-20210618001653444.png) ![image-20210618001717046](/grafana%20labs.assets/image-20210618001717046.png) ![image-20210618001802916](/grafana%20labs.assets/image-20210618001802916.png) ![image-20210618001825698](/grafana%20labs.assets/image-20210618001825698.png) ![image-20210618002004176](/grafana%20labs.assets/image-20210618002004176.png) ![image-20210618002031005](/grafana%20labs.assets/image-20210618002031005.png) ![image-20210618002107064](/grafana%20labs.assets/image-20210618002107064.png) ![image-20210618002134459](/grafana%20labs.assets/image-20210618002134459.png) ![image-20210618002151908](/grafana%20labs.assets/image-20210618002151908.png) ![image-20210618002214979](/grafana%20labs.assets/image-20210618002214979.png) ![image-20210618002223734](/grafana%20labs.assets/image-20210618002223734.png) 现在你看见的就是最基本的数据,因为在loki搭建的时候,开启的promtail日志收集工具,所以这里有数据,你可以登录http://localhost:9080/ 查看你的配置信息。 ## 总结 安装过程到这里就结束了,接下来还有一些高级操作,我也不会。