Skip to content

Commit

Permalink
Specify region in prometheus.
Browse files Browse the repository at this point in the history
  • Loading branch information
DailyDreaming committed Nov 5, 2018
1 parent 5639526 commit df863ce
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions dashboard/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
- targets: ['localhost:9100']
- job_name: 'aws-node-exporter'
ec2_sd_configs:
- region: 'us-west-2'
refresh_interval: 15s
- refresh_interval: 15s
region: ZONE_NAME
port: 9100
relabel_configs:
- source_labels: ['__meta_ec2_tag_Name']
Expand Down
1 change: 1 addition & 0 deletions dashboard/prometheus/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
#Set cluster name

sed -i "s/^\([[:blank:]]*\) regex: CLUSTER_NAME/\1 regex: \'${1}\'/g" /etc/prometheus/prometheus.yml
sed -i "s/^\([[:blank:]]*\) region: ZONE_NAME/\1 region: \'${2}\'/g" /etc/prometheus/prometheus.yml

exec /bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/prometheus --web.console.libraries=/usr/share/prometheus/console_libraries --web.console.templates=/usr/share/prometheus/consoles
11 changes: 7 additions & 4 deletions src/toil/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,8 +1094,10 @@ class ToilMetrics:
def __init__(self, provisioner=None):
if provisioner is not None:
self.clusterName = provisioner.clusterName
self.zone = provisioner._zone if provisioner._zone else 'us-west-2'
else:
self.clusterName = "none"
self.clusterName = 'none'
self.zone = 'us-west-2'

registry = lookupEnvVar(name='docker registry',
envName='TOIL_DOCKER_REGISTRY',
Expand All @@ -1105,7 +1107,7 @@ def __init__(self, provisioner=None):
self.grafanaImage = "%s/toil-grafana:%s" % (registry, dockerTag)
self.prometheusImage = "%s/toil-prometheus:%s" % (registry, dockerTag)

self.startDashboard(clusterName=self.clusterName)
self.startDashboard(clusterName=self.clusterName, zone=self.zone)

# Always restart the mtail container, because metrics should start from scratch
# for each workflow
Expand Down Expand Up @@ -1159,7 +1161,7 @@ def _containerRunning(containerName):
result = False
return result

def startDashboard(self, clusterName):
def startDashboard(self, clusterName, zone):
try:
if not self._containerRunning("toil_prometheus"):
try:
Expand All @@ -1172,7 +1174,8 @@ def startDashboard(self, clusterName):
"-d",
"-p", "9090:9090",
self.prometheusImage,
clusterName])
clusterName,
zone])

if not self._containerRunning("toil_grafana"):
try:
Expand Down

0 comments on commit df863ce

Please sign in to comment.