Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Cơ Sở Dữ Liệu

Đơn giản hóa Log Analysis với Filebeat Modules: Quick Setup & Insights

Kể từ Elastic{on} 17, chúng tôi excited về upcoming features trong Elastic Stack, đặc biệt là new Filebeat modules concept. Thường khi muốn start grabbing data với Filebeat, cần config Filebeat, tạo Elasticsearch mapping template, tạo và test ingest pipeline hoặc Logstash instance, rồi tạo Kibana visualizations cho dataset. Beats team làm setup process dễ dàng hơn rất nhiều với modules concept.

Filebeat module roll up all configuration steps vào package enable bằng single command. Filebeat 5.3.0+ ships với modules cho mysql, nginx, apache, system logs, cũng dễ tạo own modules.

Filebeat modules available vài tuần nay, tôi muốn quick blog how to use với non-local Elasticsearch clusters như ObjectRocket service. Vừa launch Elasticsearch 5.4 trên ObjectRocket, bạn có thể try Filebeat modules today và tận dụng new auditd module và Linux system.auth fileset.

Setting up

Steps dưới reference ObjectRocket for Elasticsearch instances và UI, nhưng dễ modify cho other services hoặc own clusters. Cũng dùng "system" module trong example, include other modules straightforward.

Cần: Elasticsearch 5.3+ instance (thử earlier 5.x versions work fine nhưng no guarantees), Kibana same version, hostname(s) connect Elasticsearch cluster, user credentials write cluster và create indices, Filebeat 5.3+.

Giả sử Elasticsearch cluster và Kibana đã setup, first download Filebeat cho system type, extract trên system gather logs. Example: Macbook MacOS connect Elasticsearch 5.4.0 cluster, dùng filebeat-5.4.0-darwin-x86_64.tar.gz. Extract archive và ready setup Filebeat.

Setting up Filebeat

Mặc định Filebeat try connect Elasticsearch local machine và read all logs in /var/log/*.log với included filebeat.yml, nên first modify để point to cluster và strip out other prospectors. Nếu dùng ObjectRocket service, start bằng copy Beats snippet từ UI, auto-populate specific hostnames cho cluster.

Sau strip out everything và fill username/password, entire filebeat.yml trông như:

output:
  elasticsearch:
    hosts: ["https://dfw-xxxx-0.es.objectrocket.com:xxxx", "https://dfw-xxxx-1.es.objectrocket.com:xxxx", "https://dfw-xxxx-2.es.objectrocket.com:xxxx", "https://dfw-xxxx-3.es.objectrocket.com:xxxx"]
    username: "elasticsearch"
    password: "supersecretpassword"

Đó là tất cả. Note all inputs stripped out, file chỉ include Elasticsearch connection info. Lúc này, cũng ensure access elasticsearch cluster từ machine, ACLs added, etc. Bây giờ dùng Filebeat put everything in motion.

Running Filebeat

Everything configured talk to cluster, miễn changes filebeat.yml ở default location, run command sau từ filebeat directory:

./filebeat -e -modules=system -setup

-e làm Filebeat log to stderr thay vì syslog, -modules=system dùng system module, -setup load module's Kibana dashboards. Chỉ cần -setup first time hoặc after upgrade Filebeat, vì chỉ load default dashboards vào Kibana. Muốn run multiple modules, list all separated by commas (no spaces).

Note: Bug Filebeat 5.4.0 có thể cause -setup fail trên certain systems. Workaround: set ulimit higher (run ulimit -n 2048) hoặc dùng filebeat 5.3.x.

Filebeat nên doing its thing. Nếu không thấy errors, check Kibana.

Looking at the data

Logged into Kibana, nên có new filebeat-* index pattern với visualizations và dashboards. Go to "Dashboards", open "Filebeat syslog dashboard".

Voilà. Miên system log có data, bạn sẽ có nice visualizations.

Note: Nếu no apparent errors từ Filebeat và no data in Kibana, system có thể just very quiet system log. Tôi phải set date picker back farther hơn default 'Last 15 minutes' để thấy data.

Wrapping up

Really cool step towards making Beats easier cho common use cases. Basics example này easily extend cho other modules available. Ví dụ, lots web apps (WordPress, Drupal, Magento) có web server và mysql behind. Với one set modules và single command, start shipping logs cho web server, database, system logs của application, all in one step.

Muốn more info và dig into how modules constructed, check developer documentation và poke around module directory Filebeat installation. Match up prospectors, pipelines, templates, visualizations module dùng với what you're seeing in Kibana.