目录
输入和输出集成概述
OPC UA 插件提供了一个接口,用于从 OPC UA 服务器设备检索数据,从而促进有效的数据收集和监控。
Telegraf 的 SQL 插件促进了指标在 SQL 数据库中的存储。当配置为 Microsoft SQL Server 时,它支持特定的 DSN 格式和模式要求,从而实现与 SQL Server 的无缝集成。
集成详情
OPC UA
OPC UA 插件从使用 OPC UA 协议通信的设备检索数据,允许您从 OPC UA 服务器收集和监控数据。
Microsoft SQL Server
Telegraf 的 Microsoft SQL Server SQL 输出插件旨在通过动态创建与传入数据结构匹配的表和列来捕获和存储指标数据。此集成利用 go-mssqldb 驱动程序,该驱动程序通过包含服务器、端口和数据库详细信息的 DSN 遵循 SQL Server 连接协议。尽管由于单元测试有限,该驱动程序被认为是实验性的,但它为动态模式生成和数据插入提供了强大的支持,从而能够详细记录系统性能的时间戳记录。这种灵活性使其成为需要可靠和精细指标日志记录的环境的宝贵工具,尽管其状态为实验性。
配置
OPC UA
[[inputs.opcua]]
## Metric name
# name = "opcua"
#
## OPC UA Endpoint URL
# endpoint = "opc.tcp://localhost:4840"
#
## Maximum time allowed to establish a connect to the endpoint.
# connect_timeout = "10s"
#
## Maximum time allowed for a request over the established connection.
# request_timeout = "5s"
# Maximum time that a session shall remain open without activity.
# session_timeout = "20m"
#
## Security policy, one of "None", "Basic128Rsa15", "Basic256",
## "Basic256Sha256", or "auto"
# security_policy = "auto"
#
## Security mode, one of "None", "Sign", "SignAndEncrypt", or "auto"
# security_mode = "auto"
#
## Path to cert.pem. Required when security mode or policy isn't "None".
## If cert path is not supplied, self-signed cert and key will be generated.
# certificate = "/etc/telegraf/cert.pem"
#
## Path to private key.pem. Required when security mode or policy isn't "None".
## If key path is not supplied, self-signed cert and key will be generated.
# private_key = "/etc/telegraf/key.pem"
#
## Authentication Method, one of "Certificate", "UserName", or "Anonymous". To
## authenticate using a specific ID, select 'Certificate' or 'UserName'
# auth_method = "Anonymous"
#
## Username. Required for auth_method = "UserName"
# username = ""
#
## Password. Required for auth_method = "UserName"
# password = ""
#
## Option to select the metric timestamp to use. Valid options are:
## "gather" -- uses the time of receiving the data in telegraf
## "server" -- uses the timestamp provided by the server
## "source" -- uses the timestamp provided by the source
# timestamp = "gather"
#
## Client trace messages
## When set to true, and debug mode enabled in the agent settings, the OPCUA
## client's messages are included in telegraf logs. These messages are very
## noisey, but essential for debugging issues.
# client_trace = false
#
## Include additional Fields in each metric
## Available options are:
## DataType -- OPC-UA Data Type (string)
# optional_fields = []
#
## Node ID configuration
## name - field name to use in the output
## namespace - OPC UA namespace of the node (integer value 0 thru 3)
## identifier_type - OPC UA ID type (s=string, i=numeric, g=guid, b=opaque)
## identifier - OPC UA ID (tag as shown in opcua browser)
## tags - extra tags to be added to the output metric (optional); deprecated in 1.25.0; use default_tags
## default_tags - extra tags to be added to the output metric (optional)
##
## Use either the inline notation or the bracketed notation, not both.
#
## Inline notation (default_tags not supported yet)
# nodes = [
# {name="", namespace="", identifier_type="", identifier="", tags=[["tag1", "value1"], ["tag2", "value2"]},
# {name="", namespace="", identifier_type="", identifier=""},
# ]
#
## Bracketed notation
# [[inputs.opcua.nodes]]
# name = "node1"
# namespace = ""
# identifier_type = ""
# identifier = ""
# default_tags = { tag1 = "value1", tag2 = "value2" }
#
# [[inputs.opcua.nodes]]
# name = "node2"
# namespace = ""
# identifier_type = ""
# identifier = ""
#
## Node Group
## Sets defaults so they aren't required in every node.
## Default values can be set for:
## * Metric name
## * OPC UA namespace
## * Identifier
## * Default tags
##
## Multiple node groups are allowed
#[[inputs.opcua.group]]
## Group Metric name. Overrides the top level name. If unset, the
## top level name is used.
# name =
#
## Group default namespace. If a node in the group doesn't set its
## namespace, this is used.
# namespace =
#
## Group default identifier type. If a node in the group doesn't set its
## namespace, this is used.
# identifier_type =
#
## Default tags that are applied to every node in this group. Can be
## overwritten in a node by setting a different value for the tag name.
## example: default_tags = { tag1 = "value1" }
# default_tags = {}
#
## Node ID Configuration. Array of nodes with the same settings as above.
## Use either the inline notation or the bracketed notation, not both.
#
## Inline notation (default_tags not supported yet)
# nodes = [
# {name="node1", namespace="", identifier_type="", identifier=""},
# {name="node2", namespace="", identifier_type="", identifier=""},
#]
#
## Bracketed notation
# [[inputs.opcua.group.nodes]]
# name = "node1"
# namespace = ""
# identifier_type = ""
# identifier = ""
# default_tags = { tag1 = "override1", tag2 = "value2" }
#
# [[inputs.opcua.group.nodes]]
# name = "node2"
# namespace = ""
# identifier_type = ""
# identifier = ""
## Enable workarounds required by some devices to work correctly
# [inputs.opcua.workarounds]
## Set additional valid status codes, StatusOK (0x0) is always considered valid
# additional_valid_status_codes = ["0xC0"]
# [inputs.opcua.request_workarounds]
## Use unregistered reads instead of registered reads
# use_unregistered_reads = false
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"
输入和输出集成示例
OPC UA
-
基本配置:使用您的 OPC UA 服务器端点和所需的指标设置插件。这允许 Telegraf 开始从配置的节点收集指标。
-
节点 ID 设置:使用配置来指定特定节点,例如温度传感器,以实时监控其值。例如,配置节点 ns=3;s=Temperature 以直接收集温度数据。
-
组配置:通过将多个节点分组到单个配置下来简化监控多个节点—这为该组中的所有节点设置默认值,从而减少设置中的冗余。
Microsoft SQL Server
-
企业应用监控:利用插件捕获从 SQL Server 上运行的企业应用程序的详细性能指标。此设置允许 IT 团队分析系统性能、跟踪事务时间并识别跨复杂、多层环境的瓶颈。
-
动态基础设施审计:部署插件以在 SQL Server 中创建基础设施变更和性能指标的动态审计日志。此用例非常适合需要实时监控和历史分析系统性能以进行合规性和优化的组织。
-
自动化性能基准测试:使用插件持续记录和分析 SQL Server 数据库的性能指标。这实现了自动化基准测试,将历史数据与当前性能进行比较,有助于快速识别服务中的异常或退化。
-
集成 DevOps 仪表板:将插件与 DevOps 监控工具集成,以将来自 SQL Server 的实时指标馈送到集中式仪表板中。这提供了应用程序健康状况的整体视图,允许团队将 SQL Server 性能与应用程序级事件相关联,以便更快地进行故障排除和主动维护。
反馈
感谢您成为我们社区的一份子!如果您有任何一般性反馈或在这些页面上发现了任何错误,我们欢迎并鼓励您提供意见。请在 InfluxDB 社区 Slack 中提交您的反馈。