graphite-dev team mailing list archive
-
graphite-dev team
-
Mailing list archive
-
Message #00677
Re: [Question #146483]: Priority appears unused in storage-schemas.conf
Question #146483 on Graphite changed:
https://answers.launchpad.net/graphite/+question/146483
Kindjal posted a new comment:
This patch appears to make priority work.
diff --git a/carbon-0.9.7/lib/carbon/storage.py b/carbon-0.9.7/lib/carbon/storage.py
index 3110f10..79df559 100644
--- a/carbon-0.9.7/lib/carbon/storage.py
+++ b/carbon-0.9.7/lib/carbon/storage.py
@@ -15,6 +15,7 @@ limitations under the License."""
import os, re
from os.path import join, exists
from carbon.conf import OrderedConfigParser, Settings, settings
+from operator import attrgetter
try:
import cPickle as pickle
@@ -77,30 +78,33 @@ class Schema:
class DefaultSchema(Schema):
- def __init__(self, name, archives):
+ def __init__(self, name, archives, priority):
self.name = name
self.archives = archives
+ self.priority = priority
def test(self, metric):
return True
class PatternSchema(Schema):
- def __init__(self, name, pattern, archives):
+ def __init__(self, name, pattern, archives, priority):
self.name = name
self.pattern = pattern
self.regex = re.compile(pattern)
self.archives = archives
+ self.priority = priority
def test(self, metric):
return self.regex.search(metric)
class ListSchema(Schema):
- def __init__(self, name, listName, archives):
+ def __init__(self, name, listName, archives, priority):
self.name = name
self.listName = listName
self.archives = archives
+ self.priority = priority
self.path = join(WHITELISTS_DIR, listName)
if exists(self.path):
@@ -154,6 +158,7 @@ def loadStorageSchemas():
matchAll = options.get('match-all')
pattern = options.get('pattern')
listName = options.get('list')
+ priority = options.get('priority')
retentions = options['retentions'].split(',')
archives = [ Archive.fromString(s) for s in retentions ]
@@ -162,7 +167,7 @@ def loadStorageSchemas():
mySchema = DefaultSchema(section, archives)
elif pattern:
- mySchema = PatternSchema(section, pattern, archives)
+ mySchema = PatternSchema(section, pattern, archives, priority)
elif listName:
mySchema = ListSchema(section, listName, archives)
@@ -173,8 +178,10 @@ def loadStorageSchemas():
schemaList.append( mySchema )
schemaList.append( defaultSchema )
+ schemaList = sorted(schemaList,key=attrgetter('priority'),reverse=True)
+
return schemaList
defaultArchive = Archive(60, 60 * 24 * 7) #default retention for unclassified data (7 days of minutely data)
-defaultSchema = DefaultSchema('default', [defaultArchive])
+defaultSchema = DefaultSchema('default', [defaultArchive], 0)
You received this question notification because you are a member of
graphite-dev, which is an answer contact for Graphite.