본문 바로가기

리눅스

[리눅스] influxdb, grafana, telegraf 연동

728x90

influxdb, grafana, telegraf 연동

influxdb 설치 : https://sangchul.kr/335

grafana 설치 : https://sangchul.kr/334

telegraf 설치 : https://sangchul.kr/333

https://www.influxdata.com/wp-content/uploads/Influx-1.0-Diagram_04.20.2020v2.png

influxdb와 telegraf 연동하기

influxdb에서 telegraf 설정 생성

http://{Server-IP}:8086

influxdb output plugin

export INFLUX_TOKEN=OwkgzsNcgkcrwQj4Rq-wtFBjM45W64e2R1kZsHHUQHZSMnwMGsVURSyN1LJG-3vpFZTAv30XJNNIAq4bYmP-TQ==
telegraf --config http://192.168.70.234:8086/api/v2/telegrafs/09a6d8d61508c000

create configuration

 [[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.70.234:8086"]

  ## API token for authentication.
  token = "$INFLUX_TOKEN"

  ## Organization is the name of the organization you wish to write to; must exist.
  organization = "scbyun.com"

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

telegraf 설정

telegraf.conf 편집

vim /etc/telegraf/telegraf.conf
$ vim /etc/telegraf/telegraf.conf

...

[[outputs.influxdb_v2]]
urls = ["http://127.0.0.1:8086"]
token = "$INFLUX_TOKEN"
organization = "scbyun.com"
bucket = "telegraf"
export INFLUX_TOKEN=OwkgzsNcgkcrwQj4Rq-wtFBjM45W64e2R1kZsHHUQHZSMnwMGsVURSyN1LJG-3vpFZTAv30XJNNIAq4bYmP-TQ==
systemctl restart telegraf

influxdb UI

Data Explorer

dashboard

influxdb와 grafana 연동하기

influxdb

influx setup --username tadmin --password 'admin12#$' --org scbyun.com --bucket telegraf --retention 1w --force
influx auth list

d

curl -s http://localhost:8086/health
$ curl -s http://localhost:8086/health | jq
{
  "name": "influxdb",
  "message": "ready for queries and writes",
  "status": "pass",
  "checks": [],
  "version": "v2.3.0+SNAPSHOT.090f681737",
  "commit": "090f681737"
}

그라파나(grafana) 설정

http://{Server-IP}:3000

 

 

 

 

 

728x90