Skip to content

Commit

Permalink
fix: prometheus empty spawning
Browse files Browse the repository at this point in the history
  • Loading branch information
shanithkk committed Dec 6, 2023
1 parent 088edf3 commit 6a432cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
12 changes: 8 additions & 4 deletions package_io/promethues.star
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def launch_prometheus(
args,
service_details,
)

if len(template_data["MetricsJobs"]) == 0:
return "No Prometheus is available"

template_and_data = shared_utils.new_template_and_data(
config_template,
template_data,
Expand Down Expand Up @@ -89,21 +93,21 @@ def new_config_template_data(plan, args, service_details):
scrape_interval = "5s",
),
)

for parachain in args["para"]:
for node in parachain["nodes"]:
if node["prometheus"] == True:
for para_chain in service_details["parachains"]:
for para_chain in service_details["parachains"]:
for para_chain_node in para_chain["nodes"]:
service_name = para_chain_node["node_details"].name
string = "{}-{}-{}".format(parachain["name"],node["name"],args["chain-type"])
string = "{}-{}-{}".format(parachain["name"], node["name"], args["chain-type"])
if string == service_name:
ip = para_chain_node["node_details"].ip_address
port_number = para_chain_node["node_details"].ports["metrics"].number
endpoint = "{0}:{1}".format(ip, port_number)
metrics_jobs.append(
new_metrics_job(
job_name = "parachain_{}_service_{}".format(parachain["name"],node["name"]),
job_name = "parachain_{}_service_{}".format(parachain["name"], node["name"]),
endpoint = endpoint,
scrape_interval = "5s",
),
Expand Down
14 changes: 5 additions & 9 deletions relaychain/relay-chain.star
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def start_relay_chain(plan, args):
"""
name = args["chain-type"]
chain = args["relaychain"]["name"]
final_details=[]
final_details = []

prometheus = 9615
for relay_node in args["relaychain"]["nodes"]:
port = relay_node["port"]
Expand Down Expand Up @@ -40,7 +40,6 @@ def start_relay_chain(plan, args):

return final_details


def start_test_main_net_relay_nodes(plan, args):
"""
Starts testnet/mainnet relay nodes based on the provided arguments.
Expand All @@ -66,7 +65,6 @@ def start_test_main_net_relay_nodes(plan, args):

return relay_node_details


def spawn_multiple_relay(plan, count):
"""
Spawns multiple local relay chain nodes.
Expand All @@ -81,7 +79,6 @@ def spawn_multiple_relay(plan, count):
port = port + count
start_relay_chain_local(plan, node_list[i], port)


def start_relay_chains_local(plan, args):
"""
Starts local relay chain nodes based on the provided arguments.
Expand All @@ -102,15 +99,14 @@ def start_relay_chains_local(plan, args):
prometheus_port = 9615
for node in relay_nodes:
relay_detail = {}
service_details = start_relay_chain_local(plan, node["name"], node["port"], prometheus_port)
service_details = start_relay_chain_local(plan, args, node["name"], node["port"], prometheus_port)
relay_detail["service_details"] = service_details
relay_detail["service_name"] = service_details.name
final_details.append(relay_detail)
prometheus_port = prometheus_port + 1
return final_details


def start_relay_chain_local(plan, name, port, prometheus_port):
def start_relay_chain_local(plan, args, name, port, prometheus_port):
"""
Starts a local relay chain node based on the provided arguments.
Expand All @@ -125,7 +121,7 @@ def start_relay_chain_local(plan, name, port, prometheus_port):
"""
exec_command = ["bin/sh", "-c", "polkadot --base-path=/data --chain=/app/raw-polkadot.json --validator --rpc-external --rpc-cors=all --name=alice --{0} --rpc-methods=unsafe --execution=wasm --prometheus-external".format(name)]
service_details = plan.add_service(
name = "polkadot-{0}".format(name),
name = "{0}-{1}".format(args["relaychain"]["name"], name),
config = ServiceConfig(
image = "parity/polkadot:latest",
files = {
Expand Down

0 comments on commit 6a432cb

Please sign in to comment.