How to use regular expression to extract data from graphite?

I want to get data from different counters from graphite in one query, for example: -

summarize(site.testing_server_2.triggers_unknown.count,'1hour','sum')&format=json summarize(site.testing_server_2.requests_failed.count,'1hour','sum')&format=json summarize(site.testing_server_2.core_network_bad_soap.count,'1hour','sum')&format=json 

etc. another 20.

But I do not want to receive

 summarize(site.testing_server_2.module_xyz_abc.count,'1hour','sum')&format=json 

in this query, how can I do this?

This is what I tried:

 summarize(site.testing_server_2.*.count,'1hour','sum')&format=json&from=-24hour 

It also gets json data for 'module_xyz_abc', but I don't want that.

+8
ruby graphite
source share
1 answer

You cannot use regular expressions as such, but you can use some similar (in concept and somewhat in format) match methods available in the graphic rendering URL API. There are several ways to β€œcombine” in the target β€œbucket” (that is, between points).

Target Compliance

Asterisk Symbol *

An asterisk can be used to match ANY -zero or more-character (s) . It can be used to replace the entire bucket ( site.*.test ) or inside the bucket ( site.w*t.test ). Here is an example:

 site.testing_server_2.requests_*.count 

This will match site.testing_server_2.requests_failed.count, site.testing_server_2.requests_success.count, site.testing_server_2.requests_blah123.count, etc.

The character range [a-z0-9] matches

Matching a range of characters is used to match a single character ( site.w[0-9]t.test ) in the target bucket and is specified as a range or list. For example:

 site.testing_server_[0-4].requests_failed.count 

This will match at site.testing_server_0.requests_failed.count, site.testing_server_1.requests_failed.count, site.testing_server_2.requests_failed.count, etc.

List of values ​​(group capture) {blah, test, ...} matches

Matching a list of values ​​can be used to match any one in the list of values ​​in a specified part of the target bucket.

 site.testing_server_2.{triggers_unknown,requests_failed,core_network_bad_soap}.count 

This will match site.testing_server_2.triggers_unknown.count, site.testing_server_2.requests_failed.count and site.testing_server_2.core_network_bad_soap.count. But nothing else, so site.testing_server_2.module_xyz_abc.count will not match.

Answer

Without knowing all of your bucket values, it is difficult to be surgical with an approach (possibly with a combination of matching options), so I recommend just going to the value of the list of values . This should allow you to get all the values ​​in one - too long query. For example (and keep in mind that you will need to include all of your values):

 summarize(site.testing_server_2.{triggers_unknown,requests_failed,core_network_bad_soap}.count,'1hour','sum')&format=json&from=-24hour 

For more information, see Graphite Paths and Wildcards.

+17
source share

All Articles