How to setup prometheus metrics?

Hello,

could anyone please explain how to setup the prometheus metric system? So far I’ve added

  [metrics.prometheus]
  # Enable Prometheus metrics endpoint.
  endpoint_enabled=true

  # The ip:port to bind the Prometheus metrics server to for serving the
  # metrics endpoint.

  bind="172.0.0.1:8070"

to the lora-app-server.toml and

   scrape_configs:
   - job_name:       'loraserver'

    # Override the global default and scrape targets from this job every 5 seconds.
    scrape_interval: 5s

static_configs:
  - targets: ['127.0.0.1:8070']

for Prometheus. Unfortunately no metrics are collected and the target is flagged “down” in Prometheus.

You might want to use 127 instead of 172 :wink: Also, if both instances are running on the same server then you need to use different ports.

After fixing your config, you can test the endpoint with:

curl http://localhost:8070

Where 8070 is the port you have configured for the metrics.

Thank god that was just a stupid typo and not the problem :crazy_face:

Also, if both instances are running on the same server then you need to use different ports.

Prometheus and lora-app-server? Isn’t that an open port / connect to port relation? :thinking: I’m confused now, but I think that is due to the temperature. Do we have a sweating smiley btw?

On topic again: During writing the response and trying a few things I think I just found the problem and it is nearly as simple as the typo. I have two app-server instances which are both 3.x.0, but the one I choose for testing is only 3.1.0…

With this I mean when you both try to export the loraserver and lora-app-server metrics, then they can’t bind to the same port. E.g. use 8070 and 8071 and then configure Prometheus to scrape from both ports :slight_smile: