Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ELK 监控openstack 日志 #89

Open
sfPPP opened this issue Jul 31, 2018 · 0 comments
Open

ELK 监控openstack 日志 #89

sfPPP opened this issue Jul 31, 2018 · 0 comments

Comments

@sfPPP
Copy link
Owner

sfPPP commented Jul 31, 2018

采用ELK收集openstack日志

ELK实际上由3个软件组成:
Elastic Search, Logstash和Kibana, 来自一家公司, 代码都是Java写的。

Elastic Search
一款基于Lucene开源的分布式搜索引擎, 它的特点是: 分布式, 开源的实时全文查询和分析引擎。

Logstash
一款开源的数据收集器和管道, 可以收集多种数据源 (如文件, tcp, syslog), 编码转换格式/过滤, 并输出到elastic search或其他软件中。目前有很多插件可以来支持各种各样的数据源以及输出格式。

Kibana
一款开源的数据可视化平台, 能够通过输入的数据在网页上展示出不同的图表。
ELK的源码安装搭建,也可以用yum 安装


修改各节点上logstash.conf文件, 进行输入和输出的配置, 假设elastic search的服务器ip地址为: 127.0.0.1

vi /config/logstash-nova.conf

input {

  file{

     type => "nova"

     path=>"/var/log/nova/nova-scheduler.log"

     path=>"/var/log/nova/nova-novncproxy.log"

     path=>"/var/log/nova/nova-consoleauth.log"

     path=>"/var/log/nova/nova-conductor.log"

     path=>"/var/log/nova/nova-cert.log"

     path=>"/var/log/nova/nova-api.log"

  }

}

output {

  elasticsearch{

    hosts=>"127.0.0.1:9200"

    max_retries=>-1

    index => "%{type}-index"

  }

}

vi /config/logstash-nenutron.conf

input {

  file{

     type => "neutron"

     path=>"/var/log/neutron/l3-agent.log"

     path=>"/var/log/neutron/dhcp-agent.log"

     path=>"/var/log/neutron/linuxbridge-agent.log"

     path=>"/var/log/neutron/server.log"


  }

}


output {

  elasticsearch{

    hosts=>"127.0.0.1:9200"

    max_retries=>-1

    index => "%{type}-index"

  }

}

注意: 需要查看一下logstash用户是否有权限访问指定的log文件

*比如neutron的log日志, 可以使用命令usermod -a -G neutron logstash,把logstash加到neutron组里, 使logstash能够访问相关neutron log日志。否则logstash不能够得到log信息。

usermod -a -G nova logstash,把logstash加到nova组里


前提要保证elasticsearch和logstash都正常启动(需要先启动elasticsearch,再启动logstash),elasticsearch要用elk用户起


先可以通过以下命令确认elastic search是否已经获取到logstash上的index数据信息。

curl 'localhost:9200/_cat/indices?v'


health status index         pri rep docs.count docs.deleted store.size pri.store.size

yellow open   .kibana         1   1          6            1     30.3kb         30.3kb

yellow open   nova-index      5   1    2674455            0    721.6mb        721.6mb

yellow open   neutron-index   5   1   32665606            0     10.9gb         10.9gb 

也可以执行
curl 'http://192.168.30.132:9200/_search?pretty'查看最新日志


遇到的问题:
1.
启动logstash 的时候elasticsearch被killed了
原因:
虚拟机内存不够,扩大内存可以恢复正常

elasticsearch 启动 报错cannot allocate memory
原因:
You have configured a virtual machine with 1 GB of RAM, but elastic is trying to start with 2 GB of RAM (default for Elasticsearch version 5.X)
解决办法:
Either give more memory to your VM, or change Elasticsearch JVM settings /etc/elasticsearch/jvm.options and lower the values of the following parameters: -Xms512m -Xmx512m


Kinaba的使用
登陆http://localhost:5601
image
进入Discover页面, 查看历史以及实时的LOG, 其中:

1. 右上角可以配置页面刷新速率以及显示数据的时间段

2. 上方有一个搜索栏, 可以填入查询语句进行内容过滤, 对于log源, 一般可以通过ERROR OR WARN* OR TRACE

过滤出ERROR, WARN, TRACE的log。

3. 左侧可以选择需要显示的列表字段, 以及各字段中出现频率最高的内容。字段主要有: 消息获取时间, log消息从哪个host来的, log文件路径, log类型, log消息的具体内容等等。

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant