github.com/go-graphite/carbonapi@v0.17.0/expr/functions/seriesByTag/function.go (about) 1 package seriesByTag 2 3 import ( 4 "context" 5 6 "github.com/go-graphite/carbonapi/expr/interfaces" 7 "github.com/go-graphite/carbonapi/expr/types" 8 "github.com/go-graphite/carbonapi/pkg/parser" 9 ) 10 11 type seriesByTag struct{} 12 13 func GetOrder() interfaces.Order { 14 return interfaces.Any 15 } 16 17 func New(configFile string) []interfaces.FunctionMetadata { 18 res := make([]interfaces.FunctionMetadata, 0) 19 f := &seriesByTag{} 20 for _, n := range []string{"seriesByTag"} { 21 res = append(res, interfaces.FunctionMetadata{Name: n, F: f}) 22 } 23 return res 24 } 25 26 func (f *seriesByTag) Do(ctx context.Context, eval interfaces.Evaluator, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { 27 var results []*types.MetricData 28 key := parser.MetricRequest{Metric: e.ToString(), From: from, Until: until} 29 data, ok := values[key] 30 if !ok { 31 return results, nil 32 } 33 return data, nil 34 } 35 36 // Description is auto-generated description, based on output of https://github.com/graphite-project/graphite-web 37 func (f *seriesByTag) Description() map[string]types.FunctionDescription { 38 return map[string]types.FunctionDescription{ 39 "seriesByTag": { 40 Description: "Returns a SeriesList of series matching all the specified tag expressions.\n\nExample:\n\n.. code-block:: none\n\n &target=seriesByTag(\"tag1=value1\",\"tag2!=value2\")\n\nReturns a seriesList of all series that have tag1 set to value1, AND do not have tag2 set to value2.\n\nTags specifiers are strings, and may have the following formats:\n\n.. code-block:: none\n\n tag=spec tag value exactly matches spec\n tag!=spec tag value does not exactly match spec\n tag=~value tag value matches the regular expression spec\n tag!=~spec tag value does not match the regular expression spec\n\nAny tag spec that matches an empty value is considered to match series that don't have that tag.\n\nAt least one tag spec must require a non-empty value.\n\nRegular expression conditions are treated as being anchored at the start of the value.\n\nSee :ref:`querying tagged series <querying-tagged-series>` for more detail.", 41 Function: "seriesByTag(*tagExpressions)", 42 Group: "Special", 43 Module: "graphite.render.functions", 44 Name: "seriesByTag", 45 Params: []types.FunctionParam{ 46 { 47 Name: "tagExpressions", 48 Required: true, 49 Type: types.String, 50 Multiple: true, 51 }, 52 }, 53 }, 54 } 55 }