아두이노 센서 데이터 대시보드 구현 (6/7) – Telegraf

Sep 12, 2024 | 0 comments

아두이노 온습도 센서에서 수집된 데이터로 대시보드를 구성하는 과정을 살펴보겠습니다
총 7개의 포스트로 이루어지며 아래 글목록을 보시면 확인이 가능합니다.

Config 파일 수정

MqttUI/telegraf 폴더에 생성된 telegraf.conf 파일을 복사해서 백업한 다음 편집기로 수정합니다.
(기본 샘플 파일을 보존하기 위해서 백업해 두었습니다. 생략하셔도 됩니다.)

Input 설정 수정 – mqtt

[[inputs.mqtt 문자열을 검색해서 mqtt plugin 설정으로 이동한 다음 다음과 같이 수정합니다.
서버 주소 및 구독할 Topic, Qos, 접속 타임 아웃 등 주석을 해제해서 설정합니다.
client_id 의 경우 Mqtt Client ID 이며 중복되지 않게 작성해야 합니다.
사용자 인증 정보({{중괄호}}) 도 수정합니다.
data_format 및 data_type 은 문자열로 통일하였습니다.

# Read metrics from MQTT topic(s)
[[inputs.mqtt_consumer]]
  ## Broker URLs for the MQTT server or cluster.  To connect to multiple
  ## clusters or standalone servers, use a separate plugin instance.
  ##   example: servers = ["tcp://localhost:1883"]
  ##            servers = ["ssl://localhost:1883"]
  ##            servers = ["ws://localhost:1883"]
servers = ["tcp://192.168.219.200:41883"]

  ## Topics that will be subscribed to.
topics = [
  "DRS/#"
]


  ## The message topic will be stored in a tag specified by this value.  If set
  ## to the empty string no topic tag will be created.
  # topic_tag = "topic"

  ## QoS policy for messages
  ##   0 = at most once
  ##   1 = at least once
  ##   2 = exactly once
  ##
  ## When using a QoS of 1 or 2, you should enable persistent_session to allow
  ## resuming unacknowledged messages.
qos = 0

  ## Connection timeout for initial connection in seconds
connection_timeout = "30s"


  ## Maximum messages to read from the broker that have not been written by an
  ## output.  For best throughput set based on the number of metrics within
  ## each message and the size of the output's metric_batch_size.
  ##
  ## For example, if each message from the queue contains 10 metrics and the
  ## output metric_batch_size is 1000, setting this to 100 will ensure that a
  ## full batch is collected and the write is triggered immediately without
  ## waiting until the next flush_interval.
  # max_undelivered_messages = 1000

  ## Persistent session disables clearing of the client session on connection.
  ## In order for this option to work you must also set client_id to identify
  ## the client.  To receive messages that arrived while the client is offline,
  ## also set the qos option to 1 or 2 and don't forget to also set the QoS when
  ## publishing.
  # persistent_session = false

  ## If unset, a random client ID will be generated.
client_id = "telegraf"

  ## Username and password to connect MQTT server.
username = "{{사용자계정}}"
password = "{{비밀번호}}"

  ## 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

  ## Data format to consume.
  ## Each data format has its own unique set of configuration options, read
  ## more about them here:
  ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
  #data_format = "influx"
data_format = "value"
data_type = "string"

  ## Enable extracting tag values from MQTT topics
  ## _ denotes an ignored entry in the topic path
  # [[inputs.mqtt_consumer.topic_parsing]]
  #   topic = ""
  #   measurement = ""
  #   tags = ""
  #   fields = ""
  ## Value supported is int, float, unit
  #   [[inputs.mqtt_consumer.topic.types]]
  #      key = type

Output 설정 수정 – Influxdb v2

[[outputs.influxdb_v2]] 문자열을 검색해서 Influxdb plugin 설정으로 이동한 다음 다음과 같이 수정합니다.
서버 주소, {{Token}}, Organization, Bucket, Timeout 을 수정했습니다.
Token 은 여기 에서 생성한 토큰 값으로 수정합니다.

# # Configuration for sending metrics to InfluxDB 2.0
[[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://192.168.219.200:48086"]
#
#   ## Local address to bind when connecting to the server
#   ## If empty or not set, the local address is automatically chosen.
# local_address = ""
#
#   ## Token for authentication.
token = "{{Token}}"
#
#   ## Organization is the name of the organization you wish to write to.
organization = "IOT"
#
#   ## Destination bucket to write into.
bucket = "AHT"
#
#   ## 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
#
#   ## When true, Telegraf will omit the timestamp on data to allow InfluxDB
#   ## to set the timestamp of the data during ingestion. This is generally NOT
#   ## what you want as it can lead to data points captured at different times
#   ## getting omitted due to similar data.
#   # influx_omit_timestamp = false
#
#   ## HTTP/2 Timeouts
#   ## The following values control the HTTP/2 client's timeouts. These settings
#   ## are generally not required unless a user is seeing issues with client
#   ## disconnects. If a user does see issues, then it is suggested to set these
#   ## values to "15s" for ping timeout and "30s" for read idle timeout and
#   ## retry.
#   ##
#   ## Note that the timer for read_idle_timeout begins at the end of the last
#   ## successful write and not at the beginning of the next write.
#   # ping_timeout = "0s"
#   # read_idle_timeout = "0s"
#
#   ## 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

컨테이너 재시작

설정 파일을 수정한 다음 해당 컨테이너만 재시작 하겠습니다.

kkomzi@KKOMZI_HPN54L:/volume1/docker/MqttUI$ docker-compose restart telegraf
Restarting telegraf ... done

Learn more on this topic

Related Blog Posts

WinSCP 접속 버퍼 길이 최적화

WinSCP 접속 버퍼 길이 최적화

WinSCP 에서 대용량 데이터를 복사하던 중에 발생한 상황에 대한 해결 과정입니다. (접속 버퍼 길이 최적화)

read more

Join in the conversation

Leave a Comment

0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

무료 온라인 전광판

전광판

텍스트를 입력하고 텍스트 효과 및 배경효과 를 변경해서 전체화면으로 표시할 수 있는 전광판 용도로 사용하실 수 있습니다. 각종 스포츠 및 공연 관람시 응원 용도로 사용이 가능합니다.

Carousel

여러개의 슬라이드를 추가하여 프레젠테이션 및 이미지 슬라이드 용도로 사용하실 수 있습니다. 브라우저가 포함된 IT 기기로 큰 모니터에 연결하여 매장 내 공지사항 및 메뉴소개를 이미지로 표시할 수 있습니다.

Pin It on Pinterest

Shares
Share This

Share This

Share this post with your friends!

Shares