· 9 years ago · Mar 15, 2017, 01:26 PM
1"""Copyright 2008 Orbitz WorldWide
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License."""
14# Django settings for graphite project.
15# DO NOT MODIFY THIS FILE DIRECTLY - use local_settings.py instead
16import os
17import sys
18from os.path import abspath, dirname, join
19from warnings import warn
20
21from django.core.urlresolvers import reverse_lazy
22
23
24GRAPHITE_WEB_APP_SETTINGS_LOADED = False
25WEBAPP_VERSION = '0.10.0-alpha'
26DEBUG = False
27JAVASCRIPT_DEBUG = False
28
29DATE_FORMAT = '%m/%d'
30
31# Filesystem layout
32WEB_DIR = dirname( abspath(__file__) )
33WEBAPP_DIR = dirname(WEB_DIR)
34GRAPHITE_ROOT = dirname(WEBAPP_DIR)
35# Initialize additional path variables
36# Defaults for these are set after local_settings is imported
37STATIC_ROOT = ''
38STATIC_URL = '/static/'
39URL_PREFIX = ''
40CONF_DIR = ''
41DASHBOARD_CONF = ''
42GRAPHTEMPLATES_CONF = ''
43STORAGE_DIR = ''
44WHITELIST_FILE = ''
45INDEX_FILE = ''
46LOG_DIR = ''
47CERES_DIR = ''
48WHISPER_DIR = ''
49RRD_DIR = ''
50STANDARD_DIRS = []
51
52# Cluster settings
53CLUSTER_SERVERS = []
54# This settings control wether https is used to communicate between cluster members
55INTRACLUSTER_HTTPS = False
56REMOTE_FIND_TIMEOUT = 3.0
57REMOTE_FETCH_TIMEOUT = 3.0
58REMOTE_RETRY_DELAY = 60.0
59REMOTE_EXCLUDE_LOCAL = False
60REMOTE_STORE_MERGE_RESULTS = True
61REMOTE_STORE_FORWARD_HEADERS = []
62CARBON_METRIC_PREFIX='carbon'
63CARBONLINK_HOSTS = ["127.0.0.1:7002"]
64CARBONLINK_TIMEOUT = 1.0
65CARBONLINK_HASHING_KEYFUNC = None
66CARBONLINK_HASHING_TYPE = 'carbon_ch'
67CARBONLINK_RETRY_DELAY = 15
68REPLICATION_FACTOR = 1
69MEMCACHE_HOSTS = []
70MEMCACHE_KEY_PREFIX = ''
71MEMCACHE_OPTIONS = {}
72CACHES={}
73FIND_CACHE_DURATION = 300
74FIND_TOLERANCE = 2 * FIND_CACHE_DURATION
75DEFAULT_CACHE_DURATION = 60 #metric data and graphs are cached for one minute by default
76DEFAULT_CACHE_POLICY = []
77
78LOG_CACHE_PERFORMANCE = False
79LOG_ROTATION = True
80LOG_ROTATION_COUNT = 1
81MAX_FETCH_RETRIES = 2
82
83#Remote rendering settings
84REMOTE_RENDERING = False #if True, rendering is delegated to RENDERING_HOSTS
85RENDERING_HOSTS = []
86REMOTE_RENDER_CONNECT_TIMEOUT = 1.0
87LOG_RENDERING_PERFORMANCE = False
88
89#Miscellaneous settings
90SMTP_SERVER = "localhost"
91DOCUMENTATION_URL = "http://graphite.readthedocs.io/"
92ALLOW_ANONYMOUS_CLI = True
93LEGEND_MAX_ITEMS = 10
94RRD_CF = 'AVERAGE'
95STORAGE_FINDERS = (
96 'graphite.finders.standard.StandardFinder',
97)
98MIDDLEWARE_CLASSES=''
99MAX_TAG_LENGTH = 50
100AUTO_REFRESH_INTERVAL = 60
101
102#Authentication settings
103USE_LDAP_AUTH = False
104LDAP_SERVER = "" # "ldapserver.mydomain.com"
105LDAP_PORT = 389
106LDAP_USE_TLS = False
107LDAP_SEARCH_BASE = "" # "OU=users,DC=mydomain,DC=com"
108LDAP_BASE_USER = "" # "CN=some_readonly_account,DC=mydomain,DC=com"
109LDAP_BASE_PASS = "" # "my_password"
110LDAP_USER_QUERY = "" # "(username=%s)" For Active Directory use "(sAMAccountName=%s)"
111LDAP_URI = None
112
113#Set this to True to delegate authentication to the web server
114USE_REMOTE_USER_AUTHENTICATION = False
115REMOTE_USER_BACKEND = "" # Provide an alternate or subclassed backend
116AUTHENTICATION_BACKENDS=[]
117
118# Django 1.5 requires this so we set a default but warn the user
119SECRET_KEY = 'UNSAFE_DEFAULT'
120
121# Django 1.5 requires this to be set. Here we default to prior behavior and allow all
122ALLOWED_HOSTS = [ '*' ]
123
124# Override to link a different URL for login (e.g. for django_openid_auth)
125LOGIN_URL = reverse_lazy('account_login')
126
127# Set the default timezone to UTC
128TIME_ZONE = 'UTC'
129
130# Set to True to require authentication to save or delete dashboards
131DASHBOARD_REQUIRE_AUTHENTICATION = False
132# Require Django change/delete permissions to save or delete dashboards.
133# NOTE: Requires DASHBOARD_REQUIRE_AUTHENTICATION to be set
134DASHBOARD_REQUIRE_PERMISSIONS = False
135# Name of a group to which the user must belong to save or delete dashboards. Alternative to
136# DASHBOARD_REQUIRE_PERMISSIONS, particularly useful when using only LDAP (without Admin app)
137# NOTE: Requires DASHBOARD_REQUIRE_AUTHENTICATION to be set
138DASHBOARD_REQUIRE_EDIT_GROUP = None
139
140DATABASES = None
141
142# If using rrdcached, set to the address or socket of the daemon
143FLUSHRRDCACHED = ''
144
145## Load our local_settings
146try:
147 from graphite.local_settings import * # noqa
148except ImportError:
149 print >> sys.stderr, "Could not import graphite.local_settings, using defaults!"
150
151## Load Django settings if they werent picked up in local_settings
152if not GRAPHITE_WEB_APP_SETTINGS_LOADED:
153 from graphite.app_settings import * # noqa
154
155STATICFILES_DIRS = (
156 join(WEBAPP_DIR, 'content'),
157)
158
159## Set config dependent on flags set in local_settings
160# Path configuration
161if not STATIC_ROOT:
162 STATIC_ROOT = join(GRAPHITE_ROOT, 'static')
163
164if not CONF_DIR:
165 CONF_DIR = os.environ.get('GRAPHITE_CONF_DIR', join(GRAPHITE_ROOT, 'conf'))
166if not DASHBOARD_CONF:
167 DASHBOARD_CONF = join(CONF_DIR, 'dashboard.conf')
168if not GRAPHTEMPLATES_CONF:
169 GRAPHTEMPLATES_CONF = join(CONF_DIR, 'graphTemplates.conf')
170
171if not STORAGE_DIR:
172 STORAGE_DIR = os.environ.get('GRAPHITE_STORAGE_DIR', join(GRAPHITE_ROOT, 'storage'))
173if not WHITELIST_FILE:
174 WHITELIST_FILE = join(STORAGE_DIR, 'lists', 'whitelist')
175if not INDEX_FILE:
176 INDEX_FILE = join(STORAGE_DIR, 'index')
177if not LOG_DIR:
178 LOG_DIR = join(STORAGE_DIR, 'log', 'webapp')
179if not WHISPER_DIR:
180 WHISPER_DIR = join(STORAGE_DIR, 'whisper/')
181if not CERES_DIR:
182 CERES_DIR = join(STORAGE_DIR, 'ceres/')
183if not RRD_DIR:
184 RRD_DIR = join(STORAGE_DIR, 'rrd/')
185if not STANDARD_DIRS:
186 try:
187 import whisper # noqa
188 if os.path.exists(WHISPER_DIR):
189 STANDARD_DIRS.append(WHISPER_DIR)
190 except ImportError:
191 print >> sys.stderr, "WARNING: whisper module could not be loaded, whisper support disabled"
192 try:
193 import ceres # noqa
194 if os.path.exists(CERES_DIR):
195 STANDARD_DIRS.append(CERES_DIR)
196 except ImportError:
197 pass
198 try:
199 import rrdtool # noqa
200 if os.path.exists(RRD_DIR):
201 STANDARD_DIRS.append(RRD_DIR)
202 except ImportError:
203 pass
204
205if DATABASES is None:
206 DATABASES = {
207 'default': {
208 'NAME': join(STORAGE_DIR, 'graphite.db'),
209 'ENGINE': 'django.db.backends.sqlite3',
210 'USER': '',
211 'PASSWORD': '',
212 'HOST': '',
213 'PORT': '',
214 },
215 }
216
217# Handle URL prefix in static files handling
218if URL_PREFIX and not STATIC_URL.startswith(URL_PREFIX):
219 STATIC_URL = '/{0}{1}'.format(URL_PREFIX.strip('/'), STATIC_URL)
220
221# Default sqlite db file
222# This is set here so that a user-set STORAGE_DIR is available
223if 'sqlite3' in DATABASES.get('default',{}).get('ENGINE','') \
224 and not DATABASES.get('default',{}).get('NAME'):
225 DATABASES['default']['NAME'] = join(STORAGE_DIR, 'graphite.db')
226
227# Caching shortcuts
228if MEMCACHE_HOSTS:
229 CACHES['default'] = {
230 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
231 'LOCATION': MEMCACHE_HOSTS,
232 'TIMEOUT': DEFAULT_CACHE_DURATION,
233 'KEY_PREFIX': MEMCACHE_KEY_PREFIX,
234 'OPTIONS': MEMCACHE_OPTIONS,
235 }
236
237# Authentication shortcuts
238if USE_LDAP_AUTH and LDAP_URI is None:
239 LDAP_URI = "ldap://%s:%d/" % (LDAP_SERVER, LDAP_PORT)
240
241if USE_REMOTE_USER_AUTHENTICATION or REMOTE_USER_BACKEND:
242 MIDDLEWARE_CLASSES += ('django.contrib.auth.middleware.RemoteUserMiddleware',)
243 if REMOTE_USER_BACKEND:
244 AUTHENTICATION_BACKENDS.insert(0,REMOTE_USER_BACKEND)
245 else:
246 AUTHENTICATION_BACKENDS.insert(0,'django.contrib.auth.backends.RemoteUserBackend')
247
248if USE_LDAP_AUTH:
249 AUTHENTICATION_BACKENDS.insert(0,'graphite.account.ldapBackend.LDAPBackend')
250
251if SECRET_KEY == 'UNSAFE_DEFAULT':
252 warn('SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better security')
253
254USE_TZ = True