目录
强大的性能,无限的扩展
收集、组织和处理海量高速数据。 当您将任何数据视为时间序列数据时,它都会更有价值。 借助 InfluxDB,这个排名第一的时序平台旨在与 Telegraf 一起扩展。
查看入门方法
输入和输出集成概述
Telegraf 的 Nginx 插件旨在从 Nginx Web 服务器收集状态指标,从而提供对服务器运行指标的实时洞察。
Telegraf 的 SQL 输出插件通过为每种指标类型动态创建表,将指标存储在 SQL 数据库中。 当配置为 SQLite 时,它使用基于文件的 DSN 和为轻量级嵌入式数据库使用量身定制的最小 SQL 模式。
集成详情
Nginx
此插件从 Nginx 收集状态指标。 它利用 ngx_http_stub_status_module 收集与服务器性能相关的基本指标。 该插件提供了关于活动连接数、已处理请求数和各种指标当前状态的宝贵见解。 这种实时数据对于监控 Web 服务器性能和确保最佳运行至关重要。 配置允许用户指定 Nginx 状态端点的 URL、设置超时以及在必要时配置 TLS 设置。
SQLite
SQL 输出插件使用动态模式将 Telegraf 指标写入 SQL 数据库,其中每种指标类型对应一个表。 对于 SQLite,该插件使用 modernc.org/sqlite 驱动程序,并且需要文件 URI 格式的 DSN(例如,“file:/path/to/telegraf.db?cache=shared”)。 此配置利用标准 ANSI SQL 进行表创建和数据插入,确保与 SQLite 的功能兼容。
配置
Nginx
[[inputs.nginx]]
## An array of Nginx stub_status URI to gather stats.
urls = ["http://localhost/server_status"]
## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Use TLS but skip chain & host verification
# insecure_skip_verify = false
## HTTP response timeout (default: 5s)
response_timeout = "5s"
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"
输入和输出集成示例
Nginx
-
Web 性能监控:使用 Nginx 插件从基础设施中的各种 Nginx 服务器收集性能指标。 通过在实时仪表板中可视化这些指标,团队可以跟踪性能趋势、识别瓶颈并增强 Web 应用程序的用户体验。 实施此类监控使企业能够主动解决性能问题,从而在问题影响最终用户之前解决。
-
负载均衡器监控:将此插件与您的负载均衡器集成,以跟踪后端 Nginx 服务器的性能。 通过收集“活动连接数”和“已处理请求数”等统计信息,您的运营团队可以确保流量以最佳方式流动,并且没有单个服务器过载。 这种主动负载均衡方法可以防止服务停机并增强用户体验。
-
自动化警报系统:将 Nginx 插件与警报服务结合使用,以便在服务器指标超过预定义阈值时自动通知您的团队。 例如,如果活动连接数过高,系统可以触发警报,以便立即采取纠正措施,从而保持服务质量和可靠性。
-
历史数据分析:将 Nginx 插件收集的指标存储在时序数据库中,以分析历史性能趋势。 此分析可以揭示高流量或性能不佳的时期,从而可以根据数据驱动的决策来扩展和优化基础设施。 通过了解过去的趋势,组织可以更好地为未来的需求做好准备。
SQLite
- 本地监控存储:配置插件以将指标写入本地 SQLite 数据库文件。 这非常适合不需要设置全面数据库服务器的轻量级部署。
- 嵌入式应用程序:使用 SQLite 作为边缘设备中嵌入式应用程序的后端,受益于其基于文件的架构和最低资源要求。
- 快速设置以进行测试:利用 SQLite 的易用性,快速设置 Telegraf 指标收集的测试环境,而无需外部数据库服务。
- 自定义模式管理:如果您需要特定的列类型或索引,请调整表创建模板以预定义您的模式,从而确保与您的应用程序需求兼容。
反馈
感谢您成为我们社区的一份子! 如果您有任何一般性反馈或在这些页面上发现了任何错误,我们欢迎并鼓励您提出意见。 请在 InfluxDB 社区 Slack 中提交您的反馈。
强大的性能,无限的扩展
收集、组织和处理海量高速数据。 当您将任何数据视为时间序列数据时,它都会更有价值。 借助 InfluxDB,这个排名第一的时序平台旨在与 Telegraf 一起扩展。
查看入门方法