PUSH A DASHBOARD JSON FILE TO GRAFANA
This guide shows you how to push a dashboard that is stored as a JSON file in your repository to Grafana, then fetch it back to check what Grafana stored.
Prerequisites
- A behavior named
grafanaof type@keeb/grafana/instance, withgrafanaUrlset to your Grafana server (see Create and Run a Behavior) - If your Grafana server needs an API key, a key stored in a vault (see Vaults)
If the @keeb/grafana extension is not in the repository yet, pull it:
swamp extension pull @keeb/grafanaThe output looks like:
INF extension·pull: Pulling "@keeb/grafana"@"2026.07.18.1"
INF extension·pull: Identity verified: "@keeb/grafana"@"2026.07.18.1"
INF extension·pull: Pulled "@keeb/grafana"@"2026.07.18.1"
INF extension·pull: Extracted 7 files:If Grafana needs an API key, reference it from the vault in the behavior's global arguments rather than writing it inline:
globalArguments:
grafanaUrl: http://grafana.example.local:3000
apiKey: "${{ vault.get('default', 'grafana-api-key') }}"Write the dashboard file
Save the dashboard JSON as dashboards/service-overview.json in the repository.
Set its uid field to service-overview. You use that UID in the last step to
fetch the dashboard back.
If the dashboard already exists in Grafana and you want to start from that version, export it to a JSON file first.
Push the dashboard
Run pushDashboard with the path to the file:
swamp behavior run grafana pushDashboard --input dashboardFile=dashboards/service-overview.jsonThis command needs a reachable Grafana server. It reads the JSON file from the
repository, sends it to the Grafana API to create or update the dashboard, and
writes the push result to the dashboard resource.
To push a later change, edit the file and run the same command again.
Check what Grafana stored
Fetch the dashboard back by its UID:
swamp behavior run grafana getDashboard --input dashboardUid=service-overviewThis command fetches the dashboard from Grafana and writes its full content,
including panels and variables, to the dashboardContent resource. Compare that
content with your file to confirm the push. To read the stored data, see
Query and Manage Data.
Refer to the Grafana extensions reference for every method and argument.