Logstash output to Influxdb

Source: Internet
Author: User
Tags logstash influxdb

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

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.