目录
输入和输出集成概述
Docker 输入插件允许您使用 Docker Engine API 从 Docker 容器中收集指标,从而增强容器化应用程序的可见性和监控。
MongoDB Telegraf 插件使用户能够将指标发送到 MongoDB 数据库,自动管理时序集合。
集成详情
Docker
Telegraf 的 Docker 输入插件从 Docker Engine API 收集有价值的指标,从而提供对正在运行的容器的洞察。此插件利用官方 Docker 客户端与 Engine API 交互,允许用户监控各种容器状态、资源分配和性能指标。凭借按名称和状态过滤容器的选项,以及可自定义的标签,此插件支持在各种环境中监控容器化应用程序的灵活性,无论是在本地系统上还是在 Kubernetes 等编排平台中。此外,它通过要求访问 Docker 守护程序的权限来解决安全考虑,并强调在容器化环境中部署时进行适当的配置。
MongoDB
此插件将指标发送到 MongoDB,并与其时序功能无缝集成,从而允许在时序集合尚不存在时自动创建为时序集合。它需要 MongoDB 5.0 或更高版本才能使用时序集合功能,这对于高效存储和查询基于时间的数据至关重要。此插件通过确保所有相关指标都正确存储并在 MongoDB 中组织,从而增强了监控功能,使用户能够利用 MongoDB 强大的查询和聚合功能进行时序分析。
配置
Docker
[[inputs.docker]]
## Docker Endpoint
## To use TCP, set endpoint = "tcp://[ip]:[port]"
## To use environment variables (ie, docker-machine), set endpoint = "ENV"
endpoint = "unix:///var/run/docker.sock"
## Set to true to collect Swarm metrics(desired_replicas, running_replicas)
## Note: configure this in one of the manager nodes in a Swarm cluster.
## configuring in multiple Swarm managers results in duplication of metrics.
gather_services = false
## Only collect metrics for these containers. Values will be appended to
## container_name_include.
## Deprecated (1.4.0), use container_name_include
container_names = []
## Set the source tag for the metrics to the container ID hostname, eg first 12 chars
source_tag = false
## Containers to include and exclude. Collect all if empty. Globs accepted.
container_name_include = []
container_name_exclude = []
## Container states to include and exclude. Globs accepted.
## When empty only containers in the "running" state will be captured.
# container_state_include = []
# container_state_exclude = []
## Objects to include for disk usage query
## Allowed values are "container", "image", "volume"
## When empty disk usage is excluded
storage_objects = []
## Timeout for docker list, info, and stats commands
timeout = "5s"
## Whether to report for each container per-device blkio (8:0, 8:1...),
## network (eth0, eth1, ...) and cpu (cpu0, cpu1, ...) stats or not.
## Usage of this setting is discouraged since it will be deprecated in favor of 'perdevice_include'.
## Default value is 'true' for backwards compatibility, please set it to 'false' so that 'perdevice_include' setting
## is honored.
perdevice = true
## Specifies for which classes a per-device metric should be issued
## Possible values are 'cpu' (cpu0, cpu1, ...), 'blkio' (8:0, 8:1, ...) and 'network' (eth0, eth1, ...)
## Please note that this setting has no effect if 'perdevice' is set to 'true'
# perdevice_include = ["cpu"]
## Whether to report for each container total blkio and network stats or not.
## Usage of this setting is discouraged since it will be deprecated in favor of 'total_include'.
## Default value is 'false' for backwards compatibility, please set it to 'true' so that 'total_include' setting
## is honored.
total = false
## Specifies for which classes a total metric should be issued. Total is an aggregated of the 'perdevice' values.
## Possible values are 'cpu', 'blkio' and 'network'
## Total 'cpu' is reported directly by Docker daemon, and 'network' and 'blkio' totals are aggregated by this plugin.
## Please note that this setting has no effect if 'total' is set to 'false'
# total_include = ["cpu", "blkio", "network"]
## docker labels to include and exclude as tags. Globs accepted.
## Note that an empty array for both will include all labels as tags
docker_label_include = []
docker_label_exclude = []
## Which environment variables should we use as a tag
tag_env = ["JAVA_HOME", "HEAP_SIZE"]
## 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
MongoDB
[[outputs.mongodb]]
# connection string examples for mongodb
dsn = "mongodb://localhost:27017"
# dsn = "mongodb://mongod1:27017,mongod2:27017,mongod3:27017/admin&replicaSet=myReplSet&w=1"
# overrides serverSelectionTimeoutMS in dsn if set
# timeout = "30s"
# default authentication, optional
# authentication = "NONE"
# for SCRAM-SHA-256 authentication
# authentication = "SCRAM"
# username = "root"
# password = "***"
# for x509 certificate authentication
# authentication = "X509"
# tls_ca = "ca.pem"
# tls_key = "client.pem"
# # tls_key_pwd = "changeme" # required for encrypted tls_key
# insecure_skip_verify = false
# database to store measurements and time series collections
# database = "telegraf"
# granularity can be seconds, minutes, or hours.
# configuring this value will be based on your input collection frequency.
# see https://docs.mongodb.com/manual/core/timeseries-collections/#create-a-time-series-collection
# granularity = "seconds"
# optionally set a TTL to automatically expire documents from the measurement collections.
# ttl = "360h"
输入和输出集成示例
Docker
-
监控容器化应用程序的性能:使用 Docker 输入插件来跟踪 Docker 容器中运行的应用程序的 CPU、内存、磁盘 I/O 和网络活动。通过收集这些指标,DevOps 团队可以主动管理资源分配、排除性能瓶颈,并确保跨不同环境的最佳应用程序性能。
-
与 Kubernetes 集成:利用此插件收集由 Kubernetes 编排的 Docker 容器的指标。通过过滤掉不必要的 Kubernetes 标签并专注于关键指标,团队可以简化其监控解决方案并创建仪表板,从而提供对 Kubernetes 集群中运行的微服务的整体运行状况的洞察。
-
容量规划和资源优化:使用 Docker 输入插件收集的指标来执行 Docker 部署的容量规划。分析使用模式有助于识别未充分利用的资源和过度配置的容器,从而指导根据实际使用趋势进行向上或向下扩展的决策。
-
容器异常的自动警报:根据通过 Docker 插件收集的指标设置警报规则,以通知团队资源使用量异常飙升或服务中断。这种主动监控方法有助于维护服务可靠性并优化容器化应用程序的性能。
MongoDB
-
物联网设备的动态日志记录到 MongoDB:利用此插件实时收集和存储来自大量物联网设备的指标。通过将设备日志直接发送到 MongoDB,您可以创建一个集中式数据库,从而可以轻松访问和查询运行状况指标和性能数据,从而根据历史趋势实现主动维护和故障排除。
-
Web 流量的时序分析:使用 MongoDB Telegraf 插件来收集和分析一段时间内的 Web 流量指标。此应用程序可以帮助您了解高峰使用时间、用户交互和行为模式,从而指导营销策略和基础设施扩展决策,以改善用户体验。
-
自动化监控和警报系统:将 MongoDB 插件集成到跟踪应用程序性能指标的自动化监控系统中。借助时序集合,您可以根据特定阈值设置警报,从而使您的团队能够在潜在问题影响用户之前做出响应。这种主动管理可以提高服务可靠性和整体性能。
-
指标存储中的数据保留和 TTL 管理:利用 MongoDB 集合中文档的 TTL 功能来自动过期过时的指标。这对于仅最近的性能数据相关的环境尤其有用,可以防止您的 MongoDB 数据库被旧指标搞乱,并确保高效的数据管理。
反馈
感谢您成为我们社区的一份子!如果您有任何一般性反馈或在这些页面上发现任何错误,我们欢迎并鼓励您提出意见。请在 InfluxDB 社区 Slack 中提交您的反馈。