# Sentinel

Type: `middleware.http.sentinel`

Status: alpha

Reference: https://docs.dapr.io/reference/components-reference/supported-middleware/middleware-sentinel/

## Example

```
apiVersion: cra.diagrid.io/v1beta1
kind: Component
metadata:
  name: <name>
spec:
  type: middleware.http.sentinel
  version: v1
  metadata:
    # The application name for Sentinel
    - name: appName
      value: "nodeapp"
    # JSON array of circuit breaker rules to handle failures (Optional)
    #- name: circuitBreakerRules
    #  value: | 
    #    [
    #      {
    #        resource: POST:/v1.0/invoke/nodeapp/method/neworder,
    #        minRequestAmount: 5,
    #        statIntervalMs: 1000,
    #        maxAllowedRtMs: 50,
    #        maxSlowRequestRatio: 0.5
    #      }
    #    ]
    # JSON array of flow control rules to limit request rate (Optional)
    #- name: flowRules
    #  value: | 
    #    [
    #      {
    #        resource: POST:/v1.0/invoke/nodeapp/method/neworder,
    #        threshold: 10,
    #        tokenCalculateStrategy: 0,
    #        controlBehavior: 0
    #      }
    #    ]
    # JSON array of hotspot parameter rules for parameter-based flow control (Optional)
    #- name: hotSpotParamRules
    #  value: | 
    #    [
    #      {
    #        resource: POST:/v1.0/invoke/nodeapp/method/neworder,
    #        paramIdx: 0,
    #        threshold: 10,
    #        maxQueueingTimeMs: 500
    #      }
    #    ]
    # JSON array of isolation rules for thread pool isolation (Optional)
    #- name: isolationRules
    #  value: | 
    #    [
    #      {
    #        resource: POST:/v1.0/invoke/nodeapp/method/neworder,
    #        maxConcurrency: 10,
    #        maxQueueingTimeMs: 500
    #      }
    #    ]
    # Directory for Sentinel log files (Optional)
    #- name: logDir
    #  value: "/var/tmp"
    # JSON array of system protection rules for overall system protection (Optional)
    #- name: systemRules
    #  value: | 
    #    [
    #      {
    #        avgRt: 50,
    #        maxThread: 10,
    #        qps: 20
    #      }
    #    ]

```

## Metadata

### `appName` (string)

**Required** - The application name for Sentinel

Example value: `nodeapp`

### `circuitBreakerRules` (string)

JSON array of circuit breaker rules to handle failures

Example value:

```
[
  {
    resource: POST:/v1.0/invoke/nodeapp/method/neworder,
    minRequestAmount: 5,
    statIntervalMs: 1000,
    maxAllowedRtMs: 50,
    maxSlowRequestRatio: 0.5
  }
]
```

### `flowRules` (string)

JSON array of flow control rules to limit request rate

Example value:

```
[
  {
    resource: POST:/v1.0/invoke/nodeapp/method/neworder,
    threshold: 10,
    tokenCalculateStrategy: 0,
    controlBehavior: 0
  }
]
```

### `hotSpotParamRules` (string)

JSON array of hotspot parameter rules for parameter-based flow control

Example value:

```
[
  {
    resource: POST:/v1.0/invoke/nodeapp/method/neworder,
    paramIdx: 0,
    threshold: 10,
    maxQueueingTimeMs: 500
  }
]
```

### `isolationRules` (string)

JSON array of isolation rules for thread pool isolation

Example value:

```
[
  {
    resource: POST:/v1.0/invoke/nodeapp/method/neworder,
    maxConcurrency: 10,
    maxQueueingTimeMs: 500
  }
]
```

### `logDir` (string)

Directory for Sentinel log files

Example value: `/var/tmp`

### `systemRules` (string)

JSON array of system protection rules for overall system protection

Example value:

```
[
  {
    avgRt: 50,
    maxThread: 10,
    qps: 20
  }
]
```
