Telegraf CSV 文件,在 prometheus 中仅返回一行,不返回基于时间戳的

问题描述 投票:0回答:1

我正在尝试按时间序列转换 csv 数据,但是只有 Prometheus 中填充的最后数据(telegraf 和 prometheus 在同一服务器中运行)。有人可以帮助我,我缺少什么。 我的电报配置:

[agent]
  interval = "10s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  debug = false
  quiet = false
# # Read metrics from one or more CSV files
[[inputs.file]]
  ## Files to parse each interval.
  files = ["/usr/temperature.csv"]
  ## File will be read in every interval.
  data_format = "csv"
  csv_header_row_count=1
  ## Specify a time format to use for parsing time from CSV
  csv_timestamp_column = "timestamp"
  csv_timestamp_format = "2006-01-02T15:04:05Z07:00"

# # Configuration for Prometheus client to expose metrics for scraping

[[outputs.prometheus_client]]
  listen = ":9273"

温度.csv - 时间戳、温度、房间、设备 2024-06-27T12:00:00Z,22.5,房间 1,设备 1 2024-05-28T12:05:00Z,22.7,房间1,设备1 2024-04-22T12:10:00Z,22.8,房间1,设备1 2024-03-21T12:15:00Z,22.6,房间1,设备1 2024-02-20T12:20:00Z,22.5,房间1,设备1 2024-01-23T12:00:00Z,23.0,房间2,设备2 2024-06-29T12:05:00Z,23.1,房间2,设备2

下面的详细信息,我添加了 prometheus.yml 文件 -

scrape_configs:
  - job_name: 'telegraf'
    static_configs:
      - targets: ['localhost:9273']`your text`

期望时间序列放入普罗米修斯

prometheus grafana telegraf
1个回答
0
投票

在您的 csv 文件中,我只看到两个唯一的标签值对 -

temparature{room="room1",device='device1'} 22.5
temparature{room="room2",device='device2'} 23.1

您只会得到这两个条目,因为 Prometheus 客户端选择有效唯一标签值对的最新值。这是预料之中的。如果你不断地以固定的抓取间隔替换文件内容,那么只有它才会成为时间序列数据,并且你将如期在 Prometheus 中看到它。

© www.soinside.com 2019 - 2024. All rights reserved.