为什么要给企业建设网站,百度提交链接,网站 工作室 建设 方案,织梦协会网站模板一、下载软件
因为我是本地测试#xff0c;所以用的windows版本的包#xff0c;loki服务window版本的安装包下载地址#xff1a;下载地址#xff0c;选择
promtail-windows版本的安装包下载地址#xff1a;下载地址 Grafana服务的下载地址#xff1a;下载地址
二、配置…一、下载软件
因为我是本地测试所以用的windows版本的包loki服务window版本的安装包下载地址下载地址选择
promtail-windows版本的安装包下载地址下载地址 Grafana服务的下载地址下载地址
二、配置文件
在解压后的根目录下新建loki-local-config.yaml配置文件内容如下
auth_enabled: falseserver: http_listen_port: 3100ingester: lifecycler: address: 127.0.0.1ring:kvstore: store: inmemoryreplication_factor: 1final_sleep: 0schunk_idle_period: 5mchunk_retain_period: 30smax_transfer_retries: 0schema_config: configs: - from: 2022-02-15store: boltdbobject_store: filesystemschema: v11index: prefix: index_period: 168hstorage_config: boltdb: directory: /tmp/loki/indexfilesystem: directory: /tmp/loki/chunkslimits_config: enforce_metric_name: falsereject_old_samples: truereject_old_samples_max_age: 168hchunk_store_config: max_look_back_period: 0stable_manager: retention_deletes_enabled: falseretention_period: 0s新增promtail-local-config.yaml配置文件内容如下
server: http_listen_port: 9080grpc_listen_port: 0positions: filename: /tmp/positions.yamlclients: - url: http://127.0.0.1:3100/loki/api/v1/pushscrape_configs:
- job_name: systemstatic_configs: - targets:- 127.0.0.1labels: job: testlogs
#第1个监控日志目录__path__: C:\Users\Administrator\Desktop\fsdownload\*.log
- job_name: system1static_configs: - targets:- 127.0.0.1labels:
#第2个监控日志目录job: alogs__path__: D:\work\product\MES\windows-pro\logs\*.log三、创建启动脚本
在根目录下新增loki的启动的windows命令行脚本内容如下
.\loki-windows-amd64.exe --config.fileloki-local-config.yaml
在根目录下新增promtail的启动的windows命令行脚本内容如下
.\promtail-windows-amd64.exe --config.filepromtail-local-config.yaml
四、配置loki
安装好Grafana后先启动上面的loki服务后启动promtail服务浏览器访问grafana地址http://127.0.0.1:3000/ 点击左下角的设置图标选择Configuration Add Data source选择loki 输入loki的URL默认就是http://127.0.0.1:3100 点击下面的Savetest,若提示“Data source connected, but no labels received. Verify that Loki and Promtail is configured properly.”检查上面配置的promtail-local-config.yaml中的“_path_”路径是否存在若test成功则会有如下测试 五、验证效果
点击左侧工具栏选择Explore 选择要查询的日志标签然后输入要搜索的日志文本内容点击回国或右上角的“Run query” 1.64G的日志文件秒极返回查询结果