【问题标题】:Posting metrics to prometheusPosting metrics to prometheus
【发布时间】:2022-12-27 13:17:38
【问题描述】:

I have installed prometheus on my Linux PC and I am trying to post some metrics value. I have the following job configured in my yml file:

scrape_configs:
  - job_name: test_job
    metrics_path: /metrics

    static_configs:
      - targets: ["localhost:9090"]

I would expect the following curl request:

echo "some_metric 3.14" | curl --data-binary @- http://127.0.0.1:9090/metrics/test_job

to post the metric value, but curl is returning HTTP 404 not found. I have checked port 9090 in the browser and it is used by prometheus, not by some other server software.

Any suggestions? Thanks.

【问题讨论】:

  • That is not how it works, you do not post metrics to a Prometheus server. Prometheus server scrapes targets (usually where an exporter is running and exposing metrics in data model format ) and read metric values from them. To do some quick testing you can try textfile-collector
  • If you really want to push metrics to Prometheus, although it is not the recommended implementation as mentioned above, you can check Prometheus Pushgateway prometheus.io/docs/practices/pushing

标签: prometheus


【解决方案1】:

Prometheus doesn't support metrics push in plaintext format. It supports only metrics push in binary format (aka Prometheus remote_write format) when it runs with --web.enable-remote-write-receiver command-line flag. See these docs for details.

Prometheus ecosystem provides a workaround, which allows pushing plaintext metrics into Prometheus - pushgateway. It has some limitations though. The main limitation is that it doesn't provide the ability to storeeverypushed metric into Prometheus.

P.S. If you want pushing every metric in Prometheus text exposition format into a Prometheus-like system, then take a look at VictoriaMetrics - the project I work on. It accepts Prometheus plaintext metrics via /api/v1/import/prometheus http endpoint - see these docs.

【讨论】:

    猜你喜欢
    • 2021-10-07
    • 1970-01-01
    • 1970-01-01
    • 2014-09-25
    • 2021-09-12
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 2023-04-03
    相关资源
    最近更新 更多