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

feat: add ports to metrics #183

Merged
merged 4 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ def run(plan, chain_type = "local", relaychain = None, parachains = None, explor

Args:
chain_type (string): The type of chain (local, testnet or mainnet). Default is local.
relaychain (dict): A dict containing data for relay chain config.
relaychain (json, optional): A json object containing data for relay chain config.
- name (string): Name of relay chain.
- node (dict): A dict of node details.
- nodes (json): A json object containing node details.
- name (string): Name of node.
- node_type (string): Type of node.
- prometheus (bool): Boolean value to enable metrics for a given node.
parachains (list): A list containing data for para chain config. Each item in the list has the following:
parachains (json, optional): A json object containing data for para chain config. Each item in the list has the following:
- name (string): Name of para chain.
- node (dict): A dict of node details.
- nodes (json): A json object containing node details.
- name (string): Name of node.
- node_type (string): Type of node.
- prometheus (bool): Boolean value to enable metrics for a given node.
explorer (bool): A boolean value indicating whether to enable polkadot js explorer or not.
explorer (bool, optional): A boolean value indicating whether to enable polkadot js explorer or not.

Returns:
dict: Service details containing information about relay chains, parachains, and Prometheus.
service_details (json): Service details containing information about relay chains, parachains, and Prometheus.
"""
service_details = run_polkadot_setup(plan, chain_type, relaychain, parachains, explorer)
return service_details
Expand All @@ -40,22 +40,22 @@ def run_polkadot_setup(plan, chain_type, relaychain, parachains, explorer):

Args:
chain_type (string): The type of chain (local, testnet or mainnet). Default is local.
relaychain (dict): A dict containing data for relay chain config.
relaychain (json): A json object containing data for relay chain config.
- name (string): Name of relay chain.
- node (dict): A dict of node details.
- node (json): A json object of node details.
- name (string): Name of node.
- node_type (string): Type of node.
- prometheus (bool): Boolean value to enable metrics for a given node.
parachains (list): A list containing data for para chain config. Each item in the list has the following:
parachains (json): A json object containing data for para chain config. Each item in the list has the following:
- name (string): Name of para chain.
- node (dict): A dict of node details.
- node (json): A json object of node details.
- name (string): Name of node.
- node_type (string): Type of node.
- prometheus (bool): Boolean value to enable metrics for a given node.
explorer (bool): A boolean value indicating whether to enable polkadot js explorer or not.

Returns:
dict: Service details containing information about relay chains, parachains, and Prometheus.
service_details (json): Service details containing information about relay chains, parachains, and Prometheus.
"""

chain_type, relaychain, parachains = utils.convert_to_lowercase(chain_type, relaychain, parachains)
Expand Down
2 changes: 1 addition & 1 deletion package_io/constant.star
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ DIFFERENT_IMAGES_FOR_TESTNET = {
"acala": "acala/mandala-node:latest",
}

CHAIN_COMMAND = ["manta", "moonsama", "interlay", "kintsugi-btc", "polkadex", "centrifuge", "altair", "robonomics", "kilt"]
CHAIN_COMMAND = ["manta", "moonsama", "interlay", "kintsugi-btc", "polkadex", "centrifuge", "altair", "robonomics", "kilt", "mangata"]

KUSAMA_PARACHAINS = ["altair", "bajun", "bifrost", "calamari", "encointer", "karura", "khala", "kintsugi-btc", "litmus", "mangata", "moonriver", "robonomics", "subzero", "turing"]
POLKADOT_PARACHAINS = ["acala", "ajuna", "bifrost", "centrifuge", "clover", "frequency", "integritee", "interlay", "kilt", "kylin", "litentry", "manta", "moonbeam", "moonsama", "nodle", "parallel", "pendulum", "phala", "polkadex", "subsocial", "zeitgeist"]
24 changes: 16 additions & 8 deletions package_io/grafana.star
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,41 @@ def prometheus_grafana_service(plan, service_name, image, port, command, build_f
if build_file != None:
files["/build"] = build_file

if port != None:
public_ports = {"polkadot": PortSpec(port, transport_protocol = "TCP")}
else:
public_ports = {}
service = plan.add_service(
name = service_name,
config = ServiceConfig(
image = image,
files = files,
ports = {
"polkadot": PortSpec(port, transport_protocol = "TCP"),
env_vars={
"GF_AUTH_ANONYMOUS_ENABLED": "true",
"GF_AUTH_ANONYMOUS_ORG_ROLE": "Admin",
"GF_AUTH_ANONYMOUS_ORG_NAME": "Main Org.",
},
public_ports = {
"polkadot": PortSpec(port, transport_protocol = "TCP"),
ports = {
"polkadot": PortSpec(3000, transport_protocol = "TCP"),
},
public_ports = public_ports,
entrypoint = command,
),
)

return service

def launch_grafana(plan):
def launch_grafana(plan, port = None):
command = ["/run.sh"]
service = prometheus_grafana_service(plan, "grafana", "grafana/grafana-dev:10.3.0-147071", 3000, command, None)
service = prometheus_grafana_service(plan, "grafana", "grafana/grafana-dev:10.3.0-147071", port, command, None)

grafana_service_details = {}
all_grafana_service_details = {}

grafana_service_details["service_name"] = "grafana"
grafana_service_details["endpoint"] = utils.get_service_url("http", service.ip_address, 3000)

if port != None:
grafana_service_details["endpoint_public"] = utils.get_service_url("http", "127.0.0.1", port)
all_grafana_service_details[service.name] = grafana_service_details

return all_grafana_service_details
return all_grafana_service_details
24 changes: 18 additions & 6 deletions package_io/promethues.star
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ USED_PORTS = {

def launch_prometheus(
plan,
service_details
service_details,
http_port_number = None
):
template_data = new_config_template_data(
plan,
Expand All @@ -44,27 +45,38 @@ def launch_prometheus(

prometheus_service_details = {}
all_prometheus_service_details = {}
config = get_config(config_files_artifact_name)
config = get_config(config_files_artifact_name, http_port_number)
prometheus_service = plan.add_service(SERVICE_NAME, config)

private_ip_address = prometheus_service.ip_address
prometheus_service_http_port = prometheus_service.ports[HTTP_PORT_ID].number
prometheus_service_details["service_name"] = SERVICE_NAME
prometheus_service_details["endpoint"] = "http://{0}:{1}".format(private_ip_address, prometheus_service_http_port)

if http_port_number != None:
prometheus_service_details["endpoint_public"] = "http://{0}:{1}".format("127.0.0.1", http_port_number)

all_prometheus_service_details[prometheus_service.name] = prometheus_service_details

return all_prometheus_service_details

def get_config(config_files_artifact_name):
def get_config(config_files_artifact_name, http_port_number):
config_file_path = shared_utils.path_join(
CONFIG_DIR_MOUNTPOINT_ON_PROMETHEUS,
shared_utils.path_base(CONFIG_FILENAME),
)
if http_port_number == None:
public_ports = {}
else:
public_ports = {
HTTP_PORT_ID: shared_utils.new_port_spec(
http_port_number,
"TCP",
"http",
),
}
return ServiceConfig(
image = IMAGE_NAME,
ports = USED_PORTS,
public_ports = USED_PORTS,
public_ports = public_ports,
files = {CONFIG_DIR_MOUNTPOINT_ON_PROMETHEUS: config_files_artifact_name},
cmd = [
"--config.file=" + config_file_path,
Expand Down
2 changes: 1 addition & 1 deletion parachain/build-spec.star
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def create_parachain_build_spec_with_para_id(plan, image, binary, chain_name, ch
command = ExecRecipe(command = [
"/bin/sh",
"-c",
"sed -e 's/\"parachainId\": *[0-9]\\+/\"parachainId\": {0}/' -e 's/\"para_id\": [0-9]*,/\"para_id\": {0},/' -e 's/\"paraId\": [0-9]*,/\"paraId\": {0},/' /build/{1}.json > /tmp/{1}.json".format(para_id, chain_name),
"sed -e 's/\"parachainId\": *[0-9]\\+/\"parachainId\": {0}/' -e 's/\"para_id\": [0-9]*,/\"para_id\": {0},/' -e 's/\"paraId\": [0-9]*,/\"paraId\": {0},/' -e 's/\"parachain_id\": [0-9]*,/\"parachain_id\": {0},/' /build/{1}.json > /tmp/{1}.json".format(para_id, chain_name),
])
build_spec.create_edit_and_build_spec(plan, chain_name + "edit", constant.CURL_JQ_IMAGE, chain_name, command, chain_name + "plain")
raw_service = create_raw_build_spec_genisis_state_genisis_wasm(plan, binary, image, chain_name, chain_name + "edit")
Expand Down
2 changes: 1 addition & 1 deletion parachain/static_files/images.star
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ parachain_images = {
"encointer": {
"image": "encointer/parachain:1.5.1",
"entrypoint": "/usr/local/bin/encointer-collator",
"base": ["encointer-rococo-local", "encointer-rococo", "encointer-kusama"],
"base": ["encointer-rococo-local-dev", "encointer-rococo", "encointer-kusama"],
},
"altair": {
"image": "centrifugeio/centrifuge-chain:test-PR1628-354d76c-23-11-28",
Expand Down