Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add a grep function that returns metrics that match a regular expression #151

Merged
merged 1 commit into from

3 participants

@nightfly19

Shell style globing and exclusion lists aren't always powerful enough.

@whilp whilp referenced this pull request in monitorama/hackathon
Closed

Improve search in graphite-web #7

@obfuscurity
Owner

@nightfly19 Can you make that minor change that @SEJeff mentioned? I'd :heart: to merge this in.

@SEJeff
Collaborator

Looks good

@obfuscurity
Owner

It occurred to me afterwards that we're missing the UI bits for this. But it needn't hold up this PR imho.

@nightfly19

Oops, updated to include the new function in the composer.

@obfuscurity obfuscurity merged commit 1b6fbfc into graphite-project:master
@obfuscurity
Owner

Thanks @nightfly19!

:cake: :sparkles: :heart_eyes_cat: :cherries:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 28, 2013
  1. @nightfly19

    Add a grep function that returns metrics that match a regular expression

    nightfly19 authored
    The opposite behavior of exclude
This page is out of date. Refresh to see the latest.
View
1  webapp/content/js/composer_widgets.js
@@ -959,6 +959,7 @@ function createFunctionsMenu() {
{text: 'sortByMinima', handler: applyFuncToEach('sortByMinima')},
{text: 'limit', handler: applyFuncToEachWithInput('limit', 'Limit to first ___ of a list of metrics')},
{text: 'Exclude', handler: applyFuncToEachWithInput('exclude', 'Exclude metrics that match a regular expression')}
+ {text: 'Grep', handler: applyFuncToEachWithInput('grep', 'Exclude metrics that don\'t match a regular expression')}
]
}, {
text: 'Special',
View
15 webapp/graphite/render/functions.py
@@ -2312,6 +2312,21 @@ def exclude(requestContext, seriesList, pattern):
return [s for s in seriesList if not regex.search(s.name)]
+def grep(requestContext, seriesList, pattern):
+ """
+ Takes a metric or a wildcard seriesList, followed by a regular expression
+ in double quotes. Excludes metrics that don't match the regular expression.
+
+ Example:
+
+ .. code-block:: none
+
+ &target=grep(servers*.instance*.threads.busy,"server02")
+ """
+ regex = re.compile(pattern)
+ return [s for s in seriesList if regex.search(s.name)]
+
+
def smartSummarize(requestContext, seriesList, intervalString, func='sum', alignToFrom=False):
"""
Smarter experimental version of summarize.
Something went wrong with that request. Please try again.