telegraf input的配置

 

复制代码

1.操作系统基础监控指标配置标准
基础监控使用通用的全局配置文件telegraf.conf,以下只贴上采集器input部分代码

telegraf -config /etc/telegraf/telegraf.d/telegraf.conf -input-filter http_response -test


# Read metrics about cpu usage
[[inputs.cpu]]
  interval = “60s”
  percpu = true
  totalcpu = true
  fielddrop = [“time*”]
# Read metrics about disk usage by mount point
[[inputs.disk]]
  interval = “10m”
  # mount_points = [“/”]
  ignore_fs = [“tmpfs”, “devtmpfs”]
# Read metrics about disk IO by device
[[inputs.diskio]]
  interval = “60s”
# Get kernel statistics from /proc/stat
[[inputs.kernel]]
  interval = “10m”
# Read metrics about memory usage
[[inputs.mem]]
  interval = “10m”
# Get the number of processes and group them by status
[[inputs.processes]]
  interval = “10m”
  fielddrop = [“wait”,”idle”,”unknown”]
# Read metrics about swap memory usage
[[inputs.swap]]
  interval = “1h”
  fieldpass = [“used_percent”]
# Read metrics about system load & uptime
[[inputs.system]]
  interval = “2m”
# # Read metrics about network interface usage
 [[inputs.net]]
  interval = “60s”
  fieldpass = [“packets_*”,”bytes_*”,”drop_*”,”err_*”]
# # Read TCP metrics such as established, time wait and sockets counts.
 [[inputs.netstat]]
 interval = “5m”
 fielddrop = [“tcp_none”,”tcp_closing”,”tcp_close*”]
# # Read ping metrics
[[inputs.ping]]
 urls = [“www.qq.com”]
 count = 1
 ping_interval = 0.0
 timeout = 0.0
 interface = “eth0”

2.docker容器监控配置标准
对于基础监控之外的指标监控,需要使用新的配置文件,指定采集器的采集标准和配置,以及输出数据库(可选非必要),下同。
[[inputs.docker]]
   interval = “5m”
   endpoint = “unix:///var/run/docker.sock”
   container_names = []
   timeout = “10s”
   perdevice = true
   total = false
3.mysql监控配置标准
# Read metrics from one or many mysql servers
[root@10-19-6-138 telegraf.d]# cat telegraf_mysql.conf 
[[inputs.mysql]]
  interval = "5m" 采集频率
  servers = ["root:kgzg789@tcp(127.0.0.1:3306)/?tls=false"] 采集配置
  perf_events_statements_digest_text_limit  = 120
  perf_events_statements_limit              = 250
  perf_events_statements_time_limit         = 86400
  table_schema_databases                    = [""]
  gather_table_schema                       = false
  
  gather_process_list                       = true
  
  gather_info_schema_auto_inc               = true
  
  gather_slave_status                       = true
  gather_binary_logs                        = false
  gather_table_io_waits                     = false
  gather_table_lock_waits                   = false
  gather_index_io_waits                     = false
  gather_event_waits                        = false
  gather_file_events_stats                  = false
  interval_slow                             = "30m"


4.haproxy配置标准
#vim /etc/telegraf/telegraf.d/mysql.conf

[inputs.haproxy]
        interval = “60s”                   #input采集频率
        servers = [“/var/run/haproxy.sock”]             #input参数配置

5.nginx配置标准
[[inputs.nginx]]
  interval = “60s”
  urls = [“http://localhost/server_status”]   

6.kafka配置标准
[[inputs.kafka_consumer]]
  topics = [“telegraf”]
  zookeeper_peers = [“localhost:2181”]
  consumer_group = “telegraf_metrics_consumers”
  metric_buffer = 100000
  offset = “oldest”
  data_format = “influx”


7.zookeeper配置标准
[[inputs.zookeeper]]
   servers = [“:2181”]

8.ovirt配置标准
9.redis配置标准
# # Read metrics from one or many redis servers
 [[inputs.redis]]
   interval = “5m”
   unix:///var/run/redis.sock
   servers = [“tcp://localhost:6379”]

10.http网站监控
[[inputs.http_response]]

      interval = “1m”
      address = “http://abc.com”
      response_timeout = “15s”
      method = “GET”
      follow_redirects = true
11.Ceph监控
[[inputs.ceph]]
  interval = ‘1m’
  ceph_binary = “/usr/bin/ceph”
  socket_dir = “/var/run/ceph”
  mon_prefix = “ceph-mon”
  osd_prefix = “ceph-osd”
  socket_suffix = “asok”
  ceph_user = “client.admin”
  ceph_config = “/etc/ceph/ceph.conf”
  gather_admin_socket_stats = true
  gather_cluster_stats = false
12.ping监控
单独使用场景:主要作为WAN链路监控,URL监控的监测手段
[[inputs.ping]]
     urls = [“www.qq.com”]
     count = 1
     ping_interval = 0.0
     timeout = 0.0
     interface = “eth0”

13.tcp端口监控
使用场景:主要作为本机端口应用监控
# # Generic TCP listener
[[inputs.tcp_listener]]
     service_address = “:8094”
     allowed_pending_messages = 10000
     max_tcp_connections = 250
     data_format = “influx”
14.端口流量监控
使用场景:主要作为入口或者外出服务器或者防火墙的端口流量监控
15.IPMI监控
使用场景:主要作为物理机器基础电力设施的指标监控
# #IPMI1# # 
[[inputs.ipmi_sensor]]
  servers = [“root:password@lanplus(10.8.81.15)”]

16.http-json格式监控
使用场景:在特殊应用无任何匹配模板时,可使用json格式化数据后进行指标收集;
# [[inputs.httpjson]]
   name = “webserver_stats”
   servers = [
     “http://localhost:9999/stats/”,
     “http://localhost:9998/stats/”,
                   ]
   method = “GET”
   tag_keys = [
  “my_tag_1”,
   “my_tag_2”
                 ]



17.自定义sh脚本监控
使用场景:在以上都没有可用的监控采集配置外,可以使用自定义脚本格式收集指标;
[[inputs.exec]]
    commands = [“/tmp/test.sh”,]
    timeout = “15s”
    data_format = “json”
    name_suffix = “_mycollector”
18.SQLserver监控
使用场景:用于监控SQLserver数据库性能
[[inputs.sqlserver]]
   servers = [
    “Server=192.168.1.30;Port=1433;User Id=telegraf;Password=T$l$gr@f69*;app name=dbname;log=1;”
    ]

复制代码

原文:http://www.lvkaineng.com/235.html

分类: 监控

好文要顶 关注我 收藏该文  

BigBao的博客
关注 - 4
粉丝 - 30

+加关注

0

0

« 上一篇:grafana 邮件报警
» 下一篇:Zookeeper服务器配置项详解

### Telegraf 使用指南与配置示例 #### 1. 验证 Telegraf 是否正常运行 可以通过两种方式验证 Telegraf 的状态:一是查看 Telegraf 的日志文件;二是检查 InfluxDB 数据库中的数据更新情况。以下是用于实时监控 Telegraf 日志的命令: ```bash tail -f /var/log/telegraf/telegraf.log ``` 此操作可以帮助用户快速定位潜在问题并确认插件是否按预期收集数据[^1]。 --- #### 2. 安装后的基本配置路径 在 Windows 平台上,解压完成后,默认情况下 Telegraf 的主要配置文件会存储于以下目录: ``` C:\Program Files\telegraf\telegraf.conf ``` 该文件包含了所有的输入、处理器和输出插件配置选项。如果需要修改默认行为,则可以直接编辑 `telegraf.conf` 文件以适配具体需求[^2]。 --- #### 3. Telegraf 配置结构概述 Telegraf 的核心功能依赖三个部分实现——输入(input)、处理(processor) 和 输出(output),这些组件均定义在一个统一的 `.conf` 文件中。下面是一个简单的例子展示如何配置 CPU 输入插件并将采集到的信息发送至 InfluxDB: ```toml # Global tags can be specified here in key="value" format. [agent] interval = "10s" round_interval = true metric_batch_size = 1000 metric_buffer_limit = 10000 collection_jitter = "0s" flush_interval = "10s" flush_jitter = "0s" [[inputs.cpu]] percpu = true totalcpu = true collect_cpu_time = false report_active = false [[outputs.influxdb_v2]] urls = ["http://localhost:8086"] token = "your-auth-token-here" organization = "example-org" bucket = "example-bucket" ``` 在此配置下,每 10 秒钟读取一次系统的 CPU 负载,并将其写入本地运行的 InfluxDB 实例中[^1]。 --- #### 4. 自定义 reporter 设置(适用于 Telemetry Metrics) 虽然这并非严格意义上的 Telegraf 功能扩展,但如果目标是集成其他框架(如 Elixir/Erlang 应用程序),可以考虑利用 **Telemetry Metrics** 提供的支持。例如,在 Phoenix 框架的应用场景里,可通过如下形式调整指标上报机制[^3]: ```elixir config :telemetry_metrics, reporters: [ {TelemetryMetricsPrometheus, metric_prefix: "phoenix_app"}, {TelemetryMetricsStatsD, host: "statsd-host", port: 8125} ] ``` 这种灵活性允许开发者轻松切换不同的后端服务作为接收方。 --- #### 5. Kubernetes 环境下的部署方案 对于容器化环境而言,推荐借助官方维护的 Helm Chart 来简化安装流程。更多细节可参阅仓库文档链接[^4]: ``` https://gitcode.com/gh_mirrors/helmcharts4/helm-charts ``` 通过执行以下指令即可一键完成初始化过程: ```bash helm repo add influxdata https://influxdata.github.io/helm-charts/ helm install telegraf influxdata/influxdb --set telegraf.enabled=true ``` --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值