New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fluent-plugin-script-filter

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fluent-plugin-script-filter

  • 0.0.3.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

fluent-plugin-script

Fluent filter plugin to external ruby script.

Build Status Gem

install

gem install fluent-plugin-filter-script

Configuration

fluent.conf
<filter foo.bar.*>
  type script
  path /etc/fluentd/example.rb
</filter>
external ruby script
def start
  super
  # This is the first method to be called when it starts running
  # Use it to allocate resources, etc.  
end

def shutdown
  super
  # This method is called when Fluentd is shutting down.
  # Use it to free up resources, etc.
end

def filter(tag, time, record)
  # This method implements the filtering logic for individual filters
  record
end

ref. http://docs.fluentd.org/articles/plugin-development#filter-plugins

Example

example.rb
def filter(tag, time, record)
  case tag
  when /.+\.code$/
    code(record)
  when /.+\.msg$/
    message(record)
  end
end

def code(record)
  if record.has_key?("key1")
    record["code"] = record["key1"].to_i
    record.delete("key1")
  end
  record
end

def message(record)
  case record["key2"].to_i
  when 100..200
    level = "INFO"
  when 201..300
    level = "WARN"
  else
    level = "ERROR"
  end
  record.delete("key2")

  record["message"] = level + ":" + record["key3"]
  record.delete("key3")
  record
end
Example 1
input
foo.bar.code: {"key1": "200"}
output
foo.bar.code: {"code":200}
Example 2
input
foo.bar.msg: {"key2":280,"key3":"Something happend."}
output
foo.bar.msg: {"message":"WARN:Something happend."}

FAQs

Package last updated on 27 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc