目录
输入和输出集成概述
Zipkin 输入插件允许从微服务收集跟踪信息和定时数据。 这种能力对于诊断复杂面向服务环境中的延迟问题至关重要。
Telegraf 的 SQL 输出插件通过为每种指标类型动态创建表,将指标存储在 SQL 数据库中。 当配置为 SQLite 时,它使用基于文件的 DSN 和为轻量级嵌入式数据库使用量身定制的最小 SQL 模式。
集成细节
Zipkin
此插件实现了 Zipkin HTTP 服务器,以收集跟踪和定时数据,这对于解决微服务架构中的延迟问题至关重要。 Zipkin 是一个分布式跟踪系统,可帮助收集跨各种微服务的定时数据,使团队能够可视化请求流并识别性能瓶颈。 该插件支持基于指定的 Content-Type 的 JSON 或 thrift 格式的输入跟踪。 此外,它还利用 span 元数据来跟踪请求的定时,从而增强了符合 OpenTracing 标准的应用程序的可观察性。 作为一个实验性功能,其配置和模式可能会随着时间的推移而演变,以更好地满足用户需求和分布式跟踪方法的进步。
SQLite
SQL 输出插件使用动态模式将 Telegraf 指标写入 SQL 数据库,其中每种指标类型对应一个表。 对于 SQLite,该插件使用 modernc.org/sqlite 驱动程序,并且需要 DSN 采用文件 URI 格式(例如,‘file:/path/to/telegraf.db?cache=shared’)。 此配置利用标准 ANSI SQL 进行表创建和数据插入,确保与 SQLite 的功能兼容。
配置
Zipkin
[[inputs.zipkin]]
## URL path for span data
# path = "/api/v1/spans"
## Port on which Telegraf listens
# port = 9411
## Maximum duration before timing out read of the request
# read_timeout = "10s"
## Maximum duration before timing out write of the response
# write_timeout = "10s"
SQLite
[[outputs.sql]]
## Database driver
## Valid options: mssql (Microsoft SQL Server), mysql (MySQL), pgx (Postgres),
## sqlite (SQLite3), snowflake (snowflake.com), clickhouse (ClickHouse)
driver = "sqlite"
## Data source name
## For SQLite, the DSN is a filename or URL with the scheme "file:".
## Example: "file:/path/to/telegraf.db?cache=shared"
data_source_name = "file:/path/to/telegraf.db?cache=shared"
## 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
## The values on the left are the data types Telegraf has and the values on the right are the SQL types used when writing to SQLite.
#[outputs.sql.convert]
# integer = "INT"
# real = "DOUBLE"
# text = "TEXT"
# timestamp = "TIMESTAMP"
# defaultvalue = "TEXT"
# unsigned = "UNSIGNED"
# bool = "BOOL"
输入和输出集成示例
Zipkin
-
微服务中的延迟监控:使用 Zipkin 输入插件捕获和分析来自微服务架构的跟踪数据。 通过可视化请求流并查明延迟源,开发团队可以优化服务交互,缩短响应时间,并确保跨服务获得更流畅的用户体验。
-
关键服务中的性能优化:在关键服务中集成该插件,不仅可以监控响应时间,还可以跟踪可能突出显示性能问题的特定注释。 收集 span 数据的功能可以帮助确定需要性能增强的区域的优先级,从而实现有针对性的改进。
-
动态服务依赖关系映射:使用收集的跟踪数据,自动映射服务依赖关系并在仪表板中可视化它们。 这有助于团队了解不同服务如何交互以及故障或速度减慢的影响,最终促成更好的架构决策和更快的问题解决。
-
服务延迟中的异常检测:将 Zipkin 数据与机器学习模型结合使用,以检测服务延迟和请求处理时间中的异常模式。 通过自动识别异常,运营团队可以在新兴问题升级为严重故障之前主动响应。
SQLite
- 本地监控存储:将插件配置为将指标写入本地 SQLite 数据库文件。 这非常适合不需要设置全规模数据库服务器的轻量级部署。
- 嵌入式应用程序:使用 SQLite 作为嵌入在边缘设备中的应用程序的后端,受益于其基于文件的架构和最小的资源需求。
- 快速设置进行测试:利用 SQLite 的易用性,快速设置 Telegraf 指标收集的测试环境,而无需外部数据库服务。
- 自定义模式管理:如果您需要特定的列类型或索引,请调整表创建模板以预定义您的模式,确保与您的应用程序需求兼容。
反馈
感谢您成为我们社区的一份子!如果您有任何一般性反馈或在这些页面上发现了任何错误,我们欢迎并鼓励您提出意见。 请在 InfluxDB 社区 Slack 中提交您的反馈。