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

Add env vars to the grafana connection of post_start script. #105

Merged
merged 2 commits into from
Feb 6, 2024

Conversation

bitodt
Copy link
Contributor

@bitodt bitodt commented Feb 4, 2024

Added the following env vars in the set_default_graf_dash.sh script, while keeping the default values in case they're not set:

  • GRAFANA_USER
  • GRAFANA_PASS
  • GRAFANA_HOST
  • GRAFANA_PORT

This is very helpful when deploying with Docker or in a Kubernetes cluster. You can set the env vars in the docker-compose file, or your kubernetes yaml or helm charts.

Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

Can you please rebase the PR to avoid the merge commit? And give the commit a proper commit message?

@@ -1,12 +1,20 @@
#!/bin/sh

# Grafana connection configuration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: comments should always be full sentences, including punctuation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to "# Set your Grafana instance's connection configuration.".

echo "Setting Grafana default dashboard..."
DASH_UID="sJUFc-NWk"
DASH_ID=0
for i in 1 2 3 4 5; do
curl -H 'Content-Type: application/json' -X GET http://admin:admin@grafana:3000/api/dashboards/uid/$DASH_UID && RESP=$(curl -H 'Content-Type: application/json' -X GET http://admin:admin@grafana:3000/api/dashboards/uid/$DASH_UID) && DASH_ID=$( echo "$RESP" | jq '.dashboard.id' ) && break || sleep 15;
curl -H 'Content-Type: application/json' -X GET http://${GRAFANA_URI}/api/dashboards/uid/$DASH_UID && RESP=$(curl -H 'Content-Type: application/json' -X GET http://${GRAFANA_URI}/api/dashboards/uid/$DASH_UID) && DASH_ID=$( echo "$RESP" | jq '.dashboard.id' ) && break || sleep 15;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we put the full URL into double quotes to make sure white space and other special characters don't break the command?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still working on this.
Need to debug the quotes, maybe add escape chars somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the user:pass from the URI and explicitly set it with -u. Including quotes to handle spaces.
Hostname and port can't have spaces, unless there is an edge case I'm missing.

@bitodt bitodt reopened this Feb 5, 2024
Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK, LGTM 🎉

@guggero guggero requested a review from bhandras February 6, 2024 07:42
Copy link
Member

@bhandras bhandras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@guggero guggero merged commit a849499 into lightninglabs:master Feb 6, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants