In a production environment, Logstash often encounter logs that handle multiple formats, different log formats, and different parsing methods. The following is said Logstash processing multiline Log example, the MySQL slow query log analysis, this often encountered, the network has a lot of questions.MySQL slow query log format is as follows:
# User@host:ttlsa[ttlsa] @ [10.4.10.12] id:69641319# query_time:
Index fields are indexed using automatic detection in ES, such as IP, date auto-detection (default on), Auto-detect (default off) for dynamic mapping to automatically index documents, and when specific types of fields need to be specified, mapping can be used to define mappings in index generation.
The settings for the default index in Logstash are template-based, Logstash for indexer roles. First we need t
Background: At present, there is a database data about 300 million in the business. If the query directly from the database, wait more than 15 minutes, the user often want to view the data, can only write SQL in the database directly query after drinking a few cups of tea, the results have not come out. The user sees the use of the ES cluster in our project and wants to synchronize the data in the database to the ES cluster.Software version: logstash-
Nodejs
NPM install installation environment
Logstash log analysis and graphical display
Small search engines and graphical display
Ruby-developed tools are encapsulated into jar packages in the Java environment.
Logstash Analysis
Read logs from the back to the front in real time
Elastic search Storage
Kibana web page
Java-jar logstash-1.3.2-fla
Flume compared with Logstash, the personal experience is as follows:
Logstash more emphasis on the preprocessing of the field, while flume emphasis on data transmission;
Logstash has dozens of plug-ins, flexible configuration, Flume is to emphasize the user's custom development (source and sink kind also has ten or twenty, the channel is relatively s
When we use Logstash to collect logs, we usually use the dynamic Index template that comes with logstash, although we can push our log data to the Elasticsearch index cluster without any custom action, but when we query, we find that The default index template often puts us in a field that does not need a word breaker, so that our more important aggregated statistics are inaccurate:For example, if there are
Logstash 5.0 starts with an API that outputs the metrics and status monitoring of its own processes.
Official documents:Https://www.elastic.co/guide/en/logstash/current/monitoring-logstash.html#monitoring
Node Info APIHttps://www.elastic.co/guide/en/logstash/current/node-info-api.htmlPipeline Gets pipeline-specific information and settings.OS Gets Node-level info
1. List Logstash-pluginsBin/logstash-plugin List******Logstash-output-kafkaLogstash-output-nagiosLogstash-output-nullLogstash-output-pagerdutyLogstash-output-pipeLogstash-output-rabbitmqLogstash-output-redis******2. Plugin to install MongoDB output in the output formatInstall Logstash-output-mongodb3. Configure the out
-flume-1.5.2-bin/tracklog-kafka/checkpointAgent.channels.m1.datadirs=/opt/modules/apache-flume-1.5.2-bin/tracklog-kafka/datadirAgent.channels.m1.transactionCapacity = 1000000agent.channels.m1.capacity=1000000Agent.channels.m1.checkpointInterval = 30000
Second, the data into the KafkaThe above collect topic need to be Kafka in advance, the other steps into the Kafka has been configured in the Collect.To create a topic statement reference:
%{kafka_home}/bin/kafka-topics.sh-
Data acquisition of Kafka and Logstash
Based on Logstash run-through Kafka still need to pay attention to a lot of things, the most important thing is to understand the principle of Kafka.
Logstash Working principleSince Kafka uses decoupled design ideas, it is not the original publication subscription, the producer is responsible for generating the
The Nginx Access log we collected through Logstash already contains the data for the client IP (REMOTE_ADDR), but only this IP is not enough, the location of the Kibana to display the requested source needs to be implemented by GEOIP database. GeoIP is the most common free IP address classification query library, but also has a pay version can be purchased. GeoIP Library can provide the corresponding geographical information according to the IP addres
input URL 192.168.135.129:5601 can not access, shut down the firewall is not, need to set up/etc/kibana/kibana.yml. Let's release some configuration and modify some configurations as followsThen landing outside the network, more refresh several times, the main network of Bo slow, enter the URL http://192.168.135.129:5601Ok!Final installation LogstashCreating a configuration fileThe content format has the following main input, filter and output three parts:1 Input {2 3 stdin {}4 }5 6 Filter {7 8
Logstash cannot read redis data
A problem occurred when constructing logsatsh + redis + elasticsearch today. After nearly one hour of troubleshooting, the problem was finally solved. Record it.
The environment is like this. A client sends data to redis on the server, and logstash on the server reads redis data and stores it in elasticsearch.
The initial problem is that on the server side, the log sent from
=" Wkiom1esnf2spnajaagskazveiw369.png "/>5, LogstashStarting mode Bin/logstash-f logstash.confThe whole logstash is basically the Conf configuration file, YML formatI started by Logstash Agent to upload the log to the same redis, and then use the local logstash to pull the Redis log650) this.width=650; "src=" Http://s3
Configure GeoIP in logstash to parse geographic information, logstashgeoip
The GeoIP database configured in logstash parses the ip address. Here, an open source ip data source is used to analyze the ip address of the client. The official website is here: MAXMIND
DownloadGeoLiteCityDatabase
Wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gztar-zxvf GeoLite2-City.tar.gzcp GeoLite2
\elasticsearch\logs\* # Exclude_lines: ["^dbg"] #include_lines: ["^err", "^warn"]Multiple paths can be configured here, and filtering with regular log extraction3, output log path:Filebeat output can be available in multiple destinations, ES, LogstashElasticsearch#--------------------------Elasticsearch output------------------------------#output. Elasticsearch: # Array of hosts to connect to. # hosts: ["localhost:9200"] # Optional protocol and Basic auth credentials. "https" "elastic"
Halo, the previous period of time installed logstash,rpm installation, after installation, want to start the Apache way to start Logstash, and then use the service Logstash start start, but prompted not to change the file or directory,
Depressed, a period of time, I was directly started with the command line, and then yesterday in Centos7 installation can use Sy
PartyCase BackJingTypically, the logs are stored on different devices that are scattered. If you manage hundreds of dozens of of servers, you are also using the traditional method of logging in to each machine in turn. This is not feeling very cumbersome and inefficient. Open Source Real-time log analyticsELKthe platform can perfectly solve the problem of log collection and log retrieval and analysis,elk means Elasticsearch .,Logstashand theKiabanaThree of open source tools. Because elk can be d
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.