github.com/muhammadn/cortex@v1.9.1-0.20220510110439-46bb7000d03d/docs/guides/sharded_ruler.md (about)

     1  ---
     2  title: "Config for horizontally scaling the Ruler"
     3  linkTitle: "Config for horizontally scaling the Ruler"
     4  weight: 10
     5  slug: ruler-sharding
     6  ---
     7  
     8  ## Context
     9  
    10  One option to scale the ruler is by scaling it horizontally. However, with multiple ruler instances running they will need to coordinate to determine which instance will evaluate which rule. Similar to the ingesters, the rulers establish a hash ring to divide up the responsibilities of evaluating rules.
    11  
    12  ## Config
    13  
    14  In order to enable sharding in the ruler the following flag needs to be set:
    15  
    16  ```
    17    -ruler.enable-sharding=true
    18  ```
    19  
    20  In addition the ruler requires it's own ring to be configured, for instance:
    21  
    22  ```
    23    -ruler.ring.consul.hostname=consul.dev.svc.cluster.local:8500
    24  ```
    25  
    26  The only configuration that is required is to enable sharding and configure a key value store. From there the rulers will shard and handle the division of rules automatically.
    27  
    28  Unlike ingesters, rulers do not hand over responsibility: all rules are re-sharded randomly every time a ruler is added to or removed from the ring.
    29  
    30  ## Ruler Storage
    31  
    32  The ruler supports six kinds of storage (configdb, azure, gcs, s3, swift, local).  Most kinds of storage work with the sharded ruler configuration in an obvious way.  i.e. configure all rulers to use the same backend.
    33  
    34  The local implementation reads [Prometheus recording rules](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/) off of the local filesystem.  This is a read only backend that does not support the creation and deletion of rules through [the API](../api/_index.md#ruler).  Despite the fact that it reads the local filesystem this method can still be used in a sharded ruler configuration if the operator takes care to load the same rules to every ruler.  For instance this could be accomplished by mounting a [Kubernetes ConfigMap](https://kubernetes.io/docs/concepts/configuration/configmap/) onto every ruler pod.
    35  
    36  A typical local config may look something like:
    37  ```
    38    -ruler-storage.backend=local
    39    -ruler-storage.local.directory=/tmp/cortex/rules
    40  ```
    41  
    42  With the above configuration the ruler would expect the following layout:
    43  ```
    44  /tmp/cortex/rules/<tenant id>/rules1.yaml
    45                               /rules2.yaml
    46  ```
    47  Yaml files are expected to be in the [Prometheus format](https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/#recording-rules).
    48