目录
输入和输出集成概述
SNMP Trap Telegraf 插件能够接收 SNMP 通知,通过捕获来自网络设备的重要事件,促进全面的网络监控。
Telegraf SQL 插件允许您将来自 Telegraf 的指标直接存储到 MySQL 数据库中,从而更轻松地分析和可视化收集的指标。
集成详情
SNMP Trap
SNMP Trap 插件充当 SNMP 通知的接收端点,这些通知称为陷阱和信息请求。它通过 UDP 运行,侦听传入的通知,这些通知可以配置为在特定端口上到达。此插件是网络监控和管理不可或缺的一部分,使系统能够收集和响应从网络中各种设备(包括路由器、交换机和服务器)发送的 SNMP 陷阱。该插件通过 SNMPv3 支持安全传输选项,从而可以配置身份验证和加密参数以保护敏感数据。此外,它还使用户可以灵活地配置 SNMP 的多个方面,例如 MIB 文件位置,使其适用于各种环境和用例。建议从已弃用的 netsnmp 后端过渡到更新的 gosmi 后端,以利用其增强的功能和支持。实施此插件的用户可以有效地监控网络事件、自动响应陷阱并维护强大的网络监控基础设施。
MySQL
Telegraf 的 SQL 输出插件旨在通过基于传入指标动态创建表和列,将指标数据无缝写入 SQL 数据库。当配置为 MySQL 时,该插件利用 go-sql-driver/mysql,这需要启用 ANSI_QUOTES SQL 模式以确保正确处理带引号的标识符。这种动态模式创建方法确保每个指标都存储在其自己的表中,其结构源自其字段和标签,从而提供系统性能的详细、带时间戳的记录。该插件的灵活性使其能够处理高吞吐量环境,使其成为需要强大、精细的指标日志记录和历史数据分析的场景的理想选择。
配置
SNMP Trap
[[inputs.snmp_trap]]
## Transport, local address, and port to listen on. Transport must
## be "udp://". Omit local address to listen on all interfaces.
## example: "udp://127.0.0.1:1234"
##
## Special permissions may be required to listen on a port less than
## 1024. See README.md for details
##
# service_address = "udp://:162"
##
## Path to mib files
## Used by the gosmi translator.
## To add paths when translating with netsnmp, use the MIBDIRS environment variable
# path = ["/usr/share/snmp/mibs"]
##
## Deprecated in 1.20.0; no longer running snmptranslate
## Timeout running snmptranslate command
# timeout = "5s"
## Snmp version; one of "1", "2c" or "3".
# version = "2c"
## SNMPv3 authentication and encryption options.
##
## Security Name.
# sec_name = "myuser"
## Authentication protocol; one of "MD5", "SHA", "SHA224", "SHA256", "SHA384", "SHA512" or "".
# auth_protocol = "MD5"
## Authentication password.
# auth_password = "pass"
## Security Level; one of "noAuthNoPriv", "authNoPriv", or "authPriv".
# sec_level = "authNoPriv"
## Privacy protocol used for encrypted messages; one of "DES", "AES", "AES192", "AES192C", "AES256", "AES256C" or "".
# priv_protocol = ""
## Privacy password used for encrypted messages.
# priv_password = ""
MySQL
[[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})"
## 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"
输入和输出集成示例
SNMP Trap
-
集中式网络监控:将 SNMP Trap 插件集成到集中式监控解决方案中,以实时接收有关网络设备的警报。通过配置插件以侦听来自各种路由器和交换机的陷阱,网络管理员可以快速响应问题,例如设备中断或超出临界阈值。此设置可以实现主动管理和快速解决网络问题,从而最大限度地减少停机时间。
-
自动化事件响应:每当收到特定陷阱时,使用 SNMP Trap 插件触发自动化事件响应工作流程。例如,如果检测到指示硬件故障的陷阱,则可以启动自动化脚本来收集诊断信息、通知支持人员,甚至尝试补救措施。这种方法通过减少人工干预并加快响应时间来提高 IT 运营的效率。
-
网络性能分析:部署 SNMP Trap 插件以收集性能指标以及陷阱,以全面了解网络健康状况。通过将这些数据聚合到分析平台中,网络团队可以分析趋势、识别瓶颈并根据历史数据优化性能。这允许围绕网络升级或更改做出明智的决策和战略规划。
-
与警报系统集成:将 SNMP Trap 插件连接到 PagerDuty 或 Slack 等第三方警报系统。收到预定义的陷阱后,插件可以将警报发送到这些系统,使团队能够立即收到有关重要网络事件的通知。这种集成确保在正确的时间通知正确的人员,从而有助于维持高服务水平和快速解决问题。
MySQL
-
实时 Web 分析存储:利用插件捕获网站性能指标并将其存储在 MySQL 中。此设置使团队能够监控用户交互、分析流量模式并根据实时数据洞察动态调整站点功能。
-
物联网设备监控:利用插件从物联网传感器网络收集指标,并将它们记录到 MySQL 数据库中。此用例支持对设备健康状况和性能的持续监控,从而实现预测性维护和对异常的即时响应。
-
金融交易日志记录:记录具有精确时间戳的高频金融交易数据。这种方法支持强大的审计跟踪、实时欺诈检测以及全面的历史分析,以用于合规性和报告目的。
-
应用程序性能基准测试:将插件与应用程序性能监控系统集成,以将指标记录到 MySQL 中。这有助于随着时间的推移进行详细的基准测试和趋势分析,使组织能够识别性能瓶颈并有效地优化资源分配。
反馈
感谢您成为我们社区的一份子!如果您有任何一般性反馈或在这些页面上发现了任何错误,我们欢迎并鼓励您提出意见。请在 InfluxDB 社区 Slack 中提交您的反馈。