哈尔滨网站设计公司哪家更好,郑州百度seo,江苏住房城乡建设部部官方网站,手机网站建设模板下载一、简介
Loki是受Prometheus启发由Grafana Labs团队开源的水平可扩展#xff0c;高度可用的多租户日志聚合系统。 开发语言: Google Go。它的设计具有很高的成本效益#xff0c;并且易于操作。使用标签来作为索引#xff0c;而不是对全文进行检索#xff0c;也就是说高度可用的多租户日志聚合系统。 开发语言: Google Go。它的设计具有很高的成本效益并且易于操作。使用标签来作为索引而不是对全文进行检索也就是说你通过这些标签既可以查询日志的内容也可以查询到监控的数据签极大地降低了日志索引的存储。系统架构十分简单由以下3个部分组成
Loki 是主服务器负责存储日志和处理查询
promtail 是代理负责收集日志并将其发送给 loki
Grafana 用于 UI 展示
只要在应用程序服务器上安装promtail来收集日志然后发送给Loki存储就可以在Grafana UI界面通过添加Loki为数据源进行日志查询如果Loki服务器性能不够可以部署多个Loki进行存储及查询。作为一个日志系统不光只有查询分析日志的能力还能对日志进行监控和报警。 promtail收集并将日志发送给loki的 Distributor 组件 Distributor会对接收到的日志流进行正确性校验并将验证后的日志分批并行发送到Ingester Ingester 接受日志流并构建数据块压缩后存放到所连接的存储后端 Querier 收到HTTP查询请求并将请求发送至Ingester 用以获取内存数据 Ingester 收到请求后返回符合条件的数据 如果 Ingester 没有返回数据Querier 会从后端存储加载数据并遍历去重执行查询 通过HTTP返回查询结果 二、下载安装
1.下载
https://github.com/grafana/loki/releases
loki-linux-amd64.zip
promtail-linux-amd64.zip2.创建目录并解压
mkdir loki
cd loki
mkdir chunks
mkdir index
unzip loki-linux-amd64.zip3.创建配置文件vim config.yaml
# This is a complete configuration to deploy Loki backed by the filesystem.
# The index will be shipped to the storage via tsdb-shipper.auth_enabled: falseserver:http_listen_port: 3100common:ring:instance_addr: 172.17.0.122kvstore:store: inmemoryreplication_factor: 1path_prefix: /data/prometheus/lokischema_config:configs:- from: 2024-07-10store: tsdbobject_store: filesystemschema: v13index:prefix: index_period: 24hstorage_config:filesystem:directory: /data/prometheus/loki/chunks4.启动Loki
nohup loki-linux-amd64 -config.fileconfig.yaml loki.log 21 5.应用服务器安装promtail
mkdir promtail
unzip promtail-linux-amd64.zip6.创建配置文件vim promtail.yaml
server:http_listen_port: 9080grpc_listen_port: 0positions:filename: ./positions.yamlclients:- url: http://172.17.0.122:3100/loki/api/v1/pushscrape_configs:- job_name: ehrstatic_configs:- targets:- 172.17.0.112- labels:job: ehrhost: 172.17.0.112__path__: /data/ehr/output.log #应用服务日志7.启动promtail
nohup ./promtail-linux-amd64 -config.file./promtail.yaml ./promtail.log 21 8.grafana操作
连接-》数据源-》添加新数据源-》选择loki-》填写loki地址并保存-》数据源列表loki点击Explore-》label fiters下选择job以及promtail中的job_name-》右上角运行查询之后可导入仪表板进行查看