Skip to content

Commit

Permalink
cleanup & simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
edobry committed Jan 22, 2025
1 parent 1148cf3 commit 9550698
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
1 change: 0 additions & 1 deletion main.star
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ def run(plan, args):
)

plan.print("Launching grafana...")

grafana.launch_grafana(
plan,
prometheus_private_url,
Expand Down
26 changes: 7 additions & 19 deletions src/observability/grafana/grafana_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,11 @@ HTTP_PORT_NUMBER_UINT16 = 3000

TEMPLATES_FILEPATH = "./templates"

DATASOURCE_CONFIG_TEMPLATE_FILEPATH = TEMPLATES_FILEPATH + "/datasource.yml.tmpl"
DASHBOARD_PROVIDERS_CONFIG_TEMPLATE_FILEPATH = (
TEMPLATES_FILEPATH + "/dashboard-providers.yml.tmpl"
)

DATASOURCE_UID = "grafanacloud-prom"
DATASOURCE_CONFIG_TEMPLATE_FILEPATH = TEMPLATES_FILEPATH + "/datasource.yml.tmpl"
DATASOURCE_CONFIG_REL_FILEPATH = "datasources/datasource.yml"

# this is relative to the files artifact root
DASHBOARD_PROVIDERS_CONFIG_REL_FILEPATH = "dashboards/dashboard-providers.yml"

CONFIG_DIRPATH_ON_SERVICE = "/config"
DASHBOARDS_DIRPATH_ON_SERVICE = "/dashboards"

USED_PORTS = {
HTTP_PORT_ID: ethereum_package_shared_utils.new_port_spec(
Expand Down Expand Up @@ -121,12 +113,12 @@ def provision_dashboards(plan, service_url, dashboard_sources):
return

def grr_push(dir):
return 'grr push "$DASHBOARDS_DIR/{0}" -e --disable-reporting'.format(dir)
return 'grr push "{0}" -e --disable-reporting'.format(dir)

def grr_push_dashboards(i):
def grr_push_dashboards(name):
return [
grr_push("dashboards-{0}/folders".format(i)),
grr_push("dashboards-{0}/dashboards".format(i)),
grr_push("{0}/folders".format(name)),
grr_push("{0}/dashboards".format(name)),
]

grr_commands = [
Expand All @@ -138,18 +130,14 @@ def provision_dashboards(plan, service_url, dashboard_sources):
dashboard_name = "dashboards-{0}".format(index)
dashboard_artifact_name = plan.upload_files(dashboard_src, name=dashboard_name)

files[
"{0}/{1}".format(DASHBOARDS_DIRPATH_ON_SERVICE, dashboard_name)
] = dashboard_artifact_name

grr_commands += grr_push_dashboards(index)
files[dashboard_name] = dashboard_artifact_name
grr_commands += grr_push_dashboards(dashboard_name)

plan.run_sh(
description="upload dashboards",
image="grafana/grizzly:main-0b88d01",
env_vars={
"GRAFANA_URL": service_url,
"DASHBOARDS_DIR": DASHBOARDS_DIRPATH_ON_SERVICE,
},
files=files,
run=util.join_cmds(grr_commands),
Expand Down

0 comments on commit 9550698

Please sign in to comment.