目录
输入和输出集成概述
Fluentd 输入插件从 Fluentd 的 in_monitor 插件端点收集指标。它提供对各种插件指标的深入了解,同时允许自定义配置以减少序列基数。
Telegraf PostgreSQL 插件允许您高效地将指标写入 PostgreSQL 数据库,同时自动管理数据库模式。
集成详情
Fluentd
此插件从 in_monitor 插件提供的 Fluentd 插件端点收集指标。它从 /api/plugin.json 资源读取数据,并允许根据插件类型排除特定插件。
PostgreSQL
PostgreSQL 插件使用户能够将指标写入 PostgreSQL 数据库或兼容数据库,为模式管理提供强大的支持,通过自动更新缺失的列。该插件旨在促进与监控解决方案的集成,使用户能够高效地存储和管理时间序列数据。它为连接设置、并发和错误处理提供可配置的选项,并支持 JSONB 存储标签和字段、外键标记、模板化模式修改以及通过 pguint 扩展支持无符号整数数据类型等高级功能。
配置
Fluentd
[[inputs.fluentd]]
## This plugin reads information exposed by fluentd (using /api/plugins.json endpoint).
##
## Endpoint:
## - only one URI is allowed
## - https is not supported
endpoint = "http://localhost:24220/api/plugins.json"
## Define which plugins have to be excluded (based on "type" field - e.g. monitor_agent)
exclude = [
"monitor_agent",
"dummy",
]
PostgreSQL
# Publishes metrics to a postgresql database
[[outputs.postgresql]]
## Specify connection address via the standard libpq connection string:
## host=... user=... password=... sslmode=... dbname=...
## Or a URL:
## postgres://[user[:password]]@localhost[/dbname]?sslmode=[disable|verify-ca|verify-full]
## See https://postgresql.ac.cn/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
##
## All connection parameters are optional. Environment vars are also supported.
## e.g. PGPASSWORD, PGHOST, PGUSER, PGDATABASE
## All supported vars can be found here:
## https://postgresql.ac.cn/docs/current/libpq-envars.html
##
## Non-standard parameters:
## pool_max_conns (default: 1) - Maximum size of connection pool for parallel (per-batch per-table) inserts.
## pool_min_conns (default: 0) - Minimum size of connection pool.
## pool_max_conn_lifetime (default: 0s) - Maximum age of a connection before closing.
## pool_max_conn_idle_time (default: 0s) - Maximum idle time of a connection before closing.
## pool_health_check_period (default: 0s) - Duration between health checks on idle connections.
# connection = ""
## Postgres schema to use.
# schema = "public"
## Store tags as foreign keys in the metrics table. Default is false.
# tags_as_foreign_keys = false
## Suffix to append to table name (measurement name) for the foreign tag table.
# tag_table_suffix = "_tag"
## Deny inserting metrics if the foreign tag can't be inserted.
# foreign_tag_constraint = false
## Store all tags as a JSONB object in a single 'tags' column.
# tags_as_jsonb = false
## Store all fields as a JSONB object in a single 'fields' column.
# fields_as_jsonb = false
## Name of the timestamp column
## NOTE: Some tools (e.g. Grafana) require the default name so be careful!
# timestamp_column_name = "time"
## Type of the timestamp column
## Currently, "timestamp without time zone" and "timestamp with time zone"
## are supported
# timestamp_column_type = "timestamp without time zone"
## Templated statements to execute when creating a new table.
# create_templates = [
# '''CREATE TABLE {{ .table }} ({{ .columns }})''',
# ]
## Templated statements to execute when adding columns to a table.
## Set to an empty list to disable. Points containing tags for which there is no column will be skipped. Points
## containing fields for which there is no column will have the field omitted.
# add_column_templates = [
# '''ALTER TABLE {{ .table }} ADD COLUMN IF NOT EXISTS {{ .columns|join ", ADD COLUMN IF NOT EXISTS " }}''',
# ]
## Templated statements to execute when creating a new tag table.
# tag_table_create_templates = [
# '''CREATE TABLE {{ .table }} ({{ .columns }}, PRIMARY KEY (tag_id))''',
# ]
## Templated statements to execute when adding columns to a tag table.
## Set to an empty list to disable. Points containing tags for which there is no column will be skipped.
# tag_table_add_column_templates = [
# '''ALTER TABLE {{ .table }} ADD COLUMN IF NOT EXISTS {{ .columns|join ", ADD COLUMN IF NOT EXISTS " }}''',
# ]
## The postgres data type to use for storing unsigned 64-bit integer values (Postgres does not have a native
## unsigned 64-bit integer type).
## The value can be one of:
## numeric - Uses the PostgreSQL "numeric" data type.
## uint8 - Requires pguint extension (https://github.com/petere/pguint)
# uint64_type = "numeric"
## When using pool_max_conns>1, and a temporary error occurs, the query is retried with an incremental backoff. This
## controls the maximum backoff duration.
# retry_max_backoff = "15s"
## Approximate number of tag IDs to store in in-memory cache (when using tags_as_foreign_keys).
## This is an optimization to skip inserting known tag IDs.
## Each entry consumes approximately 34 bytes of memory.
# tag_cache_size = 100000
## Enable & set the log level for the Postgres driver.
# log_level = "warn" # trace, debug, info, warn, error, none
输入和输出集成示例
Fluentd
- 基本配置:设置 Fluentd 输入插件以从 Fluentd 实例的监控端点收集指标,确保您能够跟踪性能和使用统计信息。
- 排除插件:使用
exclude
选项忽略监控需求不必要的特定插件指标,从而简化数据收集并专注于重要事项。 - 自定义插件 ID:在 Fluentd 配置中实现
@id
参数以保持一致的plugin_id
,这有助于避免频繁重启期间出现高序列基数的问题。
PostgreSQL
-
使用复杂查询进行实时分析:利用 PostgreSQL 插件将来自各种来源的指标存储在 PostgreSQL 数据库中,从而可以使用复杂查询进行实时分析。此设置可以帮助数据科学家和分析师发现模式和趋势,因为他们可以在多个表之间操作关系数据,同时利用 PostgreSQL 强大的查询优化功能。具体来说,用户可以使用跨不同指标表的 JOIN 操作创建复杂的报告,从而揭示通常在嵌入式系统中隐藏的见解。
-
与 TimescaleDB 集成以进行时间序列数据处理:在 TimescaleDB 实例中使用 PostgreSQL 插件,以高效地处理和分析时间序列数据。通过实施超表,用户可以在时间维度上实现更高的性能和主题分区。这种集成允许用户对大量时间序列数据运行分析查询,同时保留 PostgreSQL SQL 查询的全部功能,从而确保指标分析的可靠性和效率。
-
数据版本控制和历史分析:实施使用 PostgreSQL 插件的策略以维护指标的不同版本。用户可以设置不可变的数据表结构,其中保留旧版本的表,从而轻松进行历史分析。这种方法不仅提供了对数据演变的深入了解,还有助于遵守数据保留策略,确保数据集历史完整性保持不变。
-
用于不断演变的指标的动态模式管理:使用插件的模板功能来创建动态变化的模式,以响应指标变化。此用例允许组织在指标演变时调整其数据结构,添加必要的字段并确保遵守数据完整性策略。通过利用模板化的 SQL 命令,用户无需手动干预即可扩展数据库,从而促进敏捷数据管理实践。
反馈
感谢您成为我们社区的一份子!如果您有任何一般反馈或在这些页面上发现任何错误,我们欢迎并鼓励您提出意见。请在 InfluxDB 社区 Slack 中提交您的反馈。