feat(grafana): support http dashboard URLs#1395
Conversation
|
Nice feature, I missed it |
| result = plan.run_python( | ||
| description = "Downloading Grafana dashboard: {0}".format(url), | ||
| run = """ | ||
| import sys, urllib.request, os | ||
| os.makedirs("/dashboards-dl", exist_ok=True) | ||
| urllib.request.urlretrieve(sys.argv[1], "/dashboards-dl/" + sys.argv[2]) | ||
| """, | ||
| args = [url, name], | ||
| store = [StoreSpec(src = "/dashboards-dl/", name = name)], | ||
| ) |
There was a problem hiding this comment.
nit / suggestion: this repo already has the curl-via-run_sh + StoreSpec pattern for fetching remote files (see src/network_launcher/ephemery.star, shadowfork.star, public_network.star). Using it here drops the embedded Python and matches the rest of the codebase.
Locally tested with a raw.githubusercontent.com URL — artifact lands in grafana's /dashboards/ correctly.
| result = plan.run_python( | |
| description = "Downloading Grafana dashboard: {0}".format(url), | |
| run = """ | |
| import sys, urllib.request, os | |
| os.makedirs("/dashboards-dl", exist_ok=True) | |
| urllib.request.urlretrieve(sys.argv[1], "/dashboards-dl/" + sys.argv[2]) | |
| """, | |
| args = [url, name], | |
| store = [StoreSpec(src = "/dashboards-dl/", name = name)], | |
| ) | |
| result = plan.run_sh( | |
| description = "Downloading Grafana dashboard: {0}".format(url), | |
| run = "mkdir -p /dashboards-dl && curl -fsSL -o /dashboards-dl/{0} {1}".format(name, url), | |
| store = [StoreSpec(src = "/dashboards-dl/", name = name)], | |
| ) |
There was a problem hiding this comment.
It works with curl, but then the URL would have to be shell-quoted somehow. So that's why I chose run_python, it doesn't have any issues with quoting.
As of Kurtosis 1.18.3, plan.upload_files accepts arbitrary http(s) URLs natively, so the custom run_python downloader is no longer needed. Reverting to a single upload_files call that handles both local paths and URLs.
|
Closing this — turns out we don't need any code changes here. As of Kurtosis 1.18.3, plan.upload_files(dashboard_src, name="additional-grafana-dashboard-{0}".format(index))…already handles both local paths and URLs without any special-casing or Validated end-to-end with: grafana_params:
additional_dashboards:
- "https://raw.githubusercontent.com/rfmoz/grafana-dashboards/master/prometheus/node-exporter-full.json"→ artifact Thanks @fjl for surfacing the use case — your |
Makes it so I can do this