目录
输入和输出集成概述
Syslog 插件允许使用标准网络协议从各种来源收集 syslog 消息。此功能对于需要高效监控和日志记录系统的环境至关重要。
MongoDB Telegraf 插件允许用户将指标发送到 MongoDB 数据库,自动管理时序集合。
集成详情
Syslog
Telegraf 的 Syslog 插件捕获通过各种协议(如 TCP、UDP 和 TLS)传输的 syslog 消息。它支持 RFC 5424(较新的 syslog 协议)和较旧的 RFC 3164(BSD syslog 协议)。此插件作为服务输入运行,有效地启动一个服务来监听传入的 syslog 消息。与传统插件不同,服务输入可能无法与标准间隔设置或 CLI 选项(如 `--once`)一起使用。它包括用于设置网络配置、套接字权限、消息处理和连接处理的选项。此外,与 Rsyslog 的集成允许转发日志消息,使其成为实时收集和中继系统日志的强大工具,从而无缝集成到监控和日志记录系统中。
MongoDB
此插件将指标发送到 MongoDB,并与其时序功能无缝集成,允许在时序集合尚不存在时自动创建为时序集合。它需要 MongoDB 5.0 或更高版本才能使用时序集合功能,这对于高效存储和查询基于时间的数据至关重要。此插件通过确保所有相关指标都正确存储并在 MongoDB 中组织,从而增强了监控功能,使用户能够利用 MongoDB 强大的查询和聚合功能进行时序分析。
配置
Syslog
[[inputs.syslog]]
## Protocol, address and port to host the syslog receiver.
## If no host is specified, then localhost is used.
## If no port is specified, 6514 is used (RFC5425#section-4.1).
## ex: server = "tcp://localhost:6514"
## server = "udp://:6514"
## server = "unix:///var/run/telegraf-syslog.sock"
## When using tcp, consider using 'tcp4' or 'tcp6' to force the usage of IPv4
## or IPV6 respectively. There are cases, where when not specified, a system
## may force an IPv4 mapped IPv6 address.
server = "tcp://127.0.0.1:6514"
## Permission for unix sockets (only available on unix sockets)
## This setting may not be respected by some platforms. To safely restrict
## permissions it is recommended to place the socket into a previously
## created directory with the desired permissions.
## ex: socket_mode = "777"
# socket_mode = ""
## Maximum number of concurrent connections (only available on stream sockets like TCP)
## Zero means unlimited.
# max_connections = 0
## Read timeout (only available on stream sockets like TCP)
## Zero means unlimited.
# read_timeout = "0s"
## Optional TLS configuration (only available on stream sockets like TCP)
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Enables client authentication if set.
# tls_allowed_cacerts = ["/etc/telegraf/clientca.pem"]
## Maximum socket buffer size (in bytes when no unit specified)
## For stream sockets, once the buffer fills up, the sender will start
## backing up. For datagram sockets, once the buffer fills up, metrics will
## start dropping. Defaults to the OS default.
# read_buffer_size = "64KiB"
## Period between keep alive probes (only applies to TCP sockets)
## Zero disables keep alive probes. Defaults to the OS configuration.
# keep_alive_period = "5m"
## Content encoding for message payloads
## Can be set to "gzip" for compressed payloads or "identity" for no encoding.
# content_encoding = "identity"
## Maximum size of decoded packet (in bytes when no unit specified)
# max_decompression_size = "500MB"
## Framing technique used for messages transport
## Available settings are:
## octet-counting -- see RFC5425#section-4.3.1 and RFC6587#section-3.4.1
## non-transparent -- see RFC6587#section-3.4.2
# framing = "octet-counting"
## The trailer to be expected in case of non-transparent framing (default = "LF").
## Must be one of "LF", or "NUL".
# trailer = "LF"
## Whether to parse in best effort mode or not (default = false).
## By default best effort parsing is off.
# best_effort = false
## The RFC standard to use for message parsing
## By default RFC5424 is used. RFC3164 only supports UDP transport (no streaming support)
## Must be one of "RFC5424", or "RFC3164".
# syslog_standard = "RFC5424"
## Character to prepend to SD-PARAMs (default = "_").
## A syslog message can contain multiple parameters and multiple identifiers within structured data section.
## Eg., [id1 name1="val1" name2="val2"][id2 name1="val1" nameA="valA"]
## For each combination a field is created.
## Its name is created concatenating identifier, sdparam_separator, and parameter name.
# sdparam_separator = "_"
MongoDB
[[outputs.mongodb]]
# connection string examples for mongodb
dsn = "mongodb://localhost:27017"
# dsn = "mongodb://mongod1:27017,mongod2:27017,mongod3:27017/admin&replicaSet=myReplSet&w=1"
# overrides serverSelectionTimeoutMS in dsn if set
# timeout = "30s"
# default authentication, optional
# authentication = "NONE"
# for SCRAM-SHA-256 authentication
# authentication = "SCRAM"
# username = "root"
# password = "***"
# for x509 certificate authentication
# authentication = "X509"
# tls_ca = "ca.pem"
# tls_key = "client.pem"
# # tls_key_pwd = "changeme" # required for encrypted tls_key
# insecure_skip_verify = false
# database to store measurements and time series collections
# database = "telegraf"
# granularity can be seconds, minutes, or hours.
# configuring this value will be based on your input collection frequency.
# see https://docs.mongodb.com/manual/core/timeseries-collections/#create-a-time-series-collection
# granularity = "seconds"
# optionally set a TTL to automatically expire documents from the measurement collections.
# ttl = "360h"
输入和输出集成示例
Syslog
-
集中日志管理:使用 Syslog 插件将来自多个服务器的日志消息聚合到中央日志记录系统中。此设置可以通过收集来自不同来源的 syslog 数据,帮助监控整体系统健康状况、有效排除故障并维护审计跟踪。
-
实时警报:将 Syslog 插件与警报工具集成,以在检测到特定日志模式或错误时触发实时通知。例如,如果日志中出现关键系统错误,则可以向运维团队发送警报,从而最大限度地减少停机时间并执行主动维护。
-
安全监控:利用 Syslog 插件通过捕获来自防火墙、入侵检测系统和其他安全设备的日志进行安全监控。此日志记录功能增强了安全可见性,并通过分析捕获的 syslog 数据,帮助调查潜在的恶意活动。
-
应用程序性能跟踪:利用 Syslog 插件通过收集来自各种应用程序的日志来监控应用程序性能。此集成有助于分析应用程序的行为和性能趋势,从而帮助优化应用程序流程并确保更流畅的运行。
MongoDB
-
物联网设备的动态日志记录到 MongoDB:利用此插件实时收集和存储来自大量物联网设备的指标。通过将设备日志直接发送到 MongoDB,您可以创建一个中央数据库,以便轻松访问和查询健康指标和性能数据,从而根据历史趋势实现主动维护和故障排除。
-
Web 流量的时序分析:使用 MongoDB Telegraf 插件收集和分析随时间变化的 Web 流量指标。此应用程序可以帮助您了解高峰使用时间、用户交互和行为模式,从而指导营销策略和基础设施扩展决策,以改善用户体验。
-
自动化监控和警报系统:将 MongoDB 插件集成到跟踪应用程序性能指标的自动化监控系统中。借助时序集合,您可以根据特定阈值设置警报,使您的团队能够在潜在问题影响用户之前做出响应。这种主动管理可以提高服务可靠性和整体性能。
-
指标存储中的数据保留和 TTL 管理:利用 MongoDB 集合中文档的 TTL 功能自动过期过时的指标。这对于仅最近性能数据相关的环境特别有用,可以防止您的 MongoDB 数据库因旧指标而变得混乱,并确保高效的数据管理。
反馈
感谢您成为我们社区的一份子!如果您有任何一般反馈或在这些页面上发现了任何错误,我们欢迎并鼓励您提出意见。请在 InfluxDB 社区 Slack 中提交您的反馈。