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

exported dashboards for sharing, created dashboard export script, upload dashboard github action and updated documentation #641

Merged
merged 12 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 11 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
35 changes: 35 additions & 0 deletions .github/workflows/upload-dashboards.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Upload Dashboards

on:
push:
branches:
- main
ehearneRedHat marked this conversation as resolved.
Show resolved Hide resolved
paths:
- examples/dashboards/app_developer.json
- examples/dashboards/business_user.json
- examples/dashboards/platform_engineer.json

jobs:
upload-dashboards:
name: Upload Dashboards
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
- name: Upload Dashboard
run: |
# Push new dashboard changes

# Init variable with base64 auth
auth=$(echo -n ${{ secrets.GRAFANA_USERNAME }}:${{ secrets.GRAFANA_PASSWORD }} | base64)

# App Developer Dashboard
curl -X POST -F "json=@./examples/dashboards/app_developer.json" -H 'Content-Type: multipart/form-data' -H "Authorization: Basic $auth" "https://www.grafana.com/api/dashboards/20970/revisions"

# Business User Dashboard
curl -X POST -F "json=@./examples/dashboards/business_user.json" -H 'Content-Type: multipart/form-data' -H "Authorization: Basic $auth" "https://www.grafana.com/api/dashboards/20981/revisions"

# Platform Engineer Dashboard
curl -X POST -F "json=@./examples/dashboards/platform_engineer.json" -H 'Content-Type: multipart/form-data' -H "Authorization: Basic $auth" "https://www.grafana.com/api/dashboards/20982/revisions"
10 changes: 10 additions & 0 deletions config/observability/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,13 @@ In the modal popup click **Export** and then **Save to file**.
Alerting rules can be defined in [PrometheusRules](https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/user-guides/alerting.md#configuring-alertmanager-in-prometheus) resources.
The can be viewed in the Prometheus UI Alerts tab.
Some example alerting rules are available in the [/examples](/examples) folder.

## Exporting a dashboard for use with Grafana Community Platform or other Grafana Instances

Following the steps in [Editing dashboards](#editing-dashboards), we need to make one export where the toggle "Export for sharing manually" is toggled. Once this is saved, run the following from `config/observability` .

```bash
universal-dashboard.sh <"Export for sharing manually" JSON file> /path/to/<JSON file>
```

Now, you have a universal dashboard file you can use to import into your Grafana instance, but also use for uploading to the Grafana Community Platform.
35 changes: 35 additions & 0 deletions config/observability/universal-dashboard.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# Check if an argument is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <public_file.json>"
exit 1
fi

# Assign provided argument to a variable
public_file="$1"

# Check if the provided file exists
if [ ! -f "$public_file" ]; then
echo "$public_file does not exist."
exit 1
fi

# Load data from the public file
public_data=$(<"$public_file")

# Extract __inputs.name field and assign to name variable
name=$(echo "$public_data" | jq -r '.__inputs[0].name')
# Encase name variable with ${} so jq can match it.
name=$'${'$name'}'

# Remove the __inputs and __elements fields using jq
updated_data=$(echo "$public_data" | jq 'del(.__inputs, .__elements)')

# Update the uid attribute content to ${datasource}
updated_data=$(echo "$updated_data" | jq --arg old_value $name 'walk(if type == "string" and . == $old_value then "${datasource}" else . end)')

# Write the updated data back to the public file
echo "$updated_data" > $public_file

echo "File $public_file has been updated successfully."
63 changes: 50 additions & 13 deletions examples/dashboards/app_developer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,49 @@
{
"__elements": [],
"__requires": [
{
"type": "panel",
"id": "dashlist",
"name": "Dashboard list",
"version": ""
},
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "8.5.5"
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"version": "1.0.0"
},
{
"type": "panel",
"id": "stat",
"name": "Stat",
"version": ""
},
{
"type": "panel",
"id": "table",
"name": "Table",
"version": ""
},
{
"type": "panel",
"id": "text",
"name": "Text",
"version": ""
},
{
"type": "panel",
"id": "timeseries",
"name": "Time series",
"version": ""
}
],
"annotations": {
"list": [
{
Expand Down Expand Up @@ -26,8 +71,8 @@
"fiscalYearStartMonth": 0,
"gnetId": 7630,
"graphTooltip": 1,
"id": 2,
"iteration": 1713209903588,
"id": null,
"iteration": 1715589343999,
"links": [],
"liveNow": false,
"panels": [
Expand Down Expand Up @@ -1229,8 +1274,8 @@
{
"current": {
"selected": false,
"text": "prometheus",
"value": "prometheus"
"text": "Kuadrant-Thanos-Hub",
"value": "Kuadrant-Thanos-Hub"
},
"hide": 0,
"includeAll": false,
Expand All @@ -1246,15 +1291,7 @@
"type": "datasource"
},
{
"current": {
"selected": true,
"text": [
"All"
],
"value": [
"$__all"
]
},
"current": {},
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
Expand Down
73 changes: 51 additions & 22 deletions examples/dashboards/business_user.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,49 @@
{
"__elements": [],
"__requires": [
{
"type": "panel",
"id": "dashlist",
"name": "Dashboard list",
"version": ""
},
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "8.5.5"
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"version": "1.0.0"
},
{
"type": "panel",
"id": "state-timeline",
"name": "State timeline",
"version": ""
},
{
"type": "panel",
"id": "table",
"name": "Table",
"version": ""
},
{
"type": "panel",
"id": "text",
"name": "Text",
"version": ""
},
{
"type": "panel",
"id": "timeseries",
"name": "Time series",
"version": ""
}
],
"annotations": {
"list": [
{
Expand All @@ -24,8 +69,8 @@
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 1,
"id": 3,
"iteration": 1713210122715,
"id": null,
"iteration": 1715594450345,
"links": [],
"liveNow": false,
"panels": [
Expand Down Expand Up @@ -610,8 +655,8 @@
{
"current": {
"selected": false,
"text": "prometheus",
"value": "prometheus"
"text": "Kuadrant-Thanos-Hub",
"value": "Kuadrant-Thanos-Hub"
},
"hide": 0,
"includeAll": false,
Expand All @@ -626,15 +671,7 @@
"type": "datasource"
},
{
"current": {
"selected": true,
"text": [
"All"
],
"value": [
"$__all"
]
},
"current": {},
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
Expand All @@ -658,15 +695,7 @@
"type": "query"
},
{
"current": {
"selected": true,
"text": [
"All"
],
"value": [
"$__all"
]
},
"current": {},
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
Expand Down
Loading
Loading