目录
输入和输出集成概述
Syslog 插件允许使用标准网络协议从各种来源收集 syslog 消息。此功能对于需要高效监控和日志记录系统的环境至关重要。
此插件使 Telegraf 能够使用 Prometheus remote write 协议将指标发送到 Cortex,从而可以无缝摄取到 Cortex 的可扩展、多租户时序存储中。
集成详情
Syslog
Telegraf 的 Syslog 插件捕获通过各种协议(如 TCP、UDP 和 TLS)传输的 syslog 消息。它支持 RFC 5424(较新的 syslog 协议)和较旧的 RFC 3164(BSD syslog 协议)。此插件作为服务输入运行,有效地启动一个服务来侦听传入的 syslog 消息。与传统插件不同,服务输入可能无法与标准间隔设置或 CLI 选项(如 --once)一起使用。它包括用于设置网络配置、套接字权限、消息处理和连接处理的选项。此外,与 Rsyslog 的集成允许转发日志消息,使其成为实时收集和中继系统日志的强大工具,从而无缝集成到监控和日志记录系统中。
Cortex
借助 Telegraf 的 HTTP 输出插件和 prometheusremotewrite 数据格式,您可以将指标直接发送到 Cortex,这是一个用于 Prometheus 的水平可扩展长期存储后端。Cortex 支持多租户,并接受使用 Prometheus protobuf 格式的 remote write 请求。通过使用 Telegraf 作为收集代理,并将 Remote Write 作为传输机制,组织可以将可观测性扩展到 Prometheus 本身不支持的来源(例如 Windows 主机、支持 SNMP 的设备或自定义应用程序指标),同时利用 Cortex 的高可用性和长期保留能力。
配置
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 = "_"
Cortex
[[outputs.http]]
## Cortex Remote Write endpoint
url = "http://cortex.example.com/api/v1/push"
## Use POST to send data
method = "POST"
## Send metrics using Prometheus remote write format
data_format = "prometheusremotewrite"
## Optional HTTP headers for authentication
# [outputs.http.headers]
# X-Scope-OrgID = "your-tenant-id"
# Authorization = "Bearer YOUR_API_TOKEN"
## Optional TLS configuration
# tls_ca = "/path/to/ca.pem"
# tls_cert = "/path/to/cert.pem"
# tls_key = "/path/to/key.pem"
# insecure_skip_verify = false
## Request timeout
timeout = "10s"
输入和输出集成示例
Syslog
-
集中日志管理:使用 Syslog 插件将来自多个服务器的日志消息聚合到中央日志记录系统中。此设置可以通过从不同来源收集 syslog 数据来帮助监控整体系统运行状况、有效排除故障和维护审计跟踪。
-
实时警报:将 Syslog 插件与警报工具集成,以便在检测到特定日志模式或错误时触发实时通知。例如,如果日志中出现严重系统错误,则可以向运维团队发送警报,从而最大限度地减少停机时间并执行主动维护。
-
安全监控:利用 Syslog 插件进行安全监控,方法是从防火墙、入侵检测系统和其他安全设备捕获日志。此日志记录功能增强了安全可见性,并通过分析捕获的 syslog 数据来帮助调查潜在的恶意活动。
-
应用程序性能跟踪:利用 Syslog 插件通过从各种应用程序收集日志来监控应用程序性能。此集成有助于分析应用程序的行为和性能趋势,从而有助于优化应用程序流程并确保更平稳的运行。
Cortex
-
统一多租户监控:使用 Telegraf 从不同团队或环境收集指标,并使用单独的 X-Scope-OrgID 标头将其推送到 Cortex。这实现了每个租户的隔离数据摄取和查询,非常适合托管服务和平台团队。
-
将 Prometheus 覆盖范围扩展到边缘设备:在边缘或 IoT 设备上部署 Telegraf 以收集系统指标,并将它们发送到中央 Cortex 集群。即使对于没有本地 Prometheus 抓取器的环境,此方法也能确保一致的可观测性。
-
具有联邦租户的全球服务可观测性:通过配置 Telegraf 代理将数据推送到区域 Cortex 集群(每个集群都标记有租户标识符)来聚合来自全球基础设施的指标。Cortex 处理跨区域的重复数据删除和集中访问。
-
自定义应用程序遥测管道:通过 Telegraf 的 exec 或 http 输入插件收集特定于应用程序的遥测数据,并将其转发到 Cortex。这使 DevOps 团队能够以可扩展、查询高效的格式监控特定于应用程序的 KPI,同时保持指标按租户或服务进行逻辑分组。
反馈
感谢您成为我们社区的一份子!如果您有任何一般性反馈或在这些页面上发现了任何错误,我们欢迎并鼓励您提出意见。请在 InfluxDB 社区 Slack 中提交您的反馈。