Skip to content
This repository was archived by the owner on Aug 17, 2023. It is now read-only.

Commit 0325f2d

Browse files
committed
feat(out_deis.rb): allow disabling deis logs and metrics to nsq
document the new variables SEND_LOGS_TO_NSQ and SEND_METRICS_TO_NSQ in the readme simplify logic behind send_logs_to_nsq and send_metrics_to_nsq switch to c-style ternary operator
1 parent b79709e commit 0325f2d

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ To turn off log collection of fluentd's own logs to avoid infinite loops set the
3434
To turn off the deis output plugin set the following environment variable to a non-empty string value
3535
* DISABLE_DEIS_OUTPUT
3636

37+
### Disable sending log or metrics data to nsq
38+
To turn off sending log or metrics data to nsq set the following environment variable to "false"
39+
* SEND_LOGS_TO_NSQ
40+
* SEND_METRICS_TO_NSQ
41+
3742
This means we will not capture data from the log stream and send it to NSQ for processing. This means you will disable application logs (`deis logs`) and metrics generated from deis router.
3843

3944
## Plugins

rootfs/opt/fluentd/deis-output/lib/fluent/plugin/out_deis.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def initialize
2626
@influx_nsq = nil
2727
@log_topic = ENV['NSQ_LOG_TOPIC'] || "logs"
2828
@metric_topic = ENV['NSQ_METRIC_TOPIC'] || "metrics"
29+
@send_logs_to_nsq = ENV['SEND_LOGS_TO_NSQ'].to_s.downcase == 'false' ? false : true
30+
@send_metrics_to_nsq = ENV['SEND_METRICS_TO_NSQ'].to_s.downcase == 'false' ? false : true
2931
end
3032

3133
def start
@@ -43,7 +45,7 @@ def emit(tag, es, chain)
4345
if from_controller?(record) || deis_deployed_app?(record)
4446
@logger_nsq ||= get_nsq_producer(@log_topic)
4547
record["time"] = Time.now().strftime("%FT%T.%6N%:z")
46-
push(@logger_nsq, record) if @logger_nsq
48+
push(@logger_nsq, record) if @send_logs_to_nsq && @logger_nsq
4749
end
4850

4951
if from_router?(record)
@@ -54,7 +56,7 @@ def emit(tag, es, chain)
5456
line = data.map do |point|
5557
InfluxDB::PointValue.new(point).dump
5658
end.join("\n".freeze)
57-
push(@influx_nsq, line) if @influx_nsq
59+
push(@influx_nsq, line) if @send_metrics_to_nsq && @influx_nsq
5860
end
5961
rescue Exception => e
6062
puts "Error:#{e.backtrace}"

0 commit comments

Comments
 (0)