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

查询做导员的网站定制衣柜设计方案

查询做导员的网站,定制衣柜设计方案,xampp wordpress 花生壳,万能本地视频播放器1. Loki简介 1.1 Loki介绍 Loki是 Grafana Labs 团队最新的开源项目#xff0c;是一个水平可扩展#xff0c;高可用性#xff0c;多租户的日志聚合系统。它的设计非常经济高效且易于操作#xff0c;因为它不会为日志内容编制索引#xff0c;而是为每个日志流编制一组标签…1. Loki简介 1.1 Loki介绍 Loki是 Grafana Labs 团队最新的开源项目是一个水平可扩展高可用性多租户的日志聚合系统。它的设计非常经济高效且易于操作因为它不会为日志内容编制索引而是为每个日志流编制一组标签。项目受 Prometheus 启发官方的介绍就是Like Prometheus, but for logs类似于 Prometheus 的日志系统。 1.2 Loki 的主要特点 水平可扩展性Loki 能够通过增加更多的节点来扩展其处理能力以应对不断增长的数据量。 高可用性设计上保证了系统的稳定性和可靠性即使在部分组件发生故障时也能继续运行。 多租户支持Loki 支持在同一个实例中为不同的用户提供隔离的日志数据存储和查询服务。 经济高效与传统的日志系统相比Loki 不会对日志内容进行全文索引而是通过为每个日志流创建一组标签来组织数据这大大减少了存储需求和提高了查询效率。 易于操作Loki 的设计理念是简单易用使得用户可以快速上手并有效地管理日志数据。 2. Loki部署 主机名作用系统IPV4master采集端CentOS 7.9192.168.110.21/24node-01被采集端CentOS 7.9192.168.110.22/24node-02被采集端CentOS 7.9192.168.110.23/24 2.1 Loki主要组件 Loki 作为日志聚合系统的设计理念确实非常先进和实用它通过以下三个主要组件来实现高效的日志管理 Promtail Promtail 是 Loki 的日志收集器它运行在每个主机上负责从本地文件中收集日志数据。 它使用类似于 Prometheus 的服务发现机制来动态地发现日志文件。 Promtail 将日志作为流发送到 Loki 服务器这些流由一组标签定义而不是通过全文索引。 Loki Loki 本身是一个高效的日志存储系统它接收来自 Promtail 的日志数据并将其存储在后端数据库中如 BoltDB 或 Cassandra。 Loki 提供了一个 RESTful API允许用户查询和聚合日志数据。 它的设计允许快速查询和聚合因为查询是基于标签的而不是基于文本的全文搜索。 Grafana Grafana 是一个流行的开源数据可视化和监控平台它与 Loki 紧密集成。 用户可以通过 Grafana 来创建仪表板实时监控和分析 Loki 中的日志数据。 Grafana 提供了丰富的图表和可视化选项帮助用户更直观地理解日志数据。 2.2 Loki主要特性 Loki 与其他日志聚合系统相比确实具有一些独特的特性这些特性使得 Loki 成为处理大规模日志数据的理想选择特别是在云原生和容器化环境中。它的简单性、效率和成本效益使其在日志聚合领域中独树一帜。 不进行全文索引 Loki 不对日志内容进行全文索引而是存储压缩的非结构化日志数据并仅索引元数据。这种方法简化了操作减少了存储和计算资源的需求从而降低了成本。 使用标签记录流 Loki 采用了与 Prometheus 类似的标签系统通过标签来索引和分组日志流。这种方法提高了日志数据的扩展性和操作效率使得用户可以快速地查询和聚合具有特定标签的日志。 适合存储 Kubernetes Pod 日志 Loki 特别适合于存储和处理 Kubernetes 环境中的 Pod 日志。在 Kubernetes 中Pod 是短暂的而 Loki 的设计允许它高效地处理这些短暂生命周期的日志源。 Kubernetes Pod 的标签等元数据可以自动被 Loki 索引这使得用户能够利用这些标签来查询特定 Pod 或命名空间的日志。 水平可扩展性 Loki 设计为易于水平扩展可以通过增加更多的节点来处理更多的日志数据这使得它能够适应不断增长的数据量。 多租户支持 Loki 支持多租户部署允许多个团队或项目在同一个 Loki 实例上独立地存储和查询日志而不会相互干扰。 与 Grafana 的集成 Loki 与 Grafana 的紧密集成提供了强大的可视化和监控能力使得用户可以轻松地创建仪表板和警报。 成本效益 由于 Loki 的设计减少了对存储和计算资源的需求它提供了一种成本效益更高的日志聚合解决方案特别是在处理大规模日志数据时。 各日志收集组件简单对比 名称安装的组件优点ELK/EFKElasticsearch, Logstash支持自定义grok正则解析复杂日志内容- Dashboard支持丰富的可视化展示Kibana, Filebeat, Kafka/RedisLokiGrafana, Loki, Promtail占用资源小- Grafana原生支持- 查询速度快 相关资料 官方地址Grafana Loki OSS | Log aggregation system 文档地址Configure the Loki data source | Grafana documentation git地址https://github.com/grafana/loki/blob/master/docs/README.md 下载地址https://github.com/grafana/loki/releases/ 2.3 安装Loki Grafana Loki 是一个日志聚合工具它是功能齐全的日志堆栈的核心。 Loki 是一个为有效保存日志数据而优化的数据存储。日志数据的高效索引将 Loki 与其他日志系统区分开来 与其他日志系统不同Loki 索引是根据标签构建的原始日志消息未编入索引。 [rootmaster ~]# wget -c https://github.com/grafana/loki/releases/download/v2.9.8/loki-2.9.8.x86_64.rpm[rootmaster ~]# yum install loki-2.9.8.x86_64.rpm -y[rootmaster ~]# sed -i s/127.0.0.1/192.168.110.21/ /etc/loki/config.yml # 修改IP[rootmaster ~]# systemctl enable loki --now[rootmaster ~]# systemctl is-active loki.service active[rootmaster ~]# ss -lnupt | egrep 3100|9096tcp   LISTEN     0      128   [::]:9096               [::]:*                   users:((loki,pid11871,fd9))tcp   LISTEN     0      128   [::]:3100               [::]:*                   users:((loki,pid11871,fd8)) 文件介绍 [rootmaster ~]# rpm -ql loki/etc/loki/config.yml               # 配置文件/etc/systemd/system/loki.service   # 系统服务文件/usr/bin/loki                      # 二进制文件​[rootmaster ~]# cat /etc/loki/config.yml auth_enabled: false     # 是否启用鉴权​server:http_listen_port: 3100  # http访问端口grpc_listen_port: 9096  # rpc访问端口​common:instance_addr: 127.0.0.1  # 修改为自己的IP或localhostpath_prefix: /tmp/lokistorage:filesystem:chunks_directory: /tmp/loki/chunks # 记录块存储目录默认chunks块上的日志数量或到期后将chunks数据打标签后存储rules_directory: /tmp/loki/rulesreplication_factor: 1ring:kvstore:store: inmemory​query_range:            # 查询规则results_cache:cache:embedded_cache:enabled: truemax_size_mb: 100​schema_config:configs:- from: 2020-10-24store: boltdb-shipperobject_store: filesystemschema: v11index:prefix: index_period: 24h​ruler:alertmanager_url: http://localhost:9093   # 告警通知url修改为自己的IP# By default, Loki will send anonymous, but uniquely-identifiable usage and configuration# analytics to Grafana Labs. These statistics are sent to https://stats.grafana.org/## Statistics help us better understand how Loki is used, and they show us performance# levels for most users. This helps us prioritize features and documentation.# For more information on whats sent, look at# https://github.com/grafana/loki/blob/main/pkg/usagestats/stats.go# Refer to the buildReport method to see what goes into a report.## If you would like to disable reporting, uncomment the following lines:#analytics:# reporting_enabled: false 2.4 安装Promtail [rootmaster ~]# wget -c https://github.com/grafana/loki/releases/download/v2.9.8/promtail-2.9.8.x86_64.rpm[rootmaster ~]# yum install promtail-2.9.8.x86_64.rpm -y[rootmaster ~]# setfacl -m u:promtail:r /var/log/messages # 注意默认是没有读权限[rootmaster ~]# systemctl enable promtail --now[rootmaster ~]# systemctl is-active promtailactive 测试 访问http://192.168.110.21:9080/targets [rootmaster ~]# cat /tmp/positions.yaml positions:/var/log/messages: 1008852 配置文件详解 [rootmaster ~]# cat /etc/promtail/config.yml# This minimal config scrape only single log file.# Primarily used in rpm/deb packaging where promtail service can be started during system init process.# And too much scraping during init process can overload the complete system.# https://github.com/grafana/loki/issues/11398​server:http_listen_port: 9080grpc_listen_port: 0​positions:filename: /tmp/positions.yaml # 用于记录每次读取日志文件的索引行数如promtail重启后从该配置中恢复日志文件的读取位置​clients:- url: http://localhost:3100/loki/api/v1/push  # 推送日志流到Loki中的api​scrape_configs:     # 发现日志文件的位置并从中提取标签- job_name: system  # 任务名称static_configs:   # 目录配置- targets:        # 标签- localhostlabels:job: varlogs  # 子任务名称通常以项目命令#NOTE: Need to be modified to scrape any additional logs of the system.__path__: /var/log/messages  # 收集本地系统日志 2.5 安装命令行工具 [rootmaster ~]# wget -c https://github.com/grafana/loki/releases/download/v2.9.8/logcli-2.9.8.x86_64.rpm[rootmaster ~]# yum install logcli-2.9.8.x86_64.rpm -y[rootmaster ~]# logcli --help--help显示帮助信息。--version显示应用程序版本。--quiet抑制查询元数据。--stats显示查询统计信息。--output指定输出模式可选 default, raw, jsonl。raw 模式会抑制日志标签和时间戳。--timezone指定格式化输出时间戳时使用的时区默认为本地时区或 UTC。--cpuprofile 和 --memprofile指定 CPU 和内存分析文件的写入位置。--stdin从标准输入读取日志输入。--addr设置 Loki 服务器地址默认为 http://localhost:3100。--username 和 --password设置 HTTP 基本认证的用户名和密码。--ca-cert设置服务器 CA 证书的路径。--tls-skip-verify跳过 TLS 服务器证书验证。--cert 和 --key设置客户端证书和密钥的路径。--org-id添加 API 请求的租户 ID。--query-tags添加 HTTP 请求头用于跟踪查询统计。--bearer-token 和 --bearer-token-file设置用于 API 请求的身份验证令牌。--retries设置查询失败时的重试次数。--min-backoff 和 --max-backoff设置重试之间的最小和最大回退时间。--auth-header设置用于 API 请求的身份验证头部。--proxy-url设置 HTTP 或 HTTPS 代理的 URL。 2.6 安装Granafa [rootmaster ~]# wget -c https://dl.grafana.com/enterprise/release/grafana-enterprise-10.0.2-1.x86_64.rpm[rootmaster ~]# yum install grafana-enterprise-10.0.2-1.x86_64.rpm -y[rootmaster ~]# systemctl enable --now grafana-server 访问 http://192.168.110.21:3000 用户名密码都为admin 添加Loki数据源 Data sources —— Add new data source —— Loki 2.7 增加一个标签 [rootmaster ~]# vim /etc/promtail/config.yml...scrape_configs:- job_name: systemstatic_configs:- targets:- localhostlabels:job: varlogs#NOTE: Need to be modified to scrape any additional logs of the system.__path__: /var/log/messages- targets:              # 添加一个targets- localhostlabels:job: varlogs-02__path__: /var/log/secure​[rootmaster ~]# setfacl -m u:promtail:r /var/log/secure [rootmaster ~]# systemctl restart promtail.service 添加监控指标 3. LogQL语法 在 Loki 中查询日志数据时可以使用标签选择器和过滤表达式来精确地定位和检索所需的日志流。 3.1 标签选择器 标签选择器用于指定一组标签以便从 Loki 中检索匹配特定标签的日志流。 选择器放在 {} 中多个标签表达式用逗号分隔。 3.1.1 支持的符号 表示标签的值需要完全相同。 !表示标签的值需要不平等。 ~表示标签的值需要与正则表达式匹配。 !~表示标签的值不能与正则表达式匹配。 3.1.2 过滤表达式 在选择了日志流之后可以使用搜索表达式进一步过滤结果。 搜索表达式可以是文本或正则表达式。 3.1.3 示例 {jobmysql} | error选择 job 标签为 mysql 的日志流并且日志行包含字符串 error。 {namekafka} |~ tsdb-ops.*io:2003选择 name 标签为 kafka 的日志流并且日志行匹配正则表达式 tsdb-ops.*io:2003。 {instance~kafka-[23],namekafka} ! kafka.server:typeReplicaManager选择 instance 标签匹配正则表达式 kafka-[23] 并且 name 标签为 kafka 的日志流排除包含 kafka.server:typeReplicaManager 的行。 3.1.4 支持的操作符 |日志行包含指定的字符串。 !日志行不包含指定的字符串。 |~日志行匹配指定的正则表达式。 !~日志行不匹配指定的正则表达式。 3.1.5 支持多个过滤 可以在同一查询中使用多个过滤条件例如 {jobmysql} | error ! timeout选择 job 标签为 mysql 的日志流日志行包含 error 但不包含 timeout。 4. Loki收集Nginx日志 为了方便grafana dashbord展示我们把日志格式修改为json 4.1 修改Nginx配置 # 在被监控端上做 [rootnode-01~]# vim /etc/nginx/nginx.conf # 再http模块内添加 http { ... log_format json escapejson {remote_addr: $remote_addr, request_uri: $request_uri, request_length: $request_length, request_time: $request_time, request_method: $request_method, status: $status, body_bytes_sent: $body_bytes_sent, http_referer: $http_referer, http_user_agent: $http_user_agent, http_x_forwarded_for: $http_x_forwarded_for, http_host: $http_host, server_name: $server_name, upstream: $upstream_addr, upstream_response_time: $upstream_response_time, upstream_status: $upstream_status# geoip_country_code: $geoip2_data_country_code, # geoip_country_name: $geoip2_data_country_name, # geoip_city_name: $geoip2_data_city_name};; access_log /var/log/nginx/json_access.log json; }[rootnode-01 ~]# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful [rootnode-01 ~]# systemctl start nginx 访问Nginx [rootnode-01 ~]# tail /var/log/nginx/access.log 192.168.110.23 - - [15/Jun/2024:19:45:37 0800] GET / HTTP/1.1 200 615 - curl/7.29.0 - 192.168.110.23 - - [15/Jun/2024:19:45:38 0800] GET / HTTP/1.1 200 615 - curl/7.29.0 - 192.168.110.23 - - [15/Jun/2024:19:45:38 0800] GET / HTTP/1.1 200 615 - curl/7.29.0 - 192.168.110.21 - - [15/Jun/2024:19:45:42 0800] GET / HTTP/1.1 200 615 - curl/7.29.0 - 192.168.110.21 - - [15/Jun/2024:19:45:42 0800] GET / HTTP/1.1 200 615 - curl/7.29.0 - 192.168.110.21 - - [15/Jun/2024:19:45:44 0800] GET / HTTP/1.1 200 615 - curl/7.29.0 - 192.168.110.21 - - [15/Jun/2024:19:45:44 0800] GET / HTTP/1.1 200 615 - curl/7.29.0 - 192.168.110.21 - - [15/Jun/2024:19:45:44 0800] GET / HTTP/1.1 200 615 - curl/7.29.0 - 192.168.110.21 - - [15/Jun/2024:19:45:45 0800] GET / HTTP/1.1 200 615 - curl/7.29.0 - 192.168.110.21 - - [15/Jun/2024:19:45:45 0800] GET / HTTP/1.1 200 615 - curl/7.29.0 - 4.2 安装Promtail 4.2.1 安装 [rootnode-01 ~]# yum install promtail-2.9.8.x86_64.rpm -y 4.2.2 修改targets [rootnode-01 ~]# vim /etc/promtail/config.yml # This minimal config scrape only single log file. # Primarily used in rpm/deb packaging where promtail service can be started during system init process. # And too much scraping during init process can overload the complete system. # https://github.com/grafana/loki/issues/11398server:http_listen_port: 9080grpc_listen_port: 0positions:filename: /tmp/positions.yamlclients: - url: http://192.168.110.21:3100/loki/api/v1/push # 指定收集端scrape_configs: - job_name: systemstatic_configs:- targets:- localhostlabels:job: nginxlogs # 修改标签host: 192.168.110.22#NOTE: Need to be modified to scrape any additional logs of the system.__path__: /var/log/nginx/*.log # 采集的日志 4.2.3 授权启动 [rootnode-01 ~]# setfacl -m u:promtail:r /var/log/nginx/*.log [rootnode-01 ~]# systemctl restart promtail 4.3 Granafa采集数据 4.4 添加Doshbarod ID:16101
http://www.hkea.cn/news/14315178/

相关文章:

  • 建设永久网站网站开发的岗位与分工
  • 广州专业网站制作平台沈阳建设学院
  • 万网云服务器怎么上传网站吗网站开发项目实训
  • 延安商城网站开发设计wordpress5.0更新内容
  • cms网站开发教程保定定兴网站建设
  • gps定位网站建设新余 网站建站 设计 公司
  • 河北外贸网站建设妇产科医生免费咨询
  • 公众号开发河北米云自贡网站优化
  • 宁夏固原建设网站网站开发的实例教程
  • 百度信息流代理上海企业网站排名优化
  • 贵州网站建设模板手机企业网站设计理念
  • 网站公司网站建设什么叫网页
  • 网站建设公司清明雨上宁波网站开发
  • 个人网站 如何做推广郑州网站推广 汉狮网络
  • 西宁 网站建设小程序登录入口在哪
  • 用哪个程序做网站收录好6品牌营销咨询
  • 监理建设协会网站网站 内容 营销
  • 建网站公司营销型网站建设虚拟机做门户网站如何绑定域名
  • 中天建设集团门户网站网站app开发建设
  • 90设计网站如何接单阿里云网站模板
  • 公司网页设计论文题目大全附子seo
  • 免费视频网站app使用排名ps软件网页版
  • 24淘宝网站建设网站seo运营培训机构
  • ai做网站吉林省住房和建设厅网站
  • 学做网站要学什么软件免备案免费虚拟主机
  • 网站开发 放大图片中国江苏网
  • 体育西网站开发定制做seo需要会网站开发吗
  • 一个网站怎么做wordpress 获取当前用户
  • 软件开发和网站开发哪个更好展馆网站建设
  • 怎么样建设一个电影网站视频下载iis 网站正在建设中