Skip to content

Commit

Permalink
Fix instance_ip_grouping_key not working on macOS
Browse files Browse the repository at this point in the history
Fixes prometheus#629

The solution is adapted from this StackOverflow answer: https://stackoverflow.com/a/28950776
  • Loading branch information
AceFire6 authored Aug 17, 2021
1 parent c49e55a commit e9cb31f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion prometheus_client/exposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ def _escape_grouping_key(k, v):
def instance_ip_grouping_key():
"""Grouping key with instance set to the IP Address of this host."""
with closing(socket.socket(socket.AF_INET, socket.SOCK_DGRAM)) as s:
s.connect(('localhost', 0))
s.connect(('10.255.255.255', 1))
return {'instance': s.getsockname()[0]}


Expand Down

0 comments on commit e9cb31f

Please sign in to comment.