Skip to content

Commit 196316a

Browse files
fix: scrape unactive instances
Loki instances may be on worker nodes too.
1 parent b07b7ef commit 196316a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

imageroot/actions/create-module/80provision_metrics

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ import agent
1111

1212
module_id = os.environ['MODULE_ID']
1313
agent_id = os.environ['AGENT_ID']
14-
node_id = int(os.environ['NODE_ID'])
1514

1615
def main():
17-
global module_id, node_id
16+
global module_id
17+
node_id = int(os.environ['NODE_ID'])
18+
rdb_ro = agent.redis_connect()
19+
ip_address = rdb_ro.hget(f'node/{node_id}/vpn', 'ip_address') or '127.0.0.1'
1820
targets = [{
19-
"targets": [f"127.0.0.1:{os.environ['TCP_PORT']}"],
21+
"targets": [f"{ip_address}:{os.environ['TCP_PORT']}"],
2022
"labels": {
2123
"module_id": module_id,
2224
"node": node_id, # no "_id" suffix for Metrics

0 commit comments

Comments
 (0)