XuLizhao 's Notes

时光,漫步


  • 首页

  • 技术

  • 文档

  • 关于

  • 搜索
close

日志处理

时间: 2018-10-24   |   分类: tech     |   阅读: 463 字 ~1分钟

日志系统

Kafka

partition可以理解为一个日志目录。

工具:

  • kafka-python:客户端
  • kafka-tools

默认端口:

  • zookeeper :9092
  • kafka :2181
# 启动ZK
bin/zookeeper-server-start.sh config/zookeeper.properties
bin/kafka-server-start.sh config/server.properties

# 主题相关
bin/kafka-topics.sh --list --zookeeper localhost:2181
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic billing
bin/connect-standalone.sh config/connect-standalone.properties config/connect-file-source.properties config/connect-file-sink.properties
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic healthing  --from-beginning

Elastic

ELK: ElasticSearch存储索引 + Logstash收集整理 + Kibana展现

  • Beats :Go实现的轻量级日志收集Agent
  • Logstash: Ruby实现的数据处理管道
  • ElastAlert:Python实现的报警系统

注: StreamAlert是另一个基于AWS lambda的Python类似实现。

默认端口:

  • kibana :5601
  • logstash :5043
  • elasticsearch :9200

目录结构:

  • 主目录 /usr/share/elasticsearch/
  • 配置 /etc/elasticsearch
  • 日志 /var/log/elasticsearch
  • 启动脚本 /etc/init.d/elasticsearch
  • 默认启动 sudo systemctl enable elasticsearch.service
http://localhost:9200/_nodes?pretty
curl 'localhost:9200/_cat/indices?v'
curl -XGET 'http://localhost:9200/billing/billing/1'
curl -XGET 'http://localhost:9200/billing/billing/_search?q=*'
cp config.yaml.example config.yaml
elastalert-create-index
elastalert-test-rule rules/test_frequency.yaml
elastalert --verbose --rule rules/test_frequency.yaml
#  --debug会记录邮件内容,并且查询不会被保存
curl -XGET 'http://localhost:9200/elastalert_status/_mapping/'

其他

  • Python 日志处理
  • mtail: Google开源的Go实现,把日志导出到时序数据库
  • Graylog: 日志管理平台,Java实现

扩展阅读

Elasticsearch/Solr基于Lucene。

相关性算法

TF-IDF: term frequency –inverse document frequency

  • TF: term出现的频率
  • IDF: 各单词在其他文档越不常见,权重越高

常用场景:

  • 拼写错误
  • 变种
  • 建议: 自动补全 和 did you mean
  • 本文作者: xulizhao
  • 本文链接: https://xulizhao.com/blog/logging/
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
#ops#
人体工学电脑办公
算法
  • 文章目录
  • 站点概览

xulz

时光,漫步

56 日志
3 分类
28 标签
  • 日志系统
    • Kafka
    • Elastic
    • 其他
  • 扩展阅读
    • 相关性算法
© 2017 - 2023 XuLizhao 's Notes
Powered by - Hugo/ NexT
津ICP备17010344号-1
0%