目录
强大的性能,无限的扩展能力
收集、组织和处理海量高速数据。当您将任何数据视为时间序列数据时,它都会更有价值。借助 InfluxDB,排名第一的时间序列平台,旨在与 Telegraf 一起扩展。
查看入门方法
输入和输出集成概述
AMQP Consumer 输入插件允许您从兼容 AMQP 0-9-1 的消息代理(如 RabbitMQ)中摄取数据,从而实现无缝的数据收集,以进行监控和分析。
此插件使用参数化的 SQL INSERT 语句将指标从 Telegraf 直接写入 MariaDB,从而提供了一种灵活的方式将指标存储在结构化的关系表中。
集成详细信息
AMQP
此插件为 AMQP 0-9-1 提供了一个消费者,RabbitMQ 是其一个突出的实现。AMQP 或高级消息队列协议最初是为了在网络中各种系统之间实现可靠的、可互操作的消息传递而开发的。该插件使用配置的队列和绑定键从主题交换中读取指标,从而提供了一种灵活高效的方式来从兼容 AMQP 的消息传递系统中收集数据。这使用户能够利用现有的 RabbitMQ 实施来有效地监控他们的应用程序,通过捕获详细的指标以进行分析和告警。
MariaDB
Telegraf 中的 SQL 输出插件通过执行参数化的 SQL 语句,能够将指标直接写入兼容 SQL 的数据库(如 MariaDB)。通过支持 MySQL 驱动程序,该插件与 MariaDB 无缝集成,以实现可靠的、结构化的指标存储。此设置非常适合喜欢基于 SQL 的分析或希望将指标与业务数据一起存储以进行统一查询的用户。MariaDB 是一个社区开发的、企业级的 MySQL 分支,强调性能、安全性和开放性。该插件支持将时间序列指标插入到自定义模式中,从而实现灵活的分析,并与使用 SQL 连接器的 BI 工具(如 Metabase 或 Grafana)集成。
配置
AMQP
[[inputs.amqp_consumer]]
## Brokers to consume from. If multiple brokers are specified a random broker
## will be selected anytime a connection is established. This can be
## helpful for load balancing when not using a dedicated load balancer.
brokers = ["amqp://localhost:5672/influxdb"]
## Authentication credentials for the PLAIN auth_method.
# username = ""
# password = ""
## Name of the exchange to declare. If unset, no exchange will be declared.
exchange = "telegraf"
## Exchange type; common types are "direct", "fanout", "topic", "header", "x-consistent-hash".
# exchange_type = "topic"
## If true, exchange will be passively declared.
# exchange_passive = false
## Exchange durability can be either "transient" or "durable".
# exchange_durability = "durable"
## Additional exchange arguments.
# exchange_arguments = { }
# exchange_arguments = {"hash_property" = "timestamp"}
## AMQP queue name.
queue = "telegraf"
## AMQP queue durability can be "transient" or "durable".
queue_durability = "durable"
## If true, queue will be passively declared.
# queue_passive = false
## Additional arguments when consuming from Queue
# queue_consume_arguments = { }
# queue_consume_arguments = {"x-stream-offset" = "first"}
## A binding between the exchange and queue using this binding key is
## created. If unset, no binding is created.
binding_key = "#"
## Maximum number of messages server should give to the worker.
# prefetch_count = 50
## Max undelivered messages
## This plugin uses tracking metrics, which ensure messages are read to
## outputs before acknowledging them to the original broker to ensure data
## is not lost. This option sets the maximum messages to read from the
## broker that have not been written by an output.
##
## This value needs to be picked with awareness of the agent's
## metric_batch_size value as well. Setting max undelivered messages too high
## can result in a constant stream of data batches to the output. While
## setting it too low may never flush the broker's messages.
# max_undelivered_messages = 1000
## Timeout for establishing the connection to a broker
# timeout = "30s"
## Auth method. PLAIN and EXTERNAL are supported
## Using EXTERNAL requires enabling the rabbitmq_auth_mechanism_ssl plugin as
## described here: https://rabbitmq.cn/plugins.html
# auth_method = "PLAIN"
## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Use TLS but skip chain & host verification
# insecure_skip_verify = false
## Content encoding for message payloads, can be set to
## "gzip", "identity" or "auto"
## - Use "gzip" to decode gzip
## - Use "identity" to apply no encoding
## - Use "auto" determine the encoding using the ContentEncoding header
# content_encoding = "identity"
## Maximum size of decoded message.
## Acceptable units are B, KiB, KB, MiB, MB...
## Without quotes and units, interpreted as size in bytes.
# max_decompression_size = "500MB"
## Data format to consume.
## Each data format has its own unique set of configuration options, read
## more about them here:
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
data_format = "influx"
MariaDB
[[outputs.sql]]
## Database driver
## Valid options: mssql (Microsoft SQL Server), mysql (MySQL), pgx (Postgres),
## sqlite (SQLite3), snowflake (snowflake.com) clickhouse (ClickHouse)
driver = "mysql"
## Data source name
## The format of the data source name is different for each database driver.
## See the plugin readme for details.
data_source_name = "username:password@tcp(host:port)/dbname"
## Timestamp column name
timestamp_column = "timestamp"
## Table creation template
## Available template variables:
## {TABLE} - table name as a quoted identifier
## {TABLELITERAL} - table name as a quoted string literal
## {COLUMNS} - column definitions (list of quoted identifiers and types)
table_template = "CREATE TABLE {TABLE}({COLUMNS})"
## SQL INSERT statement with placeholders. Telegraf will substitute values at runtime.
## table_template = "INSERT INTO metrics (timestamp, name, value, tags) VALUES (?, ?, ?, ?)"
## Table existence check template
## Available template variables:
## {TABLE} - tablename as a quoted identifier
table_exists_template = "SELECT 1 FROM {TABLE} LIMIT 1"
## Initialization SQL
init_sql = "SET sql_mode='ANSI_QUOTES';"
## Maximum amount of time a connection may be idle. "0s" means connections are
## never closed due to idle time.
connection_max_idle_time = "0s"
## Maximum amount of time a connection may be reused. "0s" means connections
## are never closed due to age.
connection_max_lifetime = "0s"
## Maximum number of connections in the idle connection pool. 0 means unlimited.
connection_max_idle = 2
## Maximum number of open connections to the database. 0 means unlimited.
connection_max_open = 0
## NOTE: Due to the way TOML is parsed, tables must be at the END of the
## plugin definition, otherwise additional config options are read as part of the
## table
## Metric type to SQL type conversion
## The values on the left are the data types Telegraf has and the values on
## the right are the data types Telegraf will use when sending to a database.
##
## The database values used must be data types the destination database
## understands. It is up to the user to ensure that the selected data type is
## available in the database they are using. Refer to your database
## documentation for what data types are available and supported.
#[outputs.sql.convert]
# integer = "INT"
# real = "DOUBLE"
# text = "TEXT"
# timestamp = "TIMESTAMP"
# defaultvalue = "TEXT"
# unsigned = "UNSIGNED"
# bool = "BOOL"
# ## This setting controls the behavior of the unsigned value. By default the
# ## setting will take the integer value and append the unsigned value to it. The other
# ## option is "literal", which will use the actual value the user provides to
# ## the unsigned option. This is useful for a database like ClickHouse where
# ## the unsigned value should use a value like "uint64".
# # conversion_style = "unsigned_suffix"
输入和输出集成示例
AMQP
-
集成应用程序指标与 AMQP:使用 AMQP Consumer 插件收集发布到 RabbitMQ 交换机的应用程序指标。通过配置插件以监听特定的队列,团队可以深入了解应用程序性能、跟踪请求率、错误计数和延迟指标,所有这些都是实时的。这种设置不仅有助于异常检测,还为容量规划和系统优化提供了有价值的数据。
-
事件驱动的监控:配置 AMQP Consumer 以在应用程序中满足某些条件时触发特定的监控事件。例如,如果收到指示高错误率的消息,插件可以将此数据馈送到监控工具中,生成警报或扩展事件。这种集成可以提高对问题的响应速度,并自动化部分操作工作流程。
-
跨平台数据聚合:利用 AMQP Consumer 插件来整合来自分布在不同平台上的各种应用程序的指标。通过使用 RabbitMQ 作为集中式消息代理,组织可以统一他们的监控数据,从而允许通过 Telegraf 进行全面的分析和仪表板展示,从而在异构环境中保持可见性。
-
实时日志处理:扩展 AMQP Consumer 的使用以捕获发送到 RabbitMQ 交换机的日志数据,实时处理日志以进行监控和告警。此应用程序确保通过分析日志模式、趋势和异常(在它们发生时)来快速检测和解决操作问题。
MariaDB
-
商业智能集成:将应用程序性能指标直接存储到 MariaDB 中,并将其连接到 BI 工具(如 Metabase 或 Apache Superset)。这种设置允许将操作数据与业务 KPI 混合,以实现统一的仪表板,从而提高跨部门的可见性。
-
用于合规性报告的历史指标:使用此插件将指标记录到 MariaDB 中,用于审计和合规性用例。关系模型支持使用时间戳条目精确查询过去的绩效指标,从而支持监管文档。
-
基于 SQL 逻辑的自定义告警:将指标插入到 MariaDB 中,并使用自定义 SQL 查询来定义告警阈值或条件。与 cron 作业或计划脚本结合使用,这可以实现传统指标平台无法实现的高级告警工作流程。
-
物联网传感器指标存储:通过 Telegraf 收集来自物联网设备的传感器数据,并使用规范化的模式将其存储在 MariaDB 中。这种方法具有成本效益,并且与现有的基于 SQL 的系统集成良好,以进行实时或历史分析。
反馈
感谢您成为我们社区的一份子!如果您有任何一般性反馈或在这些页面上发现了任何错误,我们欢迎并鼓励您提出意见。请在InfluxDB 社区 Slack 中提交您的反馈。
强大的性能,无限的扩展能力
收集、组织和处理海量高速数据。当您将任何数据视为时间序列数据时,它都会更有价值。借助 InfluxDB,排名第一的时间序列平台,旨在与 Telegraf 一起扩展。
查看入门方法