目录
输入和输出集成概述
SNMP Trap Telegraf 插件支持接收 SNMP 通知,通过捕获来自网络设备的重要事件,促进全面的网络监控。
此插件使用参数化的 SQL INSERT 语句将来自 Telegraf 的指标直接写入 MariaDB,提供了一种将指标存储在结构化关系表中的灵活方法。
集成详情
SNMP Trap
SNMP Trap 插件充当 SNMP 通知(称为 trap 和 inform 请求)的接收端点。它通过 UDP 运行,监听传入的通知,这些通知可以配置为在特定端口上到达。此插件是网络监控和管理不可或缺的一部分,允许系统收集和响应从整个网络中的各种设备(包括路由器、交换机和服务器)发送的 SNMP trap。该插件通过 SNMPv3 支持安全传输选项,从而可以配置身份验证和加密参数以保护敏感数据。此外,它还使用户可以灵活地配置 SNMP 的多个方面,例如 MIB 文件位置,使其适用于各种环境和用例。建议从已弃用的 netsnmp 后端过渡到更新的 gosmi 后端,以利用其增强的功能和支持。实施此插件的用户可以有效地监控网络事件、自动响应 trap 并维护强大的网络监控基础设施。
MariaDB
Telegraf 中的 SQL 输出插件通过执行参数化的 SQL 语句,可以将指标直接写入 MariaDB 等 SQL 兼容数据库。凭借对 MySQL 驱动程序的支持,该插件与 MariaDB 无缝集成,以实现可靠、结构化的指标存储。对于喜欢基于 SQL 的分析或希望将指标与业务数据一起存储以进行统一查询的用户来说,此设置是理想的选择。MariaDB 是 MySQL 的社区开发的、企业级的 fork,它强调性能、安全性以及开放性。该插件支持将时序指标插入自定义架构,从而可以使用 SQL 连接器灵活地进行分析以及与 Metabase 或 Grafana 等 BI 工具集成。
配置
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 = ""
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"
输入和输出集成示例
SNMP Trap
-
集中式网络监控:将 SNMP Trap 插件集成到集中式监控解决方案中,以实时接收有关网络设备的警报。通过配置插件以监听来自各种路由器和交换机的 trap,网络管理员可以快速响应问题,例如设备中断或超出关键阈值。此设置可以实现主动管理和快速解决网络问题,从而最大限度地减少停机时间。
-
自动化事件响应:每当收到特定 trap 时,使用 SNMP Trap 插件触发自动化事件响应工作流程。例如,如果检测到指示硬件故障的 trap,则可以启动自动化脚本来收集诊断信息、通知支持人员,甚至尝试修复操作。这种方法通过减少人工干预和加快响应时间来提高 IT 运营效率。
-
网络性能分析:部署 SNMP Trap 插件以收集性能指标以及 trap,以全面了解网络运行状况。通过将这些数据聚合到分析平台中,网络团队可以分析趋势、识别瓶颈并根据历史数据优化性能。这有助于围绕网络升级或更改做出明智的决策和战略规划。
-
与警报系统集成:将 SNMP Trap 插件连接到 PagerDuty 或 Slack 等第三方警报系统。收到预定义的 trap 后,插件可以将警报发送到这些系统,使团队能够立即收到重要网络事件的通知。这种集成确保在正确的时间通知正确的人员,从而有助于保持高服务水平和快速解决问题。
MariaDB
-
商业智能集成:将应用程序性能指标直接存储到 MariaDB 中,并将其连接到 Metabase 或 Apache Superset 等 BI 工具。此设置允许将运营数据与业务 KPI 混合,以实现统一的仪表板,从而提高跨部门的可见性。
-
具有历史指标的合规性报告:使用此插件将指标记录到 MariaDB 中,以用于审计和合规性用例。关系模型支持使用时间戳条目精确查询过去的性能指标,从而支持法规文档。
-
基于 SQL 逻辑的自定义警报:将指标插入 MariaDB,并使用自定义 SQL 查询来定义警报阈值或条件。与 cron 作业或计划脚本结合使用,这可以实现传统指标平台无法实现的高级警报工作流程。
-
IoT 传感器指标存储:通过 Telegraf 从 IoT 设备收集传感器数据,并使用规范化架构将其存储在 MariaDB 中。这种方法经济高效,并且可以很好地与现有的基于 SQL 的系统集成,以进行实时或历史分析。
反馈
感谢您成为我们社区的一份子!如果您有任何一般性反馈或在这些页面上发现了任何错误,我们欢迎并鼓励您提出意见。请在 InfluxDB 社区 Slack 中提交您的反馈。