Skip to content

Commit 15638ee

Browse files
committed
1 parent d6a1d2b commit 15638ee

File tree

12 files changed

+58
-43
lines changed

12 files changed

+58
-43
lines changed

docs/config-carbon.rst

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,28 @@ aggregation.
269269
**Note:** if you plan to use the ``=`` sign in your rewrite rules. Use its octal value: ``\075``.
270270
For example ``foo=bar = foo.bar`` would be ``foo\075bar = foo.bar``
271271

272+
Metric Filters: allowed and blocked Metrics
273+
-------------------------------------------
274+
275+
The metric filter functionality allows any of the carbon daemons to only accept
276+
metrics that are explicitly allowed and/or to reject rejected metrics. The
277+
functionality can be enabled in carbon.conf with the ``USE_METRIC_FILTERS``
278+
flag. This can be useful when too many metrics are being sent to a Graphite
279+
instance or when there are metric senders sending useless or invalid metrics.
280+
281+
``GRAPHITE_CONF_DIR`` is searched for ``allowed_metrics.conf`` and
282+
``blocked_metrics.conf``. Each file contains one regular expression per line to
283+
match against metric values. If the allowed_metrics configuration is missing or
284+
empty, all metrics will be passed through by default.
285+
272286
whitelist and blacklist
273287
-----------------------
274-
The whitelist functionality allows any of the carbon daemons to only accept metrics that are explicitly
275-
whitelisted and/or to reject blacklisted metrics. The functionality can be enabled in carbon.conf with
276-
the ``USE_WHITELIST`` flag. This can be useful when too many metrics are being sent to a Graphite
277-
instance or when there are metric senders sending useless or invalid metrics.
288+
The whitelist/blacklist functionality has been renamed to 'allowed' and
289+
'blocked' so as to use less ambiguous language, and remove possible connotations
290+
associated with those terms.
291+
292+
The capabilities have been renamed as of this point, but he existing ``whitelist.conf``
293+
and ``blacklist.conf`` will still be functional for the time being.
278294

279-
``GRAPHITE_CONF_DIR`` is searched for ``whitelist.conf`` and ``blacklist.conf``. Each file contains one regular
280-
expressions per line to match against metric values. If the whitelist configuration is missing or empty,
281-
all metrics will be passed through by default.
295+
Additionally, the ``USE_WHITELIST`` flag in carbon.conf will still be respected,
296+
but treated as ``USE_METRIC_FILTERS`` until it is deprecated.

docs/config-local-settings.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ POOL_MAX_WORKERS
434434
REMOTE_RETRY_DELAY
435435
`Default: 60`
436436

437-
Time in seconds to blacklist a webapp after a timed-out request.
437+
Time in seconds to block/filter a webapp after a timed-out request.
438438

439439
FIND_CACHE_DURATION
440440
`Default: 300`

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def read(fname):
101101
'graphite.url_shortener',
102102
'graphite.url_shortener.migrations',
103103
'graphite.version',
104-
'graphite.whitelist',
104+
'graphite.metric_filters',
105105
'graphite.worker_pool',
106106
],
107107
package_data={'graphite': ['templates/*', 'local_settings.py.example']},

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ envlist =
1111
lint, docs
1212

1313
[testenv]
14-
whitelist_externals =
14+
whitelist_externals = # Unrelated to graphite project deprecation of white/black
1515
mkdir
1616
setenv =
1717
DJANGO_SETTINGS_MODULE=tests.settings

webapp/content/js/composer_widgets.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,20 +1041,20 @@ var GraphDataWindow = {
10411041

10421042
addWlSelected: function (item, e) {
10431043
Ext.Ajax.request({
1044-
url: document.body.dataset.baseUrl + 'whitelist/add',
1044+
url: document.body.dataset.baseUrl + 'metric_filters/add',
10451045
method: 'POST',
1046-
success: function () { Ext.Msg.alert('Result', 'Successfully added metrics to whitelist.'); },
1047-
failure: function () { Ext.Msg.alert('Result', 'Failed to add metrics to whitelist.'); },
1046+
success: function () { Ext.Msg.alert('Result', 'Successfully added metrics to filter.'); },
1047+
failure: function () { Ext.Msg.alert('Result', 'Failed to add metrics to filter.'); },
10481048
params: {metrics: this.getSelectedTargets().join('\n') }
10491049
});
10501050
},
10511051

10521052
removeWlSelected: function (item, e) {
10531053
Ext.Ajax.request({
1054-
url: document.body.dataset.baseUrl + 'whitelist/remove',
1054+
url: document.body.dataset.baseUrl + 'metric_filters/remove',
10551055
method: 'POST',
1056-
success: function () { Ext.Msg.alert('Result', 'Successfully removed metrics from whitelist.'); },
1057-
failure: function () { Ext.Msg.alert('Result', 'Failed to remove metrics from whitelist.'); },
1056+
success: function () { Ext.Msg.alert('Result', 'Successfully removed metrics from filter.'); },
1057+
failure: function () { Ext.Msg.alert('Result', 'Failed to remove metrics from filter.'); },
10581058
params: {metrics: this.getSelectedTargets().join('\n') }
10591059
});
10601060
},

webapp/graphite/app_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
'graphite.render',
106106
'graphite.tags',
107107
'graphite.url_shortener',
108-
'graphite.whitelist',
108+
'graphite.metric_filters',
109109
'django.contrib.auth',
110110
'django.contrib.sessions',
111111
'django.contrib.admin',

webapp/graphite/local_settings.py.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ DEFAULT_XFILES_FACTOR = 0
337337
#
338338
#CARBONLINK_HOSTS = ["127.0.0.1:7002:a", "127.0.0.1:7102:b", "127.0.0.1:7202:c"]
339339
#CARBONLINK_TIMEOUT = 1.0
340-
#CARBONLINK_RETRY_DELAY = 15 # Seconds to blacklist a failed remote server
340+
#CARBONLINK_RETRY_DELAY = 15 # Seconds to block a failed remote server
341341
# Set pickle protocol to use for Carbonlink requests,
342342
# (default of -1 is HIGHEST_AVAILABLE for your Python version)
343343
# see more: https://docs.python.org/3/library/pickle.html#data-stream-format
File renamed without changes.

webapp/graphite/whitelist/urls.py renamed to webapp/graphite/metric_filters/urls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from . import views
1717

1818
urlpatterns = [
19-
url(r'^/add$', views.add, name='whitelist_add'),
20-
url(r'^/remove$', views.remove, name='whitelist_remove'),
21-
url(r'^/?$', views.show, name='whitelist_show'),
19+
url(r'^/add$', views.add, name='metric_filters_add'),
20+
url(r'^/remove$', views.remove, name='metric_filters_remove'),
21+
url(r'^/?$', views.show, name='metric_filters_show'),
2222
]

webapp/graphite/whitelist/views.py renamed to webapp/graphite/metric_filters/views.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,43 +23,43 @@
2323

2424
def add(request):
2525
metrics = set( request.POST['metrics'].split() )
26-
whitelist = load_whitelist()
27-
new_whitelist = whitelist | metrics
28-
save_whitelist(new_whitelist)
26+
allowed_metrics = load_allowed_metrics()
27+
new_allowed_metrics = allowed_metrics | metrics
28+
save_allowed_metrics(new_allowed_metrics)
2929
return HttpResponse(content_type="text/plain", content="OK")
3030

3131

3232
def remove(request):
3333
metrics = set( request.POST['metrics'].split() )
34-
whitelist = load_whitelist()
35-
new_whitelist = whitelist - metrics
36-
save_whitelist(new_whitelist)
34+
allowed_metrics = load_allowed_metrics()
35+
new_allowed_metrics = allowed_metrics - metrics
36+
save_allowed_metrics(new_allowed_metrics)
3737
return HttpResponse(content_type="text/plain", content="OK")
3838

3939

4040
def show(request):
41-
whitelist = load_whitelist()
42-
members = '\n'.join( sorted(whitelist) )
41+
allowed_metrics = load_allowed_metrics()
42+
members = '\n'.join( sorted(allowed_metrics) )
4343
return HttpResponse(content_type="text/plain", content=members)
4444

4545

46-
def load_whitelist():
47-
buffer = open(settings.WHITELIST_FILE, 'rb').read()
48-
whitelist = unpickle.loads(buffer)
49-
return whitelist
46+
def load_allowed_metrics():
47+
buffer = open(settings.METRIC_FILTERS_FILE, 'rb').read()
48+
allowed_metrics = unpickle.loads(buffer)
49+
return allowed_metrics
5050

5151

52-
def save_whitelist(whitelist):
52+
def save_allowed_metrics(allowed_metrics):
5353
# do this instead of dump() to raise potential exceptions before open()
54-
serialized = pickle.dumps(whitelist, protocol=-1)
55-
tmpfile = '%s-%d' % (settings.WHITELIST_FILE, randint(0, 100000))
54+
serialized = pickle.dumps(allowed_metrics, protocol=-1)
55+
tmpfile = '%s-%d' % (settings.METRIC_FILTERS_FILE, randint(0, 100000))
5656
try:
5757
fh = open(tmpfile, 'wb')
5858
fh.write(serialized)
5959
fh.close()
60-
if os.path.exists(settings.WHITELIST_FILE):
61-
os.unlink(settings.WHITELIST_FILE)
62-
os.rename(tmpfile, settings.WHITELIST_FILE)
60+
if os.path.exists(settings.METRIC_FILTERS_FILE):
61+
os.unlink(settings.METRIC_FILTERS_FILE)
62+
os.rename(tmpfile, settings.METRIC_FILTERS_FILE)
6363
finally:
6464
if os.path.exists(tmpfile):
6565
os.unlink(tmpfile)

0 commit comments

Comments
 (0)