我正在尝试使用fluent-bit将日志从日志文件发送到正在监听端口8094的telegraf。我能够通过这样的终端将数据发送到该端口
回显“ some_log_data” | nc localhost 8094
但是当我使用流利的位格式输出输出插件将数据发送到同一端口时,它在流利的位日志中给出了此错误
fluent-bit_1 | [2019/11/21 11:14:44] [错误] [io] TCP连接失败:localhost:8094(连接被拒绝)
fluent-bit_1 | [2019/11/21 11:14:44] [错误] [out_fw]没有可用的上游连接
这是我的docker-compose文件:
version: '3'
services:
# Define a Telegraf service
telegraf:
image: telegraf
volumes:
- ./telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro
ports:
- "8092:8092/udp"
- "8094:8094"
- "8125:8125/udp"
- "9126:9126"
networks:
- mynet
fluent-bit:
image: fluent/fluent-bit:1.3.2-debug
volumes:
- ./fluent-bit:/fluent-bit/etc
- ./access_logs/localhost_access_log:/logs
depends_on:
- telegraf
networks:
- mynet
networks:
mynet:
fluent-bit.conf:
[SERVICE]
Flush 2
Parsers_File parsers.conf
[INPUT]
Name tail
Tag cuic.logs
Path /logs/*.log
Path_Key File_Path
Multiline On
Parser_Firstline start
[OUTPUT]
Name forward
Match *
Host localhost
Port 8094
Tag cuic.logs
telegraf.conf:
[[outputs.file]]
files = ["/tmp/metrics.out"]
data_format = "json"
json_timestamp_units = "1s"
[[inputs.socket_listener]]
service_address = "tcp://:8094"
socket_mode = "777"
data_format = "grok"
grok_patterns = ["%{CUSTOM_LOG}"]
grok_custom_patterns = '''
SOME_GROK_PATTERN
'''
[[aggregators.histogram]]
period = "10s"
drop_original = false
[[aggregators.histogram.config]]
buckets = [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0]
measurement_name = "access_log"
fields = ["resp_time"]
有人可以帮我弄清楚我做错了什么吗
答案 0 :(得分:0)
我认为问题出在使用主机名“ localhost”时。由于容器localhost在网络级别将是其自己的网络范围,因此将无法根据需要访问其他容器TCP端口。
您可以在此处了解有关同一问题的更多信息:
How to share localhost between two different Docker containers?
和...请注意,Fluent Bit中的正向输出协议使用二进制协议,而不是我怀疑要使用的普通JSON。请改用tcp输出插件。
答案 1 :(得分:0)
肯定是您使用的输出/输入插件。 Telegraf有一个FluentD插件here,看起来像这样:
# Read metrics exposed by fluentd in_monitor plugin
[[inputs.fluentd]]
## This plugin reads information exposed by fluentd (using /api/plugins.json endpoint).
##
## Endpoint:
## - only one URI is allowed
## - https is not supported
endpoint = "http://localhost:24220/api/plugins.json"
## Define which plugins have to be excluded (based on "type" field - e.g. monitor_agent)
exclude = [
"monitor_agent",
"dummy",
]
您的Fluent-Bit http output config如下所示:
[INPUT]
Name cpu
Tag cpu
[OUTPUT]
Name http
Match *
Host 192.168.2.3
Port 80
URI /something
但是Fluent-Bit也有一个InfluxDB output plugin。
答案 2 :(得分:0)
Fluent-bit有一个名为forward的out插件,它可以根据fluentd协议转发输出。您可以根据以下文档进行设置:https://docs.fluentbit.io/manual/pipeline/inputs/forward
然后,您可以找到telegraf有一个名为fluentd的输入插件,将其设置为输入,然后从fluentd客户终结点收集可以满足您要求的指标。