Now from parameter can be defined in settings file

This commit is contained in:
Mario de Frutos 2014-08-07 09:42:04 +02:00
parent f8604ddaa6
commit 3d694dfb51
4 changed files with 9 additions and 4 deletions

View File

@ -5,6 +5,7 @@ CABOT_FROM_EMAIL = os.environ.get('CABOT_FROM_EMAIL')
GRAPHITE_API = os.environ.get('GRAPHITE_API')
GRAPHITE_USER = os.environ.get('GRAPHITE_USER')
GRAPHITE_PASS = os.environ.get('GRAPHITE_PASS')
GRAPHITE_FROM = os.getenv('GRAPHITE_FROM', '-10minute')
JENKINS_API = os.environ.get('JENKINS_API')
JENKINS_USER = os.environ.get('JENKINS_USER')
JENKINS_PASS = os.environ.get('JENKINS_PASS')

View File

@ -1,5 +1,3 @@
from os import environ as env
from django.conf import settings
import requests
import logging
@ -7,6 +5,7 @@ import logging
graphite_api = settings.GRAPHITE_API
user = settings.GRAPHITE_USER
password = settings.GRAPHITE_PASS
graphite_from = settings.GRAPHITE_FROM
auth = (user, password)
@ -16,7 +15,7 @@ def get_data(target_pattern):
params={
'target': target_pattern,
'format': 'json',
'from': '-10min'
'from': graphite_from
}
)
resp.raise_for_status()
@ -42,7 +41,6 @@ def get_matching_metrics(pattern):
def get_all_metrics(limit=None):
"""Grabs all metrics by navigating find API recursively"""
metrics = []
count = 0
def get_leafs_of_node(nodepath):
for obj in get_matching_metrics(nodepath)['metrics']:

View File

@ -27,6 +27,9 @@ GRAPHITE_API=http://graphite.example.com/
GRAPHITE_USER=username
GRAPHITE_PASS=password
# From parameter for the graphite request, if not defined by default take -10 minutes
# GRAPHITE_FROM=-10minute
# Hipchat integration
HIPCHAT_ALERT_ROOM=48052
HIPCHAT_API_KEY=your_hipchat_api_key

View File

@ -27,6 +27,9 @@ GRAPHITE_API=http://graphite.example.com/
GRAPHITE_USER=username
GRAPHITE_PASS=password
# From parameter for the graphite request, if not defined by default take -10 minutes
# GRAPHITE_FROM=-10minute
# Hipchat integration
HIPCHAT_ALERT_ROOM=48052
HIPCHAT_API_KEY=your_hipchat_api_key