目录
强大的性能,无限的扩展能力
收集、组织和处理海量高速数据。当您将任何数据视为时间序列数据时,它都更有价值。借助 InfluxDB,由 Telegraf 构建的排名第一的时间序列平台,可随需扩展。
查看入门方法
输入和输出集成概述
此插件与 Apache HTTP 服务器的 mod_status 接口连接,以收集和报告服务器的性能指标。
Telegraf 的 SQL 输出插件通过为每种指标类型动态创建表,将指标存储在 SQL 数据库中。当配置为 SQLite 时,它使用基于文件的 DSN 和专为轻量级嵌入式数据库使用而定制的最小 SQL 模式。
集成详细信息
Apache
Apache 插件使用 Apache HTTP 服务器的 mod_status 模块收集服务器性能信息。它依赖于 mod_status 功能,该功能必须在 Apache 配置中显式启用,才能访问机器可读的状态页面。此插件允许用户获取与 Apache 运行性能相关的多个指标,包括工作进程状态、连接统计信息和服务器负载,从而有助于实时有效地监控和排除 Web 服务器性能故障。
SQLite
SQL 输出插件使用动态模式将 Telegraf 指标写入 SQL 数据库,其中每种指标类型对应一个表。对于 SQLite,该插件使用 modernc.org/sqlite 驱动程序,并且需要采用文件 URI 格式的 DSN(例如,“file:/path/to/telegraf.db?cache=shared”)。此配置利用标准 ANSI SQL 进行表创建和数据插入,确保与 SQLite 的功能兼容。
配置
Apache
[[inputs.apache]]
## An array of URLs to gather from, must be directed at the machine
## readable version of the mod_status page including the auto query string.
## Default is "http://localhost/server-status?auto".
urls = ["http://localhost/server-status?auto"]
## Credentials for basic HTTP authentication.
# username = "myuser"
# password = "mypassword"
## Maximum time to receive response.
# response_timeout = "5s"
## 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
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"
输入和输出集成示例
Apache
-
实时性能监控:使用 Apache 输入插件设置实时仪表板,显示 Apache 服务器的关键性能指标。通过可视化 BusyWorkers 和平均负载等指标,您可以快速识别性能瓶颈和服务器运行状况问题,从而帮助主动管理 Web 流量负载。
-
服务器问题自动警报:基于此插件收集的指标实施警报,以便在性能下降时通知管理员。例如,如果
BusyWorkers
指标超过某个阈值,则可以触发自动警报,确保及时响应事件,以维护正常运行时间和服务的可靠性。 -
历史性能分析:将 Apache 插件收集的数据与长期存储解决方案结合使用,以跟踪一段时间内的性能趋势。此累积数据有助于了解使用模式、预测资源需求以及做出有关服务器扩展或优化的明智决策。
-
跨系统监控:使用 Telegraf 的功能将从 Apache 收集的指标与 Web 堆栈其他组件的指标集成,以将数据发送到集中式监控解决方案。这种整体视图可以简化不同技术之间的故障排除和协调,从而确保整个系统性能达到最佳。
SQLite
- 本地监控存储:配置插件以将指标写入本地 SQLite 数据库文件。这非常适合不需要设置全规模数据库服务器的轻量级部署。
- 嵌入式应用程序:将 SQLite 用作边缘设备中嵌入式应用程序的后端,受益于其基于文件的架构和最低的资源需求。
- 快速设置以进行测试:利用 SQLite 的易用性,快速设置 Telegraf 指标收集的测试环境,而无需外部数据库服务。
- 自定义架构管理:如果您需要特定的列类型或索引,请调整表创建模板以预定义您的架构,从而确保与您的应用程序需求兼容。
反馈
感谢您成为我们社区的一份子!如果您对这些页面有任何一般性反馈或发现任何错误,我们欢迎并鼓励您提出意见。请在 InfluxDB 社区 Slack 中提交您的反馈。
强大的性能,无限的扩展能力
收集、组织和处理海量高速数据。当您将任何数据视为时间序列数据时,它都更有价值。借助 InfluxDB,由 Telegraf 构建的排名第一的时间序列平台,可随需扩展。
查看入门方法