Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
```
git clone https://github.com/making/cf-grafana.git
cd cf-grafana
wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.3.2.linux-x64.tar.gz
tar -zxvf grafana-4.3.2.linux-x64.tar.gz
mv grafana-4.3.2 grafana
wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.3.2.linux-amd64.tar.gz
tar -zxvf grafana-5.3.2.linux-amd64.tar.gz
mv grafana-5.3.2.linux-amd64
# In case of Pivotal Web Services
cf create-service cleardb spark grafana-db
# In case of Pivotal Cloud Foundry
Expand All @@ -24,7 +24,6 @@ Go to https://my-grafana.cfapps.io
> If you don't need to persist dashboards and users, you can use default sqlite3 as follows. This is much better experience than free ClearDB though everything in the instance will disappear when you restart the application.
>
> ```
> sed -i -e 's|^http_port = 3000$|http_port = 8080|' ./conf/defaults.ini
> cf push my-grafana -b binary_buildpack -c './bin/grafana-server web' -m 64m
> ```

Expand Down
10 changes: 10 additions & 0 deletions conf/custom.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#################################### Server ##############################
[server]
# The http port to use
http_port = 8080

# The public facing domain name used to access grafana from a browser
# domain = <your details>

# The full public facing url
# root_url = <your details>
23 changes: 11 additions & 12 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,23 @@ fi

echo "Detected $SERVICE"

MYSQL_URI=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.uri'`
MYSQL_HOSTNAME=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.hostname'`
MYSQL_PASSWORD=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.password'`
MYSQL_PORT=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.port'`
MYSQL_USERNAME=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.username'`
MYSQL_DATABASE=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.name'`
# MYSQL_HOSTNAME=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.hostname'`
# MYSQL_PASSWORD=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.password'`
# MYSQL_PORT=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.port'`
# MYSQL_USERNAME=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.username'`
# MYSQL_DATABASE=`echo $VCAP_SERVICES | jq -r '.["'$SERVICE'"][0].credentials.name'`

SESSION_CONFIG="$MYSQL_USERNAME:$MYSQL_PASSWORD@tcp($MYSQL_HOSTNAME:$MYSQL_PORT)/$MYSQL_DATABASE"
# SESSION_CONFIG="$MYSQL_USERNAME:$MYSQL_PASSWORD@tcp($MYSQL_HOSTNAME:$MYSQL_PORT)/$MYSQL_DATABASE"

cd $GRAFANA_DIR
sed -i -e 's|^url =$|url = '$MYSQL_URI'|' ./conf/defaults.ini
sed -i -e 's|^type = sqlite3$|type = mysql|' ./conf/defaults.ini
sed -i -e 's|^http_port = 3000$|http_port = 8080|' ./conf/defaults.ini
sed -i -e 's|mode = console file|mode = console|' ./conf/defaults.ini
export GF_DATABASE_TYPE=mysql
# drop ?reconnect=true from connection string because Grafana doesn't handle it properly
DATABASE_URL=${DATABASE_URL/?reconnect=true}
export GF_DATABASE_URL=${DATABASE_URL/mysql2/mysql} # replace "mysql2://..." which Grafana doesn't understand in $DATABASE_URL with "mysql://..."
# sed -i -e 's|max_idle_conn =|max_idle_conn = 1|' ./conf/defaults.ini
# sed -i -e 's|max_open_conn =|max_open_conn = 3|' ./conf/defaults.ini
# sed -i -e 's|provider = file|provider = mysql|' ./conf/defaults.ini
# sed -i -e 's|provider_config = sessions|provider_config = '$SESSION_CONFIG'|' ./conf/defaults.ini

echo "Start Grafana"
./bin/grafana-server web &
./bin/grafana-server web &