Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

Support Custom Graph URL and solve a few related issues #72

Merged
merged 3 commits into from
May 2, 2014
Merged
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
4 changes: 2 additions & 2 deletions src/analyzer/alerters.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def alert_smtp(alert, metric):
msg['Subject'] = '[skyline alert] ' + metric[1]
msg['From'] = sender
msg['To'] = recipient
link = '%s/render/?width=588&height=308&target=%s' % (settings.GRAPHITE_HOST, metric[1])
link = settings.GRAPH_URL % (metric[1])
body = 'Anomalous value: %s <br> Next alert in: %s seconds <a href="%s"><img src="%s"/></a>' % (metric[0], alert[2], link, link)
msg.attach(MIMEText(body, 'html'))
s = SMTP('127.0.0.1')
Expand All @@ -57,7 +57,7 @@ def alert_hipchat(alert, metric):
import hipchat
hipster = hipchat.HipChat(token=settings.HIPCHAT_OPTS['auth_token'])
rooms = settings.HIPCHAT_OPTS['rooms'][alert[0]]
link = '%s/render/?width=588&height=308&target=%s' % (settings.GRAPHITE_HOST, metric[1])
link = settings.GRAPH_URL % (metric[1])

for room in rooms:
hipster.method('rooms/message', method='POST', parameters={'room_id': room, 'from': 'Skyline', 'color': settings.HIPCHAT_OPTS['color'], 'message': 'Anomaly: <a href="%s">%s</a> : %s' % (link, metric[1], metric[0])})
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def check_if_parent_is_alive(self):
def send_graphite_metric(self, name, value):
if settings.GRAPHITE_HOST != '':
sock = socket.socket()
sock.connect((settings.GRAPHITE_HOST.replace('http://', ''), settings.CARBON_PORT))
sock.connect((settings.GRAPHITE_HOST, settings.CARBON_PORT))
sock.sendall('%s %s %i\n' % (name, value, time()))
sock.close()
return True
Expand Down
2 changes: 1 addition & 1 deletion src/horizon/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def in_skip_list(self, metric_name):
def send_graphite_metric(self, name, value):
if settings.GRAPHITE_HOST != '':
sock = socket.socket()
sock.connect((settings.GRAPHITE_HOST.replace('http://', ''), settings.CARBON_PORT))
sock.connect((settings.GRAPHITE_HOST, settings.CARBON_PORT))
sock.sendall('%s %s %i\n' % (name, value, time()))
sock.close()
return True
Expand Down
8 changes: 6 additions & 2 deletions src/settings.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ FULL_DURATION = 86400
MINI_DURATION = 3600

# If you have a Graphite host set up, set this metric to get graphs on
# Skyline and Horizon. Include http://.
GRAPHITE_HOST = 'http://your_graphite_host.com'
# Skyline and Horizon. Don't include http:// since this is used for carbon host as well.
GRAPHITE_HOST = 'your_graphite_host.com'

# The Graph url used to link to Graphite (Or another graphite dashboard)
# %s will be replaced by the metric name
GRAPH_URL = 'http://' + GRAPHITE_HOST + '/render/?width=1400&from=-1hour&target=%s'

# If you have a Graphite host set up, set its Carbon port.
CARBON_PORT = 2003
Expand Down
6 changes: 3 additions & 3 deletions src/webapp/static/js/skyline.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var GRAPHITE_HOST,
var GRAPH_URL,
OCULUS_HOST,
FULL_NAMESPACE,
mini_graph,
Expand All @@ -17,7 +17,7 @@ var handle_data = function(data) {
for (i in data) {
metric = data[i];
name = metric[1]
var src = GRAPHITE_HOST + '/render/?width=1400&from=-1hour&target=' + name;
var src = GRAPH_URL.replace('%s', name);
// Add a space after the metric name to make each unique
to_append = "<div class='sub'><a target='_blank' href='" + src + "'><div class='name'>" + name + " </div></a>&nbsp;&nbsp;"
if (OCULUS_HOST != ''){
Expand Down Expand Up @@ -150,7 +150,7 @@ $(function(){
// Get the variables from settings.py
data = JSON.parse(data);
FULL_NAMESPACE = data['FULL_NAMESPACE'];
GRAPHITE_HOST = data['GRAPHITE_HOST'];
GRAPH_URL = data['GRAPH_URL'];
OCULUS_HOST = data['OCULUS_HOST'];

// Get initial data after getting the host variables
Expand Down
2 changes: 1 addition & 1 deletion src/webapp/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def index():
@app.route("/app_settings")
def app_settings():

app_settings = {'GRAPHITE_HOST': settings.GRAPHITE_HOST,
app_settings = {'GRAPH_URL': settings.GRAPH_URL,
'OCULUS_HOST': settings.OCULUS_HOST,
'FULL_NAMESPACE': settings.FULL_NAMESPACE,
}
Expand Down