added repo

This commit is contained in:
Your Name
2026-08-26 03:39:42 +05:30
parent 45c25a95af
commit b8575bb8b9
6889 changed files with 1217125 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
+11
View File
@@ -0,0 +1,11 @@
apiVersion: v1
description: Automated rule-based alerting for Elasticsearch
name: elastalert2
version: 2.29.0
appVersion: 2.29.0
home: https://github.com/jertel/elastalert2
sources:
- https://github.com/jertel/elastalert2
maintainers:
- name: jertel
engine: gotpl
+125
View File
@@ -0,0 +1,125 @@
# ElastAlert 2 Helm Chart for Kubernetes
An ElastAlert 2 helm chart is available, and can be installed into an existing Kubernetes cluster by following the
instructions below.
Inspiration for optional serviceMonitor and prometheusRules objects, along with source code for calculating and
implementing labels on the chart, ported from https://github.com/bitnami/charts/tree/master/bitnami/thanos/templates
## Installing the Chart
Add the elastalert2 repository to your Helm configuration:
```console
helm repo add elastalert2 https://jertel.github.io/elastalert2/
```
Next, install the chart with a release name, such as _elastalert2_:
```console
helm install elastalert2 elastalert2/elastalert2
```
The command deploys ElastAlert 2 on the Kubernetes cluster in the default configuration.
The [configuration](#configuration) section lists the parameters that can be configured during installation.
See the comment in the default `values.yaml` for specifying a `writebackIndex` for ES 5.x.
If necessary, open Dev Tools on Kibana and send the below request to avoid errors
like `RequestError: TransportError(400, u'search_phase_execution_exception', u'No mapping found for [alert_time] in order to sort on')`
```
PUT /elastalert/_mapping/elastalert
{
"properties": {
"alert_time": {"type": "date"}
}
}
```
## Uninstalling the Chart
To uninstall/delete the ElastAlert 2 deployment:
```console
helm delete elastalert2 --purge
```
The command removes all the Kubernetes components associated with the chart and deletes the release.
## Configuration
| Parameter | Description | Default |
|----------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
| `image.repository` | docker image | jertel/elastalert2 |
| `image.tag` | docker image tag | 2.29.0 |
| `image.pullPolicy` | image pull policy | IfNotPresent |
| `image.pullSecret` | image pull secret | "" |
| `namespaceOverride` | Override the namespace specified in the Helm command for multi-namespace deployments. | "" |
| `deploymentAnnotations` | Annotations to be added to deployment | {} |
| `podAnnotations` | Annotations to be added to pods | {} |
| `podSecurityContext` | Configurable podSecurityContext for pod execution environment | {"runAsUser": 1000, "runAsGroup": 1000, "fsGroup": 1000} |
| `securityContext` | Allows you to set the securityContext for the container | {"runAsNonRoot": true, "runAsUser": 1000} |
| `command` | command override for container | `NULL` |
| `args` | args override for container | `NULL` |
| `replicaCount` | number of replicas to run | 1 |
| `updateStrategy.type` | update strategy to use | RollingUpdate |
| `minReadySeconds` | # number of seconds for which a newly created Pod should be ready without any of its containers crashing, for it to be considered available | 5 |
| `rulesFolder` | Locaton of rules directory. Useful when you have one Docker image and different set of rules per environemnt. | /opt/elastalert/rules |
| `elasticsearch.host` | elasticsearch endpoint to use | elasticsearch |
| `elasticsearch.port` | elasticsearch port to use | 9200 |
| `elasticsearch.useSsl` | whether or not to connect to es_host using SSL | False |
| `elasticsearch.username` | Username for ES with basic auth | `NULL` |
| `elasticsearch.password` | Password for ES with basic auth | `NULL` |
| `elasticsearch.credentialsSecret` | Specifies an existing secret to be used for the ES username/password auth | `NULL` |
| `elasticsearch.credentialsSecretUsernameKey` | The key in elasticsearch.credentialsSecret that stores the ES password auth | `NULL` |
| `elasticsearch.credentialsSecretPasswordKey` | The key in elasticsearch.credentialsSecret that stores the ES username auth | `NULL` |
| `elasticsearch.verifyCerts` | whether or not to verify TLS certificates | True |
| `elasticsearch.clientCert` | path to a PEM certificate to use as the client certificate | `NULL` |
| `elasticsearch.clientKey` | path to a private key file to use as the client key | `NULL` |
| `elasticsearch.caCerts` | path to a CA cert bundle to use to verify SSL connections | `NULL` |
| `elasticsearch.certsVolumes` | certs volumes, required to mount ssl certificates when elasticsearch has tls enabled | `NULL` |
| `elasticsearch.certsVolumeMounts` | mount certs volumes, required to mount ssl certificates when elasticsearch has tls enabled | `NULL` |
| `extraConfigOptions` | Additional options to propagate to all rules, cannot be `alert`, `type`, `name` or `index` | `{}` |
| `secretConfigName` | name of the secret which holds the ElastAlert config. **Note:** this will completely overwrite the generated config | `NULL` |
| `secretRulesName` | name of the secret which holds the ElastAlert rules. **Note:** this will overwrite the generated rules | `NULL` |
| `secretRulesList` | a list of rules to enable from the secret | [] |
| `optEnv` | Additional pod environment variable definitions | [] |
| `extraContainers` | List of additional containers run in the same pod as elastalert | [] |
| `extraInitContainers` | List of additional initContainers run prior to the elastalert pod | [] |
| `extraVolumes` | Additional volume definitions | [] |
| `extraVolumeMounts` | Additional volumeMount definitions | [] |
| `serviceAccount.create` | Specifies whether a service account should be created. | `true` |
| `serviceAccount.name` | Service account to be used. If not set and `serviceAccount.create` is `true`, a name is generated using the fullname template | |
| `serviceAccount.annotations` | ServiceAccount annotations | |
| `podSecurityPolicy.create` | [DEPRECATED] Create pod security policy resources | `false` |
| `resources` | Container resource requests and limits | {} |
| `rootRulesFolder` | **ONLY USE WITH EXPLODED CHART** Set this value to `rules` to read rules from the chart's `rules/` subdirectory. Be aware that Helm cannot read directories outside of the exploded chart's root directory. **Note:** this will override the rules and secretRulesName values. | `rules` |
| `enabledRules` | Name of the active rules without file extension | `[]` |
| `rulesVolumeName` | Specifies the rules volume to be mounted. Can be changed for mounting a custom rules folder via the extraVolumes parameter, instead of using the default rules configMap or secret rule mounting method. | "rules" |
| `rules` | Rule and alert configuration for ElastAlert 2 | {} example shown in values.yaml |
| `runIntervalMins` | Default interval between alert checks, in minutes | 1 |
| `realertIntervalMins` | Time between alarms for same rule, in minutes | `NULL` |
| `scanSubdirectories` | Enable/disable subdirectory scanning for rules | `true` |
| `alertRetryLimitMins` | Time to retry failed alert deliveries, in minutes | 2880 (2 days) |
| `bufferTimeMins` | Default rule buffer time, in minutes | 15 |
| `writebackIndex` | Name or prefix of elastalert index(es) | elastalert |
| `nodeSelector` | Node selector for deployment | {} |
| `affinity` | Affinity specifications for the deployed pod(s) | {} |
| `tolerations` | Tolerations for deployment | [] |
| `smtp_auth.username` | Optional SMTP mail server username. If the value is not empty, the smtp_auth secret will be created automatically. | `NULL` |
| `smtp_auth.password` | Optional SMTP mail server passwpord. This must be specified if the above field, `smtp_auth.username` is also specified. | `NULL` |
| `metrics.enabled` | Enable elastalert prometheus endpoint, add prometheus.io annotations to pod and create a service pointing to the port for prometheus to scrape the metrics | `false` |
| `livenessProbe` | Liveness probe configuration | `enabled: false` |
| `readinessProbe` | Readiness probe configuration | `enabled: false` |
| `metrics.prometheusPort` | If "metrics" is set to true, prometheus metrics will be exposed by the pod on this port. | `8080` |
| `metrics.prometheusPortName` | Name of the port where metrics are exposed | `http-alt` |
| `metrics.prometheusScrapeAnnotations` | If metrics are enabled, annotations to add to the pod for prometheus configuration. prometheus.io/port is also added during the prometheusPort and prometheusPortName values | `{prometheus.io/scrape: "true" prometheus.io/path: "/"}` |
| `metrics.serviceMonitor.enabled` | If metrics are enabled, create a serviceMonitor custom resource for prometheus-operator to detect and configure the metrics endpoint on prometheus. | `false` |
| `metrics.serviceMonitor.labels` | Labels to add to the prometheusRule object for prometheus-operator to detect it, when deployed on a namespace different from the one where prometheus-operator is running. | `{}` |
| `metrics.serviceMonitor.namespace` | Override the namespace for serviceMonitor pod. Take precedence on namespaceOverride value. | `{}` |
| `metrics.serviceMonitor.metricRelabelings` | List of prometheus metric relabeling configs to apply to scrape. Example: drop python_gc metrics or alter pod name. | `[]` |
| `metrics.prometheusRule.enabled` | If metrics are enabled, create a prometheusRule custom resource for prometheus-operator. | `false` |
| `metrics.prometheusRule.namespace` | Override the namespace for Prometheus pod. Take precedence on namespaceOverride value. | `false` |
| `metrics.prometheusRule.additionalLabels` | Labels to add to the prometheusRule object for prometheus-operator to detect it, when deployed on a namespace different from the one where prometheus-operator is running. | `{}` |
| `metrics.prometheusRule.rules` | Group of alerting and/or recording rules to add to the prometheus configuration, example Alerting rules for pod down, or for file descriptors. Should be added as multiline Yaml string. | `` |
@@ -0,0 +1,14 @@
name: Deadman Switch PagerDuty
type: frequency
index: containers-*
num_events: 3
timeframe:
minutes: 3
filter:
- term:
message: "deadmanpd"
alert:
- "pagerduty"
pagerduty:
pagerduty_service_key: dummy
pagerduty_client_name: ElastAlert Deadman Switch
@@ -0,0 +1,13 @@
name: Deadman Switch Slack
type: frequency
index: containers-*
num_events: 3
timeframe:
minutes: 3
filter:
- term:
message: "deadmanslack"
alert:
- "slack"
slack:
slack_webhook_url: dummy
@@ -0,0 +1 @@
1. ElastAlert 2 is now running against: {{ .Values.elasticsearch.host }}:{{ .Values.elasticsearch.port }}
@@ -0,0 +1,36 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "elastalert.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "elastalert.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "elastalert.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "elastalert.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,18 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Kubernetes standard labels
*/}}
{{- define "common.labels.standard" -}}
app.kubernetes.io/name: {{ include "common.names.name" . }}
helm.sh/chart: {{ include "common.names.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector
*/}}
{{- define "common.labels.matchLabels" -}}
app.kubernetes.io/name: {{ include "common.names.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
@@ -0,0 +1,60 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "common.names.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "common.names.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "common.names.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- define "common.names.servicename" -}}
{{- $name := include "common.names.fullname" . | trunc 53 -}}
{{- printf "%s-%s" $name "metrics" -}}
{{- end -}}
{{- define "common.names.configname" -}}
{{- $name := include "common.names.fullname" . | trunc 53 -}}
{{- printf "%s-%s" $name "config" -}}
{{- end -}}
{{/*
Allow the release namespace to be overridden for multi-namespace deployments in combined charts.
*/}}
{{- define "common.names.namespace" -}}
{{- if .Values.namespaceOverride -}}
{{- .Values.namespaceOverride -}}
{{- else -}}
{{- .Release.Namespace -}}
{{- end -}}
{{- end -}}
{{/*
Create a fully qualified app name adding the installation's namespace.
*/}}
{{- define "common.names.fullname.namespace" -}}
{{- printf "%s-%s" (include "common.names.fullname" .) (include "common.names.namespace" .) | trunc 63 | trimSuffix "-" -}}
{{- end -}}
@@ -0,0 +1,13 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Renders a value that contains template.
Usage:
{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $) }}
*/}}
{{- define "common.tplvalues.render" -}}
{{- if typeIs "string" .value }}
{{- tpl .value .context }}
{{- else }}
{{- tpl (.value | toYaml) .context }}
{{- end }}
{{- end -}}
@@ -0,0 +1,51 @@
{{- if not .Values.secretConfigName }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "common.names.configname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
data:
elastalert_config: |-
---
rules_folder: {{ .Values.rulesFolder }}
{{- if .Values.scanSubdirectories }}
scan_subdirectories: {{ .Values.scanSubdirectories }}
{{- end }}
run_every:
minutes: {{ .Values.runIntervalMins }}
{{- if .Values.realertIntervalMins }}
realert:
minutes: {{ .Values.realertIntervalMins }}
{{- end }}
buffer_time:
minutes: {{ .Values.bufferTimeMins }}
es_host: {{ .Values.elasticsearch.host }}
es_port: {{ .Values.elasticsearch.port }}
{{- if .Values.elasticsearch.username }}
es_username: {{ .Values.elasticsearch.username }}
{{- end }}
{{- if .Values.elasticsearch.password }}
es_password: {{ .Values.elasticsearch.password }}
{{- end }}
writeback_index: {{ .Values.writebackIndex }}
use_ssl: {{ .Values.elasticsearch.useSsl }}
verify_certs: {{ .Values.elasticsearch.verifyCerts }}
{{- if .Values.elasticsearch.clientCert }}
client_cert: {{ .Values.elasticsearch.clientCert }}
{{- end }}
{{- if .Values.elasticsearch.clientKey }}
client_key: {{ .Values.elasticsearch.clientKey }}
{{- end }}
{{- if .Values.elasticsearch.caCerts }}
ca_certs: {{ .Values.elasticsearch.caCerts }}
{{- end }}
alert_time_limit:
minutes: {{ .Values.alertRetryLimitMins }}
{{- if .Values.extraConfigOptions }}
{{ toYaml .Values.extraConfigOptions | indent 4 }}
{{- end }}
{{- end }}
@@ -0,0 +1,182 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "elastalert.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels:
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
app: {{ template "elastalert.name" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if .Values.deploymentAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.deploymentAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "common.labels.matchLabels" . | nindent 6 }}
replicas: {{ .Values.replicaCount }}
{{- if .Values.updateStrategy }}
strategy: {{- toYaml .Values.updateStrategy | nindent 4 }}
{{- end }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
minReadySeconds: {{ .Values.minReadySeconds }}
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/config.yaml") . | sha256sum }}
checksum/rules: {{ include (print $.Template.BasePath "/rules.yaml") . | sha256sum }}
{{- if .Values.metrics.enabled }}
{{ toYaml .Values.metrics.prometheusScrapeAnnotations | indent 8 }}
prometheus.io/port: {{ .Values.metrics.prometheusPort | quote}}
{{- end }}
{{- if .Values.podAnnotations }}
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
labels: {{- include "common.labels.standard" . | nindent 8 }}
app.kubernetes.io/component: {{ .Values.appKubernetesIoComponent }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 8 }}
{{- end }}
spec:
{{- if .Values.image.pullSecret }}
imagePullSecrets:
- name: {{ .Values.image.pullSecret }}
{{- end }}
serviceAccountName: {{ include "elastalert.serviceAccountName" . }}
{{- if .Values.podSecurityContext }}
securityContext:
{{ toYaml .Values.podSecurityContext | indent 8 }}
{{- end }}
{{- if .Values.extraInitContainers }}
initContainers:
{{ .Values.extraInitContainers | toYaml | indent 6}}
{{- end }}
containers:
{{- if .Values.extraContainers }}
{{ .Values.extraContainers | toYaml | indent 6}}
{{- end }}
- name: elastalert
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.metrics.enabled }}
ports:
- containerPort: {{ .Values.metrics.prometheusPort }}
protocol: TCP
name: {{ .Values.metrics.prometheusPortName }}
{{- end }}
{{- if .Values.securityContext }}
securityContext:
{{ toYaml .Values.securityContext | indent 10 }}
{{- end }}
{{- if .Values.command }}
command:
{{ toYaml .Values.command | indent 10 }}
{{- end }}
{{- if or .Values.args .Values.metrics.enabled }}
args:
{{- if .Values.args }}
{{ toYaml .Values.args | indent 10 }}
{{- end }}
{{- if .Values.metrics.enabled }}
{{- $enableportlist := list "--prometheus_port" (.Values.metrics.prometheusPort | toString) }}
{{ toYaml $enableportlist | indent 10 }}
{{- end }}
{{- end }}
volumeMounts:
- name: config
mountPath: '/opt/elastalert/config.yaml'
subPath: config.yaml
- name: {{ .Values.rulesVolumeName }}
mountPath: {{ .Values.rulesFolder }}
{{- if .Values.elasticsearch.certsVolumeMounts }}
{{ toYaml .Values.elasticsearch.certsVolumeMounts | indent 10 }}
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | indent 10 }}
{{- end }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
{{ toYaml .Values.livenessProbe | indent 10 }}
{{- end }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
{{ toYaml .Values.readinessProbe | indent 10 }}
{{- end }}
env:
{{- if .Values.elasticsearch.credentialsSecret }}
{{- if .Values.elasticsearch.credentialsSecretUsernameKey }}
- name: ES_USERNAME
valueFrom:
secretKeyRef:
name: {{ .Values.elasticsearch.credentialsSecret }}
key: {{ .Values.elasticsearch.credentialsSecretUsernameKey }}
{{- end }}
{{- if .Values.elasticsearch.credentialsSecretPasswordKey }}
- name: ES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.elasticsearch.credentialsSecret }}
key: {{ .Values.elasticsearch.credentialsSecretPasswordKey }}
{{- end }}
{{- end }}
{{- if .Values.optEnv }}
{{ .Values.optEnv | toYaml | indent 10}}
{{- end }}
restartPolicy: Always
{{- if .Values.tolerations }}
tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
{{- end }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.affinity }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
volumes:
- name: rules
{{- if .Values.secretRulesName }}
secret:
secretName: {{ .Values.secretRulesName }}
items:
{{- range $key := .Values.secretRulesList }}
- key: {{ $key }}
path: {{ $key}}.yaml
{{- end }}
{{- else }}
configMap:
name: {{ template "elastalert.fullname" . }}-rules
items:
{{- range $key, $value := .Values.rules }}
- key: {{ $key }}
path: {{ $key}}.yaml
{{- end }}
{{- end }}
- name: config
{{- if .Values.secretConfigName }}
secret:
secretName: {{ .Values.secretConfigName }}
{{- else }}
configMap:
name: {{ template "elastalert.fullname" . }}-config
{{- end }}
items:
- key: elastalert_config
path: config.yaml
{{- if .Values.elasticsearch.certsVolumes }}
{{ toYaml .Values.elasticsearch.certsVolumes | indent 8 }}
{{- end }}
{{- if .Values.extraVolumes }}
{{ toYaml .Values.extraVolumes | indent 8 }}
{{- end }}
@@ -0,0 +1,39 @@
{{- if .Values.podSecurityPolicy.create }}
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: {{ template "elastalert.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
spec:
# Prevents running in privileged mode
privileged: false
# Required to prevent escalations to root.
allowPrivilegeEscalation: false
volumes:
- configMap
- secret
hostNetwork: false
hostIPC: false
hostPID: false
runAsUser:
rule: RunAsAny
seLinux:
rule: RunAsAny
supplementalGroups:
rule: MustRunAs
ranges:
# Forbid adding the root group.
- min: 1
max: 65535
fsGroup:
rule: MustRunAs
ranges:
# Forbid adding the root group.
- min: 1
max: 65535
readOnlyRootFilesystem: false
{{- end }}
@@ -0,0 +1,19 @@
{{- if and .Values.metrics.enabled .Values.metrics.prometheusRule.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ template "common.names.fullname" . }}
namespace: {{ .Values.metrics.prometheusRule.namespace | default (include "common.names.namespace" .) | quote }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.metrics.prometheusRule.additionalLabels }}
{{- include "common.tplvalues.render" (dict "value" .Values.metrics.prometheusRule.additionalLabels "context" $) | nindent 4 }}
{{- end }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.prometheusRule.rules "context" $ ) | nindent 2 }}
{{- end }}
@@ -0,0 +1,20 @@
{{- if .Values.podSecurityPolicy.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ template "elastalert.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
rules:
- apiGroups:
- policy
resources:
- podsecuritypolicies
resourceNames:
- {{ template "elastalert.fullname" . }}
verbs:
- use
{{- end -}}
@@ -0,0 +1,18 @@
{{- if .Values.podSecurityPolicy.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ template "elastalert.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ template "elastalert.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ template "elastalert.serviceAccountName" . }}
{{- end -}}
@@ -0,0 +1,27 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "elastalert.fullname" . }}-rules
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
data:
{{- if .Values.rootRulesFolder }}
{{- $rulesDirectory := printf "%v/**.{yaml,yml}" .Values.rootRulesFolder -}}
{{- $enabledRules := .Values.enabledRules -}}
{{- range $rule, $_ := .Files.Glob $rulesDirectory -}}
{{- $ruleBase := base $rule -}}
{{- $ruleName := regexReplaceAll "\\.(yaml|yml)$" $ruleBase "" -}}
{{- if has $ruleName $enabledRules }}
{{ $ruleBase }}: |-
{{ $.Files.Get $rule | indent 4 }}
{{- end }}
{{- end }}
{{- else }}
{{- range $key, $value := .Values.rules }}
{{ $key }}: |-
{{ $value | indent 4 }}
{{- end }}
{{- end }}
@@ -0,0 +1,44 @@
{{- if .Values.metrics.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "common.names.servicename" . | quote }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
app.kubernetes.io/component: {{ .Values.appKubernetesIoComponent}}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
annotations:
{{- if .Values.commonAnnotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.metrics.service.type }}
{{- if and .Values.metrics.service.clusterIP (eq .Values.metrics.service.type "ClusterIP") }}
clusterIP: {{ .Values.metrics.service.clusterIP }}
{{- end }}
{{- if ne .Values.metrics.service.type "ClusterIP" }}
externalTrafficPolicy: {{ .Values.metrics.service.externalTrafficPolicy }}
{{- end }}
{{- if and .Values.metrics.service.loadBalancerIP (eq .Values.metrics.service.type "LoadBalancer") }}
loadBalancerIP: {{ .Values.metrics.service.loadBalancerIP }}
{{- end }}
{{- if and (eq .Values.metrics.service.type "LoadBalancer") .Values.metrics.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges: {{- toYaml .Values.metrics.service.loadBalancerSourceRanges | nindent 4 }}
{{- end }}
ports:
- port: {{ .Values.metrics.prometheusPort }}
targetPort: {{ .Values.metrics.prometheusPort }}
protocol: TCP
name: {{ .Values.metrics.prometheusPortName }}
{{- if and (or (eq .Values.metrics.service.type "NodePort") (eq .Values.metrics.service.type "LoadBalancer")) .Values.metrics.service.nodePorts }}
nodePort: {{ .Values.metrics.service.nodePorts }}
{{- else if eq .Values.metrics.service.type "ClusterIP" }}
nodePort: null
{{- end }}
selector:
{{- include "common.labels.matchLabels" . | nindent 4 }}
app.kubernetes.io/component: {{ .Values.appKubernetesIoComponent }}
{{- end }}
@@ -0,0 +1,15 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "elastalert.serviceAccountName" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end -}}
@@ -0,0 +1,45 @@
{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "common.names.servicename" . | quote }}
namespace: {{ .Values.metrics.serviceMonitor.namespace | default (include "common.names.namespace" .) | quote }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
app.kubernetes.io/component: {{ .Values.appKubernetesIoComponent}}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.metrics.serviceMonitor.labels }}
{{- toYaml .Values.metrics.serviceMonitor.labels | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- if .Values.metrics.serviceMonitor.jobLabel }}
jobLabel: {{ .Values.metrics.serviceMonitor.jobLabel }}
{{- end }}
endpoints:
- port: {{ .Values.metrics.prometheusPortName }}
{{- if .Values.metrics.serviceMonitor.interval }}
interval: {{ .Values.metrics.serviceMonitor.interval }}
{{- end }}
{{- if .Values.metrics.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- if .Values.metrics.serviceMonitor.metricRelabelings }}
metricRelabelings: {{ toYaml .Values.metrics.serviceMonitor.metricRelabelings | nindent 8 }}
{{- end }}
{{- if .Values.metrics.serviceMonitor.relabelings }}
relabelings: {{ toYaml .Values.metrics.serviceMonitor.relabelings | nindent 8 }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace | quote }}
selector:
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
app.kubernetes.io/component: {{ .Values.appKubernetesIoComponent }}
{{- if .Values.metrics.serviceMonitor.selector }}
{{- include "common.tplvalues.render" (dict "value" .Values.metrics.serviceMonitor.selector "context" $) | nindent 6 }}
{{- end }}
{{- end }}
@@ -0,0 +1,16 @@
{{- if .Values.smtp_auth }}
apiVersion: v1
kind: Secret
metadata:
name: elastalert-smtp-auth
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
type: kubernetes.io/Opaque
stringData:
smtp_auth.yaml: |-
user: {{ .Values.smtp_auth.username }}
password: {{ .Values.smtp_auth.password }}
{{- end}}
+429
View File
@@ -0,0 +1,429 @@
## Chart information
nameOverride: ""
fullnameOverride: ""
namespaceOverride: "elastalert-stg"
commonLabels: {}
commonAnnotations: {}
appKubernetesIoComponent: elastalert2
# Folder where Helm can find local rules prior to deployment to the k8s cluster. By default,
# 'rules' folder must be located in the root of the chart directory. Note that this setting
# will override the rules and secretRulesName values. Again, these rules are only read
# during the time of the chart deployment (installation) into the cluster.
# rootRulesFolder: "rules"
# enabledRules: ["deadman_slack", "deadman_pagerduty"]
# number of replicas to run
replicaCount: 1
# update strategy to use (default : RollingUpdate) but can be Recreate
updateStrategy:
type: RollingUpdate
rollingUpdate: {}
# number of helm release revisions to retain
revisionHistoryLimit: 5
# number of seconds for which a newly created Pod should be ready without any of its containers crashing, for it to be considered available.
minReadySeconds: 5
# Default internal between alert checks against the elasticsearch datasource, in minutes
runIntervalMins: 1
# Location of directory where rules reside
rulesFolder: "/opt/elastalert/rules"
# Enable/disabe subdirectory scanning for rules
scanSubdirectories: true
# Default rule buffer duration, in minutes
bufferTimeMins: 15
# Amount of time to retry and deliver failed alerts (1440 minutes per day)
alertRetryLimitMins: 2880
# Default time before realerting, in minutes
realertIntervalMins: ""
# For ES 5: The name of the index which stores elastalert 2 statuses, typically elastalert_status
# For ES 6: The prefix of the names of indices which store elastalert 2 statuses, typically elastalert
#
writebackIndex: elastalert
image:
# docker image
repository: jertel/elastalert2
# docker image tag
tag: 2.29.0
pullPolicy: IfNotPresent
pullSecret: ""
resources: {}
# Annotations to be added to deployment
deploymentAnnotations: {}
# Annotations to be added to pods
podAnnotations: {}
elasticsearch:
# ECK-managed ES service: <es-name>-es-http.<namespace>.svc.cluster.local
host: eck-observability-stg-es-http.eck-observability-stg.svc.cluster.local
# elasticsearch port
port: 9200
# whether or not to connect to es_host using TLS
# TLS is disabled on the ES HTTP layer (selfSignedCertificate.disabled: true in elasticsearch.yaml)
useSsl: "False"
# Username if authenticating to ES with basic auth
username: "elastic"
# Password if authenticating to ES with basic auth
# Get from: kubectl get secret eck-observability-stg-es-elastic-user -n eck-observability-stg -o jsonpath='{.data.elastic}' | base64 -d
password: "bJzZgYgHHMaMBlsj8TtTDKlu"
# Specifies an existing secret to be used for the ES username/password
credentialsSecret: ""
# The key in elasticsearch.credentialsSecret that stores the ES password
credentialsSecretUsernameKey: ""
# The key in elasticsearch.credentialsSecret that stores the ES username
credentialsSecretPasswordKey: ""
# whether or not to verify TLS certificates
# False because TLS is disabled on this cluster
verifyCerts: "False"
# Enable certificate based authentication
# path to a PEM certificate to use as the client certificate
# clientCert: "/certs/client.pem"
# path to a private key file to use as the client key
# clientKey: "/certs/client-key.pem"
# path to a CA cert bundle to use to verify SSL connections
# caCerts: "/certs/ca.pem"
# # certs volumes, required to mount ssl certificates when elasticsearch has tls enabled
# certsVolumes:
# - name: es-certs
# secret:
# defaultMode: 420
# secretName: es-certs
# # mount certs volumes, required to mount ssl certificates when elasticsearch has tls enabled
# certsVolumeMounts:
# - name: es-certs
# mountPath: /certs
# readOnly: true
# Optional env variables for the pod
optEnv: []
## Specify optional additional containers to run alongside the Elastalert2 container.
extraContainers: []
## Specify optional additional initContainers to run prior to the Elastalert2 container.
extraInitContainers: []
extraConfigOptions: {}
# # Options to propagate to all rules, e.g. a common slack_webhook_url or kibana_url
# # Please note at the time of implementing this value, it will not work for required_locals
# # Which MUST be set at the rule level, these are: ['alert', 'type', 'name', 'index']
# kibana_url: https://kibana.yourdomain.com
# slack_webhook_url: dummy
# To load ElastAlert 2 config via secret, uncomment the line below
# secretConfigName: elastalert-config-secret
# Example of a secret config
#apiVersion: v1
#kind: Secret
#metadata:
# name: elastalert-config-secret
#type: Opaque
#stringData:
# elastalert_config: |-
# rules_folder: /opt/elastalert/rules
# scan_subdirectories: false
# run_every:
# minutes: 1
# buffer_time:
# minutes: 15
# es_host: elasticsearch
# es_port: 9200
# writeback_index: elastalert
# use_ssl: False
# verify_certs: True
# alert_time_limit:
# minutes: 2880
# slack_webhook_url: https://hooks.slack.com/services/xxxx
# slack_channel_override: '#alerts'
# To load ElastAlert's rules via secret, uncomment the line below
#secretRulesName: elastalert-rules-secret
# Additionally, you must specificy which rules to load from the secret
#secretRulesList: [ "rule_1", "rule_2" ]
# Example of secret rules
#apiVersion: v1
#kind: Secret
#metadata:
# name: elastalert-rules-secret
# namespace: elastic-system
#type: Opaque
#stringData:
# rule_1: |-
# name: Rule 1
# type: frequency
# index: index1-*
# num_events: 3
# timeframe:
# minutes: 1
# alert:
# - "slack"
# rule_2: |-
# name: Rule 2
# type: frequency
# index: index2-*
# num_events: 5
# timeframe:
# minutes: 10
# alert:
# - "slack"
# Command and args override for container e.g. (https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/)
# command: ["YOUR_CUSTOM_COMMAND"]
# args: ["YOUR", "CUSTOM", "ARGS"]
# specifies the rules volume to be used
rulesVolumeName: "rules"
# additional rule configurations e.g. (http://elastalert2.readthedocs.io/en/latest/)
rules: {}
# deadman_slack: |-
# ---
# name: Deadman Switch Slack
# type: frequency
# index: containers-*
# num_events: 3
# timeframe:
# minutes: 3
# filter:
# - term:
# message: "deadmanslack"
# alert:
# - "slack"
# slack:
# slack_webhook_url: dummy
# deadman_pagerduty: |-
# ---
# name: Deadman Switch PagerDuty
# type: frequency
# index: containers-*
# num_events: 3
# timeframe:
# minutes: 3
# filter:
# - term:
# message: "deadmanpd"
# alert:
# - "pagerduty"
# pagerduty:
# pagerduty_service_key: dummy
# pagerduty_client_name: ElastAlert Deadman Switch
# Probes configuration
livenessProbe:
enabled: false
readinessProbe:
enabled: false
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name:
# Enable pod security policy
# https://kubernetes.io/docs/concepts/policy/pod-security-policy/
# DEPRECATED in Kubernetes 1.21 (https://kubernetes.io/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/)
podSecurityPolicy:
create: false
securityContext:
runAsNonRoot: true
runAsUser: 1000
podSecurityContext:
fsGroup: 1000
runAsUser: 1000
runAsGroup: 1000
# Support using node selectors and tolerations
# nodeSelector:
# "node-role.kubernetes.io/infra_worker": "true"
nodeSelector: {}
# Specify node affinity or anti-affinity specifications
affinity: {}
# tolerations:
# - key: "node_role"
# operator: "Equal"
# value: "infra_worker"
# effect: "NoSchedule"
tolerations: []
# Optional automatic SMTP mail server credential management.
# smtp_auth:
# username: ""
# password: ""
extraVolumes: []
# - name: smtp-auth
# secret:
# secretName: elastalert-smtp-auth
# items:
# - key: smtp_auth.yaml
# path: smtp_auth.yaml
# mode: 0400
extraVolumeMounts: []
# - name: smtp-auth
# mountPath: /opt/elastalert/config-smtp/smtp_auth.yaml
# subPath: smtp_auth.yaml
# readOnly: true
## @section Metrics parameters
## Prometheus metrics
##
metrics:
## @param metrics.enabled Enable the export of Prometheus metrics
##
enabled: false
prometheusPort: 8080
prometheusPortName: http-alt
# Prometheus Exporter defined by port:
prometheusScrapeAnnotations:
prometheus.io/scrape: "true"
prometheus.io/path: "/"
service:
type: ClusterIP
# clusterIP: ""
# externalTrafficPolicy: Cluster
# loadBalancerIP: ""
# loadBalancerSourceRanges: {}
# nodePorts: ""
## Prometheus Operator ServiceMonitor configuration
##
serviceMonitor:
## @param metrics.serviceMonitor.enabled Specify if a ServiceMonitor will be deployed for Prometheus Operator
##
enabled: false
## @param metrics.serviceMonitor.namespace Namespace in which Prometheus is running
##
namespace: ""
## @param metrics.serviceMonitor.labels Extra labels for the ServiceMonitor
## Normally used for prometheus operator to detect the servicemonitor if deployed to different namespace
## labels:
## release: prometheus-operator
labels: {}
## @param metrics.serviceMonitor.jobLabel The name of the label on the target service to use as the job name in Prometheus
##
jobLabel: ""
## @param metrics.serviceMonitor.interval How frequently to scrape metrics
## e.g:
## interval: 10s
##
interval: ""
## @param metrics.serviceMonitor.scrapeTimeout Timeout after which the scrape is ended
## e.g:
## scrapeTimeout: 10s
##
scrapeTimeout: ""
## @param metrics.serviceMonitor.metricRelabelings [array] Specify additional relabeling of metrics
## metricRelabelings:
## # Drop GO metrics
## - sourceLabels: [__name__]
## regex: go_.*
## action: drop
## # Drop python_gc metrics
## - sourceLabels: [__name__]
## regex: python_gc.*
## action: drop
## # Normalise POD names
## - sourceLabels: [pod]
## regex: (.+elastalert2)\-([\w\d]+)\-([\w\d]+)
## replacement: $1
## targetLabel: pod
metricRelabelings: []
## @param metrics.serviceMonitor.relabelings [array] Specify general relabeling
##
relabelings: []
## @param metrics.serviceMonitor.selector Prometheus instance selector labels
## ref: https://github.com/bitnami/charts/tree/master/bitnami/prometheus-operator#prometheus-configuration
##
selector: {}
## PrometheusRule CRD configuration
##
prometheusRule:
## @param metrics.prometheusRule.enabled If `true`, creates a Prometheus Operator PrometheusRule (also requires `metrics.enabled` to be `true`)
##
enabled: false
## @param metrics.prometheusRule.namespace Namespace in which the PrometheusRule CRD is created
##
namespace: ""
## @param metrics.prometheusRule.additionalLabels Additional labels for the prometheusRule
## to be detected by prometheus-operator
## additionalLabels:
## release: prometheus-operator
additionalLabels: {}
## @param metrics.prometheusRule.rules Prometheus Rules for ElastAlert 2.
## These are just examples rules, please adapt them to your needs.
## rules: |-
## groups:
## - name: elastalert
## rules:
## - alert: elastalert Pod down
## annotations:
## description: Prometheus is unable to scrape metrics service. Check pod logs for details
## summary: elastalert POD is down
## expr: up{service="{{ template "common.names.servicename" . }}",container="elastalert"} == 0
## for: 5m
## labels:
## severity: critical
## production: 'True'
## - alert: elastalert file descriptors use
## annotations:
## description: Elastalert pod nearly exhausting file descriptors
## summary: too many file descriptors used
## expr: |-
## process_open_fds{service="{{ template "common.names.servicename" . }}",container="elastalert"}
## /
## process_max_fds{service="{{ template "common.names.servicename" . }}",container="elastalert"}
## > 0.9
## for: 3m
## labels:
## severity: critical
## production: 'True'
## - alert: elastalert scrapes failing
## annotations:
## description: Elastalert is not scraping for a rule {{ "{{" }} $labels.rule_name {{ "}}" }}
## summary: scrapes for rule stalled {{ "{{" }} $labels.rule_name {{ "}}" }}
## expr: |-
## rate(elastalert_scrapes_total{service="{{ template "common.names.servicename" . }}",container="elastalert"}[1m]) == 0
## for: 5m
## labels:
## severity: critical
## production: 'True'
rules: []