Skip to content

Commit

Permalink
feat(prometheus): upgrade to XYZ
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Wiseblatt committed Mar 20, 2018
1 parent eaaba69 commit 92e6e9d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
25 changes: 11 additions & 14 deletions spinnaker-monitoring-third-party/third_party/prometheus/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ DASHBOARDS=true
# Variables for Server Configuration
# explicit prometheus versions because its not available with apt-get
# grafana will be latest version in apt-get
PROMETHEUS_VERSION=prometheus-1.7.1.linux-amd64
NODE_EXPORTER_VERSION=node_exporter-0.14.0.linux-amd64
PROMETHEUS_VERSION=prometheus-2.2.1.linux-amd64
NODE_EXPORTER_VERSION=node_exporter-0.15.2.linux-amd64
PUSHGATEWAY_VERSION=pushgateway-0.4.0.linux-amd64
PROMETHEUS_PORT=9090
GRAFANA_PORT=3000
Expand Down Expand Up @@ -263,6 +263,7 @@ function configure_gce_prometheus() {
local path="$1"
local project=$(gce_project_or_empty)
local zone_list=$(gce_zone_list_or_empty)

if [[ -z $project ]]; then
>&2 echo "You are not on GCE so must manually configure $path"
return
Expand Down Expand Up @@ -363,8 +364,8 @@ function install_prometheus() {
local old_conf_file_path=""
local old_data_path=""
if [[ -f /etc/init/prometheus.conf ]]; then
old_data_path=$(grep storage.local.path /etc/init/prometheus.conf \
| sed "s/.*-storage.local.path *\([^ ]*\).*/\1/")
old_data_path=$(grep storage.tsdb.path /etc/init/prometheus.conf \
| sed "s/.*--storage.tsdb.path *\([^ ]*\).*/\1/")
old_conf_file_path=$(grep config.file /etc/init/prometheus.conf \
| sed "s/.*-config.file *\([^ ]*\).*/\1/")
fi
Expand All @@ -375,18 +376,13 @@ function install_prometheus() {
mkdir -p $version_dir
tar xzf /tmp/prometheus.gz -C $(dirname $version_dir)
rm -f /opt/prometheus
ln -s $version_dir /opt/prometheus
ln -fs $version_dir /opt/prometheus
rm /tmp/prometheus.gz
cp "$SOURCE_DIR/prometheus.conf" /etc/init/prometheus.conf
if [[ "$old_data_path" != "" ]]; then
if [[ "$old_data_path" == "/opt/prometheus-1.5.2.linux-amd64/data" ]]; then
echo "Migrating datastore from $old_data_path to /opt/prometheus-data"
mv $old_data_path /opt/prometheus-data
else
echo "Configuring existing non-standard datastore $old_data_path"
sed "s/\/opt\/prometheus-data/${old_data_path//\//\\\/}/" \
-i /etc/init/prometheus.conf
fi
echo "Configuring existing non-standard datastore $old_data_path"
sed "s/\/opt\/prometheus-data/${old_data_path//\//\\\/}/" \
-i /etc/init/prometheus.conf
fi
if [[ "$GCE_CONFIG" == "true" ]]; then
sed "s/spinnaker-prometheus\.yml/gce-prometheus\.yml/" \
Expand Down Expand Up @@ -424,7 +420,8 @@ function install_node_exporter() {
mkdir -p $node_dir
tar xzf /tmp/node_exporter.gz -C $(dirname $node_dir)
rm -f /usr/bin/node_exporter
ln -fs $node_dir/node_exporter /usr/bin/node_exporter
ln -fs $node_dir /opt/node_exporter
ln -fs /opt/node_exporter/node_exporter /usr/bin/node_exporter
rm /tmp/node_exporter.gz
cp $SOURCE_DIR/node_exporter.conf /etc/init/node_exporter.conf
service node_exporter restart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
"steppedLine": false,
"targets": [
{
"expr": "label_replace(sum((node_filesystem_size{mountpoint!~\"/run.*\",device=~\"/dev/.*\",instance=~\"$Instance\"} -\n node_filesystem_avail{mountpoint!~\"/run.*\",device=~\"/dev/.*\",instance=~\"$Instance\"}) / node_filesystem_size{mountpoint!~\"/run.*\",device=~\"/dev/.*\",instance=~\"$Instance\"}) by (instance, device) , \"device\", \"$1\", \"device\", \"/dev(.*)\")",
"expr": "label_replace(sum((node_filesystem_size{mountpoint!~\"/var/lib/docker.*|/run.*\",device=~\"/dev/.*\",instance=~\"$Instance\"} -\n node_filesystem_avail{mountpoint!~\"/var/lib/docker.*/run.*\",device=~\"/dev/.*\",instance=~\"$Instance\"}) / node_filesystem_size{mountpoint!~\"/var/lib/docker.*|/run.*\",device=~\"/dev/.*\",instance=~\"$Instance\"}) by (instance, device) , \"device\", \"$1\", \"device\", \"/dev(.*)\")",
"format": "time_series",
"hide": false,
"interval": "",
Expand Down Expand Up @@ -653,7 +653,7 @@
"steppedLine": false,
"targets": [
{
"expr": "label_replace(sum(node_filesystem_free{mountpoint!~\"/run.*\",device=~\"/dev/.*\",instance=~\"$Instance\"}) by (instance, device), \"device\", \"$1\", \"device\", \"/dev(.*)\")",
"expr": "label_replace(sum(node_filesystem_free{mountpoint!~\"/var/lib/docker.*|/run.*\",device=~\"/dev/.*\",instance=~\"$Instance\"}) by (instance, device), \"device\", \"$1\", \"device\", \"/dev(.*)\")",
"format": "time_series",
"hide": false,
"interval": "",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
start on filesystem or runlevel [2345]

exec /usr/bin/node_exporter 2>&1 /var/log/node_exporter.log
exec /usr/bin/node_exporter 2>&1 > /var/log/node_exporter.log
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
start on filesystem or runlevel [2345]

exec /opt/prometheus/prometheus \
-config.file /opt/prometheus/spinnaker-prometheus.yml \
-storage.local.path /opt/prometheus-data \
--config.file /opt/prometheus/spinnaker-prometheus.yml \
--storage.tsdb.path /opt/prometheus-data \
2>&1 > /var/log/prometheus.log

0 comments on commit 92e6e9d

Please sign in to comment.