Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect IP registered in Consul for Prometheus Output #105

Closed
jasonyates-thg opened this issue Apr 17, 2023 · 5 comments
Closed

Incorrect IP registered in Consul for Prometheus Output #105

jasonyates-thg opened this issue Apr 17, 2023 · 5 comments

Comments

@jasonyates-thg
Copy link

I'm running consul and gnmic in docker, across 2 VM's. gnmic is configured to use consul for clustering and register it's prometheus output too, the clustering component works great however as i'm running in docker my listen statement is :7890 and :9804 for the api and prometheus output endpoints, I have to define the service-address in the clustering configuration to have the right IP registered in consul. However there's no such config option in the prometheus output section gnmic appears to use the IP of the consul server when registering the prometheus output.

How can I define the service-address for the prometheus output in the same way I can for the clustering?

# clustering config
clustering:
  cluster-name: cluster
  instance-name: gnmic01
  service-address: "10.249.1.215"
  targets-watch-timer: 30s
  leader-wait-timer: 60s
  locker:
    type: consul
    address: 10.249.0.250:8500

# Configure outputs
outputs:
  prometheus:
    type: prometheus
    listen: :9804 
    path: /metrics 
    event-processors: 
      - interface-descriptions
    service-registration:
      address: 10.249.0.250:8500
@karimra
Copy link
Collaborator

karimra commented Apr 17, 2023

The Prometheus output uses the address part of the listen field to register as a service address in Consul.
If that field is empty, Consul defaults to its own address as a service address.

If you want to register 10.249.1.215 as a service address for the prometheus output you should set listen to listen: 10.249.1.215:9804.
The caveat here is that your prometheus output listens only to that address, not to any address in the system.

@jasonyates-thg
Copy link
Author

jasonyates-thg commented Apr 17, 2023

The Prometheus output uses the address part of the listen field to register as a service address in Consul. If that field is empty, Consul defaults to its own address as a service address.

If you want to register 10.249.1.215 as a service address for the prometheus output you should set listen to listen: 10.249.1.215:9804. The caveat here is that your prometheus output listens only to that address, not to any address in the system.

The issue is have is that i'm running gnmic in a docker container via docker-compose with the prometheus endpoint port exposed, so it can't bind to 10.249.1.215:9804

I believe another possible solution to this would be to support the service-address configuration option in the service-registration section of the output in the same fashion that it can be configured in the clustering configuration.

@karimra
Copy link
Collaborator

karimra commented Apr 17, 2023

I see, let me look into it

@karimra
Copy link
Collaborator

karimra commented Apr 18, 2023

@jasonyates-thg can you give v0.30.0 a try?

You can set a service address as below:

outputs:
  prometheus:
    type: prometheus
    listen: :9804 
    path: /metrics 
    event-processors: 
      - interface-descriptions
    service-registration:
      address: 10.249.0.250:8500
      service-address: 10.249.1.215

It will register Address=10.249.1.215 and Port=9804.
You can also set a port with the address service-address: 10.249.1.215:9999 if the external port is different from the internal one.

@jasonyates-thg
Copy link
Author

This works perfectly. Thanks for the quick turnaround @karimra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants