当前位置: 首页 > news >正文

Grafana loki部署及使用及问题处理方法(超详细)

一、下载软件

因为我是本地测试,所以用的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.file=loki-local-config.yaml

在根目录下新增promtail的启动的windows命令行脚本,内容如下:

.\promtail-windows-amd64.exe --config.file=promtail-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

 点击下面的Save&test,若提示“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的日志文件,秒极返回查询结果

 

 

http://www.lryc.cn/news/8125.html

相关文章:

  • vue项目如何使用 SheetJS(xlsx)插件?
  • 项目管理工具dhtmlxGantt甘特图入门教程(九):支持哪些数据格式(上篇)
  • iView Table合并单元格(行、列)
  • 如何用P6软件编制项目进度计划(下)
  • 环境配置完整指导——Installing C++ Distributions of PyTorch
  • 深度学习——自注意力机制和位置编码(笔记)
  • 内网渗透(三十)之横向移动篇-利用远控工具向日葵横向移动
  • 自动化测试中,该如何高效管理测试数据?
  • Qt中项目A调用另一个项目B的方法汇总
  • 【项目精选】基于Javaee的影视创作论坛的设计与实现(视频+论文+源码)
  • 深入【虚拟列表】动态高度、缓冲、异步加载... Vue实现
  • Windows 11 + WSL(ubuntu 20.04) + CLion(2022.3) 编译OpenJDK12
  • Freemarker 语法精粹
  • 使用Benchto框架对Trino进行SQL性能对比测试
  • Redis之哨兵模式
  • Selenium自动化测试Python二:WebDriver基础
  • 蓝桥杯模块学习17——AT24C02存储器(深夜学习——单片机)
  • netty
  • Django项目部署-uWSGI
  • jhipster自动生成java代码的方法
  • LeetCode 82. 删除排序链表中的重复元素 II
  • tensorflow gpu环境安装
  • 如何在现实场景中随心放置AR虚拟对象?
  • 操作系统-处理机调度
  • 手机截图如何提取文字?
  • vue中复制内容
  • MySQL CAST()函数用法
  • 【测试工程师面试】详细记录 自己的一次面试
  • Elasticsearch 安装(二)
  • Java基础:异常与错误(ExceptionError)