【问题标题】:How to push prometheus metrics directly to VictoriaMetrics?如何将 prometheus 指标直接推送到 VictoriaMetrics?
【发布时间】:2021-04-21 08:50:43
【问题描述】:

我正在使用 python prometheus 客户端,在将指标推送到 VictoriaMetrics (VM) 时遇到问题。

有一个名为push_to_gateway的函数,我尝试用VM替换prometheus URL:http://prometheus:9091 -> http://vm:8428/api/v1/write。但是 VM 以 400 状态码响应。

【问题讨论】:

标签: python prometheus victoriametrics


【解决方案1】:

另外,请看一下我最近创建的客户端:https://github.com/gistart/prometheus-push-client

支持使用 InfluxDB 线路协议通过 UDP 和 HTTP 直接推送到 VictoriaMetrics

通过 UDP 以 StatsD 格式发送到 StatsD 或 statsd-exporter

通过 HTTP 以 OpenMetrics 格式推送网关或 prom-aggregation-gateway

【讨论】:

    【解决方案2】:

    我在 /api/v1/import/csv 使用 CSV 导入,如下所述:https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/README.md#how-to-import-csv-data

    直接从 pandas 数据框生成 CSV。比如:

        df.rename(columns={'timestamp': 'ts_ns'}, inplace=True)
        data = df.to_csv(index=False, header=False)
    
        csv_format = f'1:time:unix_ns{metric_format}{label_format}'
    
        response = requests.post(url, params={'format': csv_format}, data=data)
    

    【讨论】:

      【解决方案3】:

      可以将push_to_gateway 方法与 VictoriaMetrics 一起使用,请查看 gist https://gist.github.com/f41gh7/85b2eb895bb63b93ce46ef73448c62d0 中的示例

      【讨论】:

        猜你喜欢
        • 2021-02-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-12-17
        • 1970-01-01
        相关资源
        最近更新 更多