telegrafの使い方応用編 複数のinputを別々のinfluxdb bucketに振り分ける

こちらの記事から発展です。

  • keilogから取り込む消費電力データのほかに、CPUやメモリなどのパフォーマンスデータも取っておきたい。
  • 消費電力データは13か月分保持したい。
  • パフォーマンスデータは1週間分でいい。

という場合、データの保持期間はバケット単位で設定するものなので、消費電力データとパフォーマンスデータを別のバケットに保存するしかありません。
こういう場合のtelegrafの設定方法です。

概要

出力プラグイン outputs.influxdb_v2 のオプションに「bucket_tag」というものがあります。
これは出力先バケットを指定するためのタグの指定です。

例えば、bucket_tag = “dest_bucket” と指定しておき
inputプラグイン側で dest_bucket = “hogehoge” というタグを付けると
そのinputはhogehogeバケットに出力されます。

設定ファイル

実際の設定ファイルの例です。

inputs.file からの入力はbucket1バケットに
その他 inputs.cpu などからの入力はperf_bucketバケットに
それぞれ出力される設定です。

なお、bucket_tagで指定したタグが付いてない場合は、bucket オプションで指定したバケットに出力されます。
この例では bucket = “bucket1” としていますので、inputs.file のdest_bucketタグは有っても無くても結果は同じ、という事になります。

# Configuration for sending metrics to InfluxDB 2.0
[[outputs.influxdb_v2]]
(中略)
## Destination bucket to write into.
bucket = "bucket1"
## 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 = "dest_bucket"
(中略)
# Parse a complete file each interval
[[inputs.file]]
(中略)
[inputs.file.tags]
dest_bucket = "bucket1"
# Read metrics about cpu usage
[[inputs.cpu]]
## Whether to report per-cpu stats or not
percpu = true
## Whether to report total system cpu stats or not
totalcpu = true
## If true, collect raw CPU time metrics
collect_cpu_time = false
## If true, compute and report the sum of all non-idle CPU states
## NOTE: The resulting 'time_active' field INCLUDES 'iowait'!
report_active = false
## If true and the info is available then add core_id and physical_id tags
core_tags = false
[inputs.cpu.tags]
dest_bucket = "perf_bucket"
# Read metrics about disk usage by mount point
[[inputs.disk]]
## By default stats will be gathered for all mount points.
## Set mount_points will restrict the stats to only the specified mount points.
# mount_points = ["/"]
## Ignore mount points by filesystem type.
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
## Ignore mount points by mount options.
## The 'mount' command reports options of all mounts in parathesis.
## Bind mounts can be ignored with the special 'bind' option.
# ignore_mount_opts = []
[inputs.disk.tags]
dest_bucket = "perf_bucket"
# Read metrics about memory usage
[[inputs.mem]]
# no configuration
[inputs.mem.tags]
dest_bucket = "perf_bucket"

コメント

タイトルとURLをコピーしました