With this logstash extension,
Https://github.com/PeterPaulH/logstash-influxdb/blob/master/src/influxdb.rb
Put this file in Logstash-1.4.2/lib/logstash/outputs.
Look at the Logstash document for the afternoon and finally solve their own needs
This is what Python describes.
Development requirements The number of various types in the statistics log
While True: line = F.readline () try: if ' "type": "Text", "receiver_id" ' on line: type = ' Directmessage ' C4/>elif ' "subtype": "Unfollow" ' in line: type = ' unfollow ' elif ' "subtype": "Follow" ' on line: type = ' follow ' elif ' "Subtype": "Status" ' in line: type = ' Weibo ' elif ' "subtype": "comment" ' on line: type = ' Comment ' else: type = None if type: data = [ {' name ': ' Pingpong_processor ', ' columns ': ["Type"], "points": [[[Type]] }
The Logstash configuration file is as follows
Input {stdin {}}filter {if ' "type": "Text" ' in [message] {mutate {Add_field = = {"Type" = "DIRECTM Essage "} Remove_field = [" Message "," Search "," @version "]}} else if '" subtype ":" Unfollow "' in [mess Age] {mutate {Add_field = {"Type" = "unfollow"} Remove_field = ["Message", "Search", "@version"]}} else if ' "subtype": "Follow" ' in [message] {mutate {Add_field + = {"Type" = "fo" Llow "} Remove_field = [" Message "," Search "," @version "]}} else if '" subtype ":" Status "' in [message] {mutate {Add_field = {"type" + "Weibo"} Remove_field = = ["Message", "Search", "@versi On "]}} or else if '" subtype ":" comment "' in [message] {mutate {Add_field = = {" Type "=" comment " } Remove_field = ["Message", "Search", "@version"]}} else {drop {}}}output {influxdb { Host = "10.75.28."Port = + 4444 Name" + ["pingpong_processor"] columns = ["Type", "host"] points = = ["% {type} "," C ","%{host} "," C "]} stdout {}}
Don't forget to change the INFLUXDB configuration as well, because the default UPD protocol is not open
# Configure the UDP API [INPUT_PLUGINS.UDP] enabled = True port = 4444 Database = "Pingpong_processor"
I use the influxdb version is influxdb-0.8.2-1.x86_64, with/etc/init.d/influxdb This start error, helpless manual start
/usr/bin/influxdb-pidfile/tmp/influxdb.pid-config config.toml
Take a look at whether the UDP port is started
Netstat-anup|grep influxdbudp 0 0::: 4444 :::* 27512/influxdb
Completed
Logstash output to Influxdb