# AlertPolicy

> AlertPolicy says when a tenant hears about its flows, and where.

Source: https://docs.go-lumen.ai/de/reference/resources/alertpolicy

## At a glance

| Eigenschaft | Wert |
| --- | --- |
| **apiVersion** | `lumen.ai/v1alpha1` |
| **kind** | `AlertPolicy` |
| **Resource name** | `alertpolicies` |
| **Scope** | Namespaced (lives in a workspace's namespace) |

## Spec

Fields under `spec:`. Nested fields are indented under their parent.

| Feld | Typ | Standardwert | Beschreibung |
| --- | --- | --- | --- |
| `flows` | object |  | Flows selects by label; empty selects every flow in the namespace. |
| `flows.matchExpressions` | list of object |  | matchExpressions is a list of label selector requirements. The requirements are ANDed. |
| `flows.matchExpressions[].key` (erforderlich) | string |  | key is the label key that the selector applies to. |
| `flows.matchExpressions[].operator` (erforderlich) | string |  | operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. |
| `flows.matchExpressions[].values` | list of string |  | values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. |
| `flows.matchLabels` | map of string |  | matchLabels is a map of `{key,value}` pairs. A single `{key,value}` in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. |
| `notify` (erforderlich) | list of object |  | (minItems 1) |
| `notify[].connectorRef` | object |  | LocalObjectReference names an object in the same namespace. |
| `notify[].connectorRef.name` (erforderlich) | string |  | (minLength 1) |
| `notify[].email` | string |  |  |
| `when` (erforderlich) | object |  | AlertCondition is a discriminated union on type. **Regel:** costOver is set exactly when type is CostOver **Regel:** anomaly is set exactly when type is Anomaly |
| `when.anomaly` | object |  |  |
| `when.anomaly.sensitivity` | string | `"medium"` | Sensitivity is the z-score threshold. (one of low, medium, high) |
| `when.costOver` | object |  |  |
| `when.costOver.amountUSD` (erforderlich) | string |  | USD is a non-negative decimal amount in US dollars, as a string because floats do not round-trip through the Kubernetes API. (pattern \`^\[0-9\]+(\\.\[0-9\]{1,6})?$\`) |
| `when.costOver.window` (erforderlich) | string |  | Window is a Prometheus duration, e.g. 1h, 1d. (pattern \`^\[0-9\]+(m|h|d)$\`) |
| `when.type` (erforderlich) | string |  | (one of RunFailed, CostOver, Anomaly) |

## Status

Written by Lumen; do not set it. Only the phase and the conditions are described here.

| Feld | Typ | Standardwert | Beschreibung |
| --- | --- | --- | --- |
| `conditions` | list of object |  |  |
| `conditions[].lastTransitionTime` (erforderlich) | string |  | lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. |
| `conditions[].message` (erforderlich) | string |  | message is a human readable message indicating details about the transition. This may be an empty string. (maxLength 32768) |
| `conditions[].observedGeneration` | integer |  | observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions\[x\].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. (minimum 0) |
| `conditions[].reason` (erforderlich) | string |  | reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty. (minLength 1; maxLength 1024; pattern \`^\[A-Za-z\](\[A-Za-z0-9\_,:\]\*\[A-Za-z0-9\_\])?$\`) |
| `conditions[].status` (erforderlich) | string |  | status of the condition, one of True, False, Unknown. (one of True, False, Unknown) |
| `conditions[].type` (erforderlich) | string |  | type of condition in CamelCase or in foo.example.com/CamelCase. (maxLength 316; pattern \`^(\[a-z0-9\](\[-a-z0-9\]\*\[a-z0-9\])?(\\.\[a-z0-9\](\[-a-z0-9\]\*\[a-z0-9\])?)\*/)?((\[A-Za-z0-9\]\[-A-Za-z0-9\_.\]\*)?\[A-Za-z0-9\])$\`) |

## kubectl columns

| Column | Type | JSONPath |
| --- | --- | --- |
| When | string | `.spec.when.type` |
| Ready | string | `.status.conditions[?(@.type=="Ready")].status` |
| Age | date | `.metadata.creationTimestamp` |

## Example

```yaml title="alertpolicy.yaml"
apiVersion: lumen.ai/v1alpha1
kind: AlertPolicy
metadata:
  name: invoice-failures
  namespace: tenant-acme
spec:
  flows:
    matchLabels: {lumen.ai/owner: git}
  when:
    type: RunFailed
  notify:
    - email: ops@acme.example
```
