github.com/netdata/go.d.plugin@v0.58.1/pkg/prometheus/selector/README.md (about)

     1  <!--
     2  title: "Time series selector"
     3  custom_edit_url: "https://github.com/netdata/go.d.plugin/edit/master/pkg/prometheus/selector/README.md"
     4  sidebar_label: "Time series selector"
     5  learn_status: "Published"
     6  learn_rel_path: "Developers/External plugins/go.d.plugin/Helper Packages"
     7  -->
     8  
     9  # Time series selector
    10  
    11  Selectors allow selecting and filtering of a set of time series.
    12  
    13  ## Simple Selector
    14  
    15  In the simplest form you need to specify only a metric name.
    16  
    17  ### Syntax
    18  
    19  ```cmd
    20   <line>                 ::= <metric_name_pattern>
    21   <metric_name_pattern>  ::= simple pattern
    22  ```
    23  
    24  The metric name pattern syntax is [simple pattern](https://github.com/netdata/netdata/blob/master/src/libnetdata/simple_pattern/README.md).
    25  
    26  ### Examples
    27  
    28  This example selects all time series that have the `go_memstats_alloc_bytes` metric name:
    29  
    30  ```cmd
    31  go_memstats_alloc_bytes
    32  ```
    33  
    34  This example selects all time series with metric names starts with `go_memstats_`:
    35  
    36  ```cmd
    37  go_memstats_*
    38  ```
    39  
    40  This example selects all time series with metric names starts with `go_` except `go_memstats_`:
    41  
    42  ```cmd
    43  !go_memstats_* go_*
    44  ``` 
    45  
    46  ## Advanced Selector
    47  
    48  It is possible to filter these time series further by appending a comma separated list of label matchers in curly braces (`{}`).
    49  
    50  ### Syntax
    51  
    52  ```cmd
    53   <line>                 ::= [ <metric_name_pattern> ]{ <list_of_selectors> }
    54   <metric_name_pattern>  ::= simple pattern
    55   <list_of_selectors>    ::= a comma separated list <label_name><op><label_value_pattern>
    56   <label_name>           ::= an exact label name
    57   <op>                   ::= [ '=', '!=', '=~', '!~', '=*', '!*' ]
    58   <label_value_pattern>  ::= a label value pattern, depends on <op>
    59  ```
    60  
    61  The metric name pattern syntax is [simple pattern](https://github.com/netdata/netdata/blob/master/src/libnetdata/simple_pattern/README.md).
    62  
    63  Label matching operators:
    64  
    65  -   `=`: Match labels that are exactly equal to the provided string.
    66  -   `!=`: Match labels that are not equal to the provided string.
    67  -   `=~`: Match labels that [regex-match](https://golang.org/pkg/regexp/syntax/) the provided string.
    68  -   `!~`: Match labels that do not [regex-match](https://golang.org/pkg/regexp/syntax/) the provided string.
    69  -   `=*`: Match labels that [simple-pattern-match](https://github.com/netdata/netdata/blob/master/src/libnetdata/simple_pattern/README.md) the provided string.
    70  -   `!*`: Match labels that do not [simple-pattern-match](https://github.com/netdata/netdata/blob/master/src/libnetdata/simple_pattern/README.md) the provided string.
    71  
    72  ### Examples
    73  
    74  This example selects all time series that:
    75  
    76  -   have the `node_cooling_device_cur_state` metric name and
    77  -   label `type` value not equal to `Fan`:
    78  
    79  ```cmd
    80  node_cooling_device_cur_state{type!="Fan"}
    81  ```
    82  
    83  This example selects all time series that:
    84  
    85  -   have the `node_filesystem_size_bytes` metric name and
    86  -   label `device` value is either `/dev/nvme0n1p1` or `/dev/nvme0n1p2` and
    87  -   label `fstype` is equal to `ext4`
    88  
    89  ```cmd
    90  node_filesystem_size_bytes{device=~"/dev/nvme0n1p1$|/dev/nvme0n1p2$",fstype="ext4"}
    91  ```
    92  
    93  Label matchers can also be applied to metric names by matching against the internal `__name__` label.
    94  
    95  For example, the expression `node_filesystem_size_bytes` is equivalent to `{__name__="node_filesystem_size_bytes"}`.
    96  This allows using all operators (other than `=*`) for metric names matching.
    97  
    98  The following expression selects all metrics that have a name starting with `node_`:
    99  
   100  ```cmd
   101  {__name__=*"node_*"}
   102  ```