Syslog 和 Loki 集成

强大的性能和简单的集成,由 InfluxData 构建的开源数据连接器 Telegraf 提供支持。

info

对于大规模实时查询,这不是推荐的配置。为了查询和压缩优化、高速摄取和高可用性,您可能需要考虑 Syslog 和 InfluxDB

50 亿+

Telegraf 下载量

#1

时间序列数据库
来源:DB Engines

10 亿+

InfluxDB 的下载量

2,800+

贡献者

目录

强大的性能,无限的扩展能力

收集、组织和处理大量高速数据。当您将任何数据视为时间序列数据时,它都更有价值。借助 InfluxDB,第一的时间序列平台,旨在与 Telegraf 一起扩展。

查看入门方法

输入和输出集成概述

Syslog 插件支持使用标准网络协议从各种来源收集 syslog 消息。此功能对于需要高效监控和记录系统的环境至关重要。

Loki 插件允许用户将日志发送到 Loki 进行聚合和查询,从而利用 Loki 高效的存储能力。

集成详情

Syslog

Telegraf 的 Syslog 插件捕获通过各种协议(如 TCP、UDP 和 TLS)传输的 syslog 消息。它支持 RFC 5424(较新的 syslog 协议)和较旧的 RFC 3164(BSD syslog 协议)。此插件作为服务输入运行,有效地启动一个服务来侦听传入的 syslog 消息。与传统插件不同,服务输入可能无法与标准间隔设置或 CLI 选项(如 --once)一起使用。它包括用于设置网络配置、套接字权限、消息处理和连接处理的选项。此外,与 Rsyslog 的集成允许转发日志消息,使其成为实时收集和中继系统日志的强大工具,从而无缝集成到监控和日志记录系统中。

Loki

此 Loki 插件与 Grafana Loki 集成,Grafana Loki 是一个强大的日志聚合系统。通过以与 Loki 兼容的格式发送日志,此插件可以有效地存储和查询日志。每个日志条目都以键值格式结构化,其中键表示字段名称,值表示相应的日志信息。按时间戳对日志进行排序可确保通过 Loki 查询时,日志流保持时间顺序。此插件对密钥的支持使安全管理身份验证参数变得更加容易,而 HTTP 标头、gzip 编码和 TLS 配置的选项增强了日志传输的适应性和安全性,满足各种部署需求。

配置

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 = "_"

Loki

[[outputs.loki]]
  ## The domain of Loki
  domain = "https://loki.domain.tld"

  ## Endpoint to write api
  # endpoint = "/loki/api/v1/push"

  ## Connection timeout, defaults to "5s" if not set.
  # timeout = "5s"

  ## Basic auth credential
  # username = "loki"
  # password = "pass"

  ## Additional HTTP headers
  # http_headers = {"X-Scope-OrgID" = "1"}

  ## If the request must be gzip encoded
  # gzip_request = false

  ## Optional TLS Config
  # tls_ca = "/etc/telegraf/ca.pem"
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"

  ## Sanitize Tag Names
  ## If true, all tag names will have invalid characters replaced with
  ## underscores that do not match the regex: ^[a-zA-Z_:][a-zA-Z0-9_:]*.
  # sanitize_label_names = false

  ## Metric Name Label
  ## Label to use for the metric name to when sending metrics. If set to an
  ## empty string, this will not add the label. This is NOT suggested as there
  ## is no way to differentiate between multiple metrics.
  # metric_name_label = "__name"

输入和输出集成示例

Syslog

  1. 集中式日志管理:使用 Syslog 插件将来自多台服务器的日志消息聚合到中央日志记录系统中。通过收集来自不同来源的 syslog 数据,此设置有助于监控整体系统健康状况、有效排除问题并维护审计跟踪。

  2. 实时警报:将 Syslog 插件与警报工具集成,以便在检测到特定日志模式或错误时触发实时通知。例如,如果日志中出现关键系统错误,则可以向运维团队发送警报,从而最大限度地减少停机时间并执行主动维护。

  3. 安全监控:利用 Syslog 插件通过捕获来自防火墙、入侵检测系统和其他安全设备的日志来进行安全监控。此日志记录功能增强了安全可见性,并通过分析捕获的 syslog 数据,有助于调查潜在的恶意活动。

  4. 应用程序性能跟踪:利用 Syslog 插件通过收集来自各种应用程序的日志来监控应用程序性能。这种集成有助于分析应用程序的行为和性能趋势,从而帮助优化应用程序流程并确保更顺畅的运行。

Loki

  1. 微服务集中式日志记录:使用 Loki 插件从 Kubernetes 集群中运行的多个微服务收集日志。通过将日志定向到中央 Loki 实例,开发人员可以在一个位置监控、搜索和分析来自所有服务的日志,从而简化故障排除和性能监控。此设置简化了操作,并支持对分布式应用程序中的问题做出快速响应。

  2. 实时日志异常检测:将 Loki 与监控工具结合使用,实时分析日志输出中可能表明系统错误或安全威胁的异常模式。在日志流上实施异常检测使团队能够主动识别和响应事件,从而提高系统可靠性并增强安全态势。

  3. 使用 Gzip 压缩增强日志处理:配置 Loki 插件以使用 gzip 压缩进行日志传输。这种方法可以减少带宽使用并提高传输速度,这在网络带宽可能受到限制的环境中尤其有利。它对于高容量日志记录应用程序尤其有用,在这些应用程序中,每个字节都很重要,性能至关重要。

  4. 通过自定义标头实现多租户支持:利用添加自定义 HTTP 标头的功能来隔离多租户应用程序环境中的不同租户的日志。通过使用 Loki 插件为每个租户发送不同的标头,运营商可以确保正确的日志管理并遵守数据隔离要求,使其成为 SaaS 应用程序的通用解决方案。

反馈

感谢您成为我们社区的一份子!如果您有任何一般性反馈或在这些页面上发现了任何错误,我们欢迎并鼓励您提出意见。请在 InfluxDB 社区 Slack 中提交您的反馈。

强大的性能,无限的扩展能力

收集、组织和处理大量高速数据。当您将任何数据视为时间序列数据时,它都更有价值。借助 InfluxDB,第一的时间序列平台,旨在与 Telegraf 一起扩展。

查看入门方法

相关集成

HTTP 和 InfluxDB 集成

HTTP 插件从一个或多个 HTTP(S) 端点收集指标。它支持各种身份验证方法和数据格式的配置选项。

查看集成

Kafka 和 InfluxDB 集成

此插件从 Kafka 读取消息,并允许基于这些消息创建指标。它支持各种配置,包括不同的 Kafka 设置和消息处理选项。

查看集成

Kinesis 和 InfluxDB 集成

Kinesis 插件允许从 AWS Kinesis 流中读取指标。它支持多种输入数据格式,并提供带有 DynamoDB 的检查点功能,以实现可靠的消息处理。

查看集成