anubis
anubis

Reputation: 1505

How can I get the number of requests to rest server with prometheus?

I have a get request like this:

http://localhost:4567/hello

Which return in postman : "hello"

I want now to receive this in prometheus:

  - job_name: 'prometheus'

    scrape_interval: 5s
    metrics_path: /hello
    static_configs:
      - targets: ['localhost:4567']

But I receive in the prometheus console:

level=warn ts=2019-08-06T08:25:36.643Z caller=scrape.go:937 component="scrape manager" scrape_pool=prometheus target=http://localhost:4567/hello msg="append failed" err="\"INVALID\" is not a valid start token"

If I test in prometheus a graph with:

prometheus_http_requests_total

I receive no datas.

Anybody knows what I'm missing?

Thanks

Upvotes: 0

Views: 3906

Answers (1)

Kamol Hasan
Kamol Hasan

Reputation: 13456

I guess you're scraping metrics from wrong path. You said that GET request on http://localhost:4567/hello return you hello instead of the metrics information.

The expected metrics information format is the following:

$ curl http://localhost:8080/metrics
# HELP http_requests_total Count of all http requests
# TYPE http_requests_total counter
http_requests_total{code="0",method="GET"} 1
http_requests_total{code="0",method="Post"} 1
# HELP version Version information about this binary
# TYPE version gauge
version{version="v0.0.1"} 0

Make sure which endpoint exposing your metrics information. Then update the scrape_config.

Upvotes: 1

Related Questions