1

我正在尝试使用 docker compose 在 macOS 11.3.1 上设置 Telegraf 和 Influxdb。但不幸的是,我收到以下错误:

telegraf     | 2021-07-12T19:18:14Z E! [outputs.influxdb_v2] When writing to [http://localhost:8086]: Post "http://localhost:8086/api/v2/write?bucket=telegraf&org=telegraf": dial tcp 127.0.0.1:8086: connect: connection refused
telegraf     | 2021-07-12T19:18:14Z E! [agent] Error writing to outputs.influxdb_v2: Post "http://localhost:8086/api/v2/write?bucket=telegraf&org=telegraf": dial tcp 127.0.0.1:8086: connect: connection refused

这是我的配置文件:

码头工人-compose.yml

version: "3.5"

services:
  influxdb2:
    image: influxdb:latest
    network_mode: "bridge"
    container_name: influxdb2
    ports:
      - "8086:8086"
    volumes:
      - type: bind
        source: /Users/endryha/Docker/influxdb2/data
        target: /var/lib/influxdb2
      - type: bind
        source: /Users/endryha/Docker/influxdb2/config
        target: /etc/influxdb2
    environment:
      - DOCKER_INFLUXDB_INIT_MODE=setup
      - DOCKER_INFLUXDB_INIT_USERNAME=telegraf
      - DOCKER_INFLUXDB_INIT_PASSWORD=P@ssw0rd
      - DOCKER_INFLUXDB_INIT_ORG=telegraf
      - DOCKER_INFLUXDB_INIT_BUCKET=telegraf
      - DOCKER_INFLUXDB_INIT_RETENTION=1w
      - DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=9859DAA6-3B3F-48FE-A981-AE9D31FBB334
    restart: always
  telegraf:
    image: telegraf:latest
    network_mode: "bridge"
    pid: "host"
    container_name: telegraf
    ports:
      - "8092:8092"
      - "8094:8094"
      - "8125:8125"
    volumes:
      - ./telegraf.conf:/etc/telegraf/telegraf.conf:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /sys:/host/sys:ro
      - /proc:/host/proc:ro
      - /etc:/host/etc:ro
    environment:
      - HOST_PROC=/host/proc
      - HOST_SYS=/host/sys
      - HOST_ETC=/host/etc
    restart: always

电报文件

# # Configuration for sending metrics to InfluxDB
 [[outputs.influxdb_v2]]
#   ## The URLs of the InfluxDB cluster nodes.
#   ##
#   ## Multiple URLs can be specified for a single cluster, only ONE of the
#   ## urls will be written to each interval.
#   ##   ex: urls = ["https://us-west-2-1.aws.cloud2.influxdata.com"]
  urls = ["http://localhost:8086"]
#
#   ## Token for authentication.
  token = "9859DAA6-3B3F-48FE-A981-AE9D31FBB334"
  # token = "sYbrP0VZ--MgCd0EpOpz9OctJN2e4kUbsfbPPUGcY9GYW8Ts27W2cI_d7YwlSf9nvHq4l-K6mJLqJiTT0Hh7Xw=="
#
#   ## Organization is the name of the organization you wish to write to; must exist.
  organization = "telegraf"
#
#   ## Destination bucket to write into.
  bucket = "telegraf"
#
#   ## The value of this tag will be used to determine the bucket.  If this
#   ## tag is not set the 'bucket' option is used as the default.
#   # bucket_tag = ""
#
#   ## If true, the bucket tag will not be added to the metric.
#   # exclude_bucket_tag = false
#
#   ## Timeout for HTTP messages.
#   # timeout = "5s"
#
#   ## Additional HTTP headers
#   # http_headers = {"X-Special-Header" = "Special-Value"}
#
#   ## HTTP Proxy override, if unset values the standard proxy environment
#   ## variables are consulted to determine which proxy, if any, should be used.
#   # http_proxy = "http://corporate.proxy:3128"
#
#   ## HTTP User-Agent
  user_agent = "telegraf"
#
#   ## Content-Encoding for write request body, can be set to "gzip" to
#   ## compress body or "identity" to apply no encoding.
#   # content_encoding = "gzip"
#
#   ## Enable or disable uint support for writing uints influxdb 2.0.
#   # influx_uint_support = false
#
#   ## Optional TLS Config for use on HTTP connections.
#   # 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

完整的日志输出

docker-compose up
Starting telegraf  ... done
Starting influxdb2 ... done
Attaching to influxdb2, telegraf
telegraf     | 2021-07-12T19:18:04Z I! Starting Telegraf 1.19.1
telegraf     | 2021-07-12T19:18:04Z I! Using config file: /etc/telegraf/telegraf.conf
telegraf     | 2021-07-12T19:18:04Z I! Loaded inputs: cpu disk diskio docker kernel mem processes swap system
telegraf     | 2021-07-12T19:18:04Z I! Loaded aggregators:
telegraf     | 2021-07-12T19:18:04Z I! Loaded processors:
telegraf     | 2021-07-12T19:18:04Z I! Loaded outputs: influxdb_v2
telegraf     | 2021-07-12T19:18:04Z I! Tags enabled: host=d52a95d7ec9d
telegraf     | 2021-07-12T19:18:04Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"d52a95d7ec9d", Flush Interval:10s
telegraf     | 2021-07-12T19:18:04Z W! [inputs.docker] 'perdevice' setting is set to 'true' so 'blkio' and 'network' metrics will be collected. Please set it to 'false' and use 'perdevice_include' instead to control this behaviour as 'perdevice' will be deprecated
telegraf     | 2021-07-12T19:18:04Z W! [inputs.docker] 'total' setting is set to 'false' so 'blkio' and 'network' metrics will not be collected. Please set it to 'true' and use 'total_include' instead to control this behaviour as 'total' will be deprecated
influxdb2    | 2021-07-12T19:18:04.687801589Z   info    found existing boltdb file, skipping setup wrapper  {"system": "docker", "bolt_path": "/var/lib/influxdb2/influxd.bolt"}
influxdb2    | ts=2021-07-12T19:18:11.025589Z lvl=info msg="Welcome to InfluxDB" log_id=0VJ2KiKG000 version=2.0.7 commit=2a45f0c037 build_date=2021-06-04T19:17:40Z
influxdb2    | ts=2021-07-12T19:18:11.029935Z lvl=info msg="Resources opened" log_id=0VJ2KiKG000 service=bolt path=/var/lib/influxdb2/influxd.bolt
influxdb2    | ts=2021-07-12T19:18:11.036551Z lvl=info msg="Checking InfluxDB metadata for prior version." log_id=0VJ2KiKG000 bolt_path=/var/lib/influxdb2/influxd.bolt
influxdb2    | ts=2021-07-12T19:18:11.037662Z lvl=info msg="Using data dir" log_id=0VJ2KiKG000 service=storage-engine service=store path=/var/lib/influxdb2/engine/data
influxdb2    | ts=2021-07-12T19:18:11.037699Z lvl=info msg="Compaction settings" log_id=0VJ2KiKG000 service=storage-engine service=store max_concurrent_compactions=4 throughput_bytes_per_second=50331648 throughput_bytes_per_second_burst=50331648
influxdb2    | ts=2021-07-12T19:18:11.037705Z lvl=info msg="Open store (start)" log_id=0VJ2KiKG000 service=storage-engine service=store op_name=tsdb_open op_event=start
influxdb2    | ts=2021-07-12T19:18:11.037820Z lvl=info msg="Open store (end)" log_id=0VJ2KiKG000 service=storage-engine service=store op_name=tsdb_open op_event=end op_elapsed=0.116ms
influxdb2    | ts=2021-07-12T19:18:11.037863Z lvl=info msg="Starting retention policy enforcement service" log_id=0VJ2KiKG000 service=retention check_interval=30m
influxdb2    | ts=2021-07-12T19:18:11.037873Z lvl=info msg="Starting precreation service" log_id=0VJ2KiKG000 service=shard-precreation check_interval=10m advance_period=30m
influxdb2    | ts=2021-07-12T19:18:11.037900Z lvl=info msg="Starting query controller" log_id=0VJ2KiKG000 service=storage-reads concurrency_quota=1024 initial_memory_bytes_quota_per_query=9223372036854775807 memory_bytes_quota_per_query=9223372036854775807 max_memory_bytes=0 queue_size=1024
influxdb2    | ts=2021-07-12T19:18:11.038758Z lvl=info msg="Configuring InfluxQL statement executor (zeros indicate unlimited)." log_id=0VJ2KiKG000 max_select_point=0 max_select_series=0 max_select_buckets=0
influxdb2    | ts=2021-07-12T19:18:11.331457Z lvl=info msg=Listening log_id=0VJ2KiKG000 service=tcp-listener transport=http addr=:8086 port=8086
influxdb2    | ts=2021-07-12T19:18:11.331525Z lvl=info msg=Starting log_id=0VJ2KiKG000 service=telemetry interval=8h
telegraf     | 2021-07-12T19:18:14Z E! [outputs.influxdb_v2] When writing to [http://localhost:8086]: Post "http://localhost:8086/api/v2/write?bucket=telegraf&org=telegraf": dial tcp 127.0.0.1:8086: connect: connection refused
telegraf     | 2021-07-12T19:18:14Z E! [agent] Error writing to outputs.influxdb_v2: Post "http://localhost:8086/api/v2/write?bucket=telegraf&org=telegraf": dial tcp 127.0.0.1:8086: connect: connection refused
telegraf     | 2021-07-12T19:18:24Z E! [outputs.influxdb_v2] When writing to [http://localhost:8086]: Post "http://localhost:8086/api/v2/write?bucket=telegraf&org=telegraf": dial tcp 127.0.0.1:8086: connect: connection refused
telegraf     | 2021-07-12T19:18:24Z E! [agent] Error writing to outputs.influxdb_v2: Post "http://localhost:8086/api/v2/write?bucket=telegraf&org=telegraf": dial tcp 127.0.0.1:8086: connect: connection refused
telegraf     | 2021-07-12T19:18:34Z E! [outputs.influxdb_v2] When writing to [http://localhost:8086]: Post "http://localhost:8086/api/v2/write?bucket=telegraf&org=telegraf": dial tcp 127.0.0.1:8086: connect: connection refused

正如我所看到的,授权存在问题,但是,我认为我正确地提供了令牌并且它应该可以正常工作。此外,我尝试使用 InfluxDB 管理 UI 手动创建令牌,但是效果不佳。

请指教。

4

0 回答 0