Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit fae5f31

Browse files
author
Jarret Lavallee
committed
Change the default to use InfluxDB instead of Graphite
This commit modifies the options to enable the use of Graphite and InfluxDB as the back end database. It defaults to using InfluxDB instead of Graphite
1 parent 34839c4 commit fae5f31

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ By default, the script uses a retention of 30 days. You can specify a different
3434

3535
_Note:_ `.json` files outside the retention peroid will be deleted as the asumption is that they exist in the tar balls.
3636

37-
#### Use InfluxDB as the backend database
38-
By default, graphite is used to store the data. New capabilities have been built to use InfluxDB as the back end database in `json2graphite.rb` and can be used as the back end database container.
37+
#### Use Graphite as the backend database
38+
By default, InfluxDB is used to store the data. New capabilities have been built to use InfluxDB as the back end database in `json2graphite.rb` and can be used as the back end database container. Graphite can be used as well with the following option.
3939

4040
```
41-
./view-in-grafana.sh -i ~/Downloads/pe_metrics/puppetserver
41+
./view-in-grafana.sh -d graphite ~/Downloads/pe_metrics/puppetserver
4242
```
4343

4444
#### Build the local containers instead of from Dockerhub

view-in-grafana.sh

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
# VARIABLES
44
BUILDLOCAL=false
5-
INFLUXDB=false
6-
CONTAINERPATH="grafana-puppetserver"
7-
NETCATARGS='--netcat localhost'
5+
DATABASE="influxdb"
6+
CONTAINERPATH="influxdb-grafana"
7+
NETCATARGS='--netcat localhost --convert-to influxdb --influx-db archive'
88
RETENTION_DAYS=30
99

1010
# ARGUMENT PARSING
@@ -13,20 +13,28 @@ usage()
1313
{
1414
echo
1515
echo "USAGE: view-in-grafana.sh <options> [directory] <retention_days>"
16-
echo "Options: -i Enable InfluxDB"
16+
echo "Options: -d [influxdb|graphite] Enable InfluxDB or Graphite as the back end database. Defaults to InfluxDB"
1717
echo " -b Build local containers from docker-compose"
1818
}
1919

20-
while getopts ":bi" opt; do
20+
while getopts ":bd:" opt; do
2121
case $opt in
2222
b)
2323
BUILDLOCAL=true
2424
;;
25-
i)
26-
echo "Using InfluxDB"
27-
INFLUXDB=true
28-
CONTAINERPATH="influxdb-grafana"
29-
NETCATARGS='--netcat localhost --convert-to influxdb --influx-db archive'
25+
d)
26+
if [ "$OPTARG" == "graphite" ]; then
27+
echo "Using Graphite"
28+
DATABASE="graphite"
29+
CONTAINERPATH="grafana-puppetserver"
30+
NETCATARGS='--netcat localhost'
31+
elif [ "$OPTARG" == "influxdb" ]; then
32+
echo "Using InfluxDB"
33+
else
34+
echo "Invalid database: $OPTARG" >&2
35+
usage
36+
exit 1
37+
fi
3038
;;
3139
\?)
3240
echo "Invalid option: -$OPTARG" >&2
@@ -72,7 +80,7 @@ get_latest_containers() {
7280
echo "Downloading latest containers"
7381
docker-compose pull --ignore-pull-failures >/dev/null 2>&1
7482
fi
75-
if [ $INFLUXDB ]; then
83+
if [ "$DATABASE" == "influxdb" ]; then
7684
echo "Getting the latest graphs"
7785
download_dashboards
7886
fi
@@ -108,7 +116,7 @@ NUM_DEL=$(find "$datadir" -type f -mtime +$RETENTION_DAYS -iname "*.json" -delet
108116
echo "Deleted $NUM_DEL files past retention_days"
109117

110118
echo "Loading data..."
111-
../json2graphite.rb --pattern "$datadir/"'**/*.json' $NETCATARGS >/dev/null
119+
../json2graphite.rb --pattern "$datadir/"'**/*.json' $NETCATARGS 2> /dev/null
112120

113121
echo
114122
echo "Metrics ready! View at http://localhost:3000"

0 commit comments

Comments
 (0)