目录
输入和输出集成概述
Modbus 插件允许您使用各种通信方法从 Modbus 设备收集数据,从而增强您监控和控制工业流程的能力。
Telegraf 的 SQL 插件有助于将指标存储在 SQL 数据库中。当配置为 Microsoft SQL Server 时,它支持特定的 DSN 格式和模式要求,从而实现与 SQL Server 的无缝集成。
集成详细信息
Modbus
Modbus 插件通过 Modbus TCP 或 Modbus RTU/ASCII 收集离散输入、线圈、输入寄存器和保持寄存器。
Microsoft SQL Server
Telegraf 的 Microsoft SQL Server SQL 输出插件旨在通过动态创建与传入数据结构匹配的表和列来捕获和存储指标数据。此集成利用 go-mssqldb 驱动程序,该驱动程序通过包含服务器、端口和数据库详细信息的 DSN 遵循 SQL Server 连接协议。尽管由于单元测试有限,该驱动程序被认为是实验性的,但它为动态模式生成和数据插入提供了强大的支持,从而可以详细记录系统性能的时间戳记录。这种灵活性使其成为需要可靠和精细指标日志记录的环境的宝贵工具,尽管其状态为实验性。
配置
Modbus
[[inputs.modbus]]
name = "Device"
slave_id = 1
timeout = "1s"
configuration_type = "register"
discrete_inputs = [
{ name = "start", address = [0]},
{ name = "stop", address = [1]},
{ name = "reset", address = [2]},
{ name = "emergency_stop", address = [3]},
]
coils = [
{ name = "motor1_run", address = [0]},
{ name = "motor1_jog", address = [1]},
{ name = "motor1_stop", address = [2]},
]
holding_registers = [
{ name = "power_factor", byte_order = "AB", data_type = "FIXED", scale=0.01, address = [8]},
{ name = "voltage", byte_order = "AB", data_type = "FIXED", scale=0.1, address = [0]},
{ name = "energy", byte_order = "ABCD", data_type = "FIXED", scale=0.001, address = [5,6]},
{ name = "current", byte_order = "ABCD", data_type = "FIXED", scale=0.001, address = [1,2]},
{ name = "frequency", byte_order = "AB", data_type = "UFIXED", scale=0.1, address = [7]},
{ name = "power", byte_order = "ABCD", data_type = "UFIXED", scale=0.1, address = [3,4]},
{ name = "firmware", byte_order = "AB", data_type = "STRING", address = [5, 6, 7, 8, 9, 10, 11, 12]},
]
input_registers = [
{ name = "tank_level", byte_order = "AB", data_type = "INT16", scale=1.0, address = [0]},
{ name = "tank_ph", byte_order = "AB", data_type = "INT16", scale=1.0, address = [1]},
{ name = "pump1_speed", byte_order = "ABCD", data_type = "INT32", scale=1.0, address = [3,4]},
]
Microsoft SQL Server
[[outputs.sql]]
## Database driver
## Valid options: mssql (Microsoft SQL Server), mysql (MySQL), pgx (Postgres),
## sqlite (SQLite3), snowflake (snowflake.com), clickhouse (ClickHouse)
driver = "mssql"
## Data source name
## For Microsoft SQL Server, the DSN typically includes the server, port, username, password, and database name.
## Example DSN: "sqlserver://username:password@localhost:1433?database=telegraf"
data_source_name = "sqlserver://username:password@localhost:1433?database=telegraf"
## 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} - table name as a quoted identifier
table_exists_template = "SELECT 1 FROM {TABLE} LIMIT 1"
## Initialization SQL (optional)
init_sql = ""
## 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
## Metric type to SQL type conversion
## You can customize the mapping if needed.
#[outputs.sql.convert]
# integer = "INT"
# real = "DOUBLE"
# text = "TEXT"
# timestamp = "TIMESTAMP"
# defaultvalue = "TEXT"
# unsigned = "UNSIGNED"
# bool = "BOOL"
输入和输出集成示例
Modbus
- 基本用法:要从单个设备读取数据,请使用设备名称和 IP 地址对其进行配置,指定从站 ID 和感兴趣的寄存器。
- 多个请求:您可以通过指定多个
[[inputs.modbus.request]]
部分,在单个配置中定义多个请求以从不同的 Modbus 从站设备获取数据。 - 数据处理:利用缩放功能将原始 Modbus 读数转换为有用的指标,根据需要调整单位转换。
Microsoft SQL Server
-
企业应用监控:利用插件捕获从 SQL Server 上运行的企业应用程序的详细性能指标。 此设置允许 IT 团队分析系统性能、跟踪事务时间并识别复杂多层环境中的瓶颈。
-
动态基础设施审计:部署插件以在 SQL Server 中创建基础设施变更和性能指标的动态审计日志。 此用例非常适合需要实时监控和系统性能历史分析以进行合规性和优化的组织。
-
自动化性能基准测试:使用插件持续记录和分析 SQL Server 数据库的性能指标。 这实现了自动化基准测试,将历史数据与当前性能进行比较,有助于快速识别服务中的异常或降级。
-
集成 DevOps 仪表板:将插件与 DevOps 监控工具集成,以将 SQL Server 的实时指标馈送到集中式仪表板。 这提供了应用程序健康状况的整体视图,使团队可以将 SQL Server 性能与应用程序级事件相关联,从而加快故障排除和主动维护。
反馈
感谢您成为我们社区的一份子! 如果您有任何一般反馈或在这些页面上发现任何错误,我们欢迎并鼓励您提出意见。 请在 InfluxDB 社区 Slack 中提交您的反馈。