Skip to content

Commit 57c2901

Browse files
authored
feat: Add check-alert cron task (#2)
1 parent a05cf98 commit 57c2901

File tree

5 files changed

+60
-1
lines changed

5 files changed

+60
-1
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ hyperdx:
114114
key: API_KEY
115115
```
116116

117+
## Task Configuration
118+
119+
By default, there is one task in the chart setup as a cronjob, responsible for checking whether alerts should fire. Here are its configuration options:
120+
121+
| Parameter | Description | Default |
122+
|-----------|-------------|---------|
123+
| `tasks.enabled` | Enable/Disable cron tasks in the cluster. By default, the HyperDX image will run cron tasks intra process. Change to true if you'd rather use a separate cron task in the cluster. | `false` |
124+
| `tasks.checkAlerts.schedule` | Cron schedule for the check-alerts task | `*/1 * * * *` |
125+
| `tasks.checkAlerts.resources` | Resource requests and limits for the check-alerts task | See `values.yaml` |
126+
117127
## Upgrading the Chart
118128

119129
To upgrade to a newer version:

charts/hdx-oss-v2/data/users.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<app>
2626
<password>{{ .Values.clickhouse.config.users.appUserPassword }}</password>
2727
<networks>
28+
<ip>10.0.0.0/8</ip> <!-- Kubernetes cluster IP range -->
2829
<host_regexp>.*\.svc\.cluster\.local$</host_regexp>
2930
</networks>
3031
<profile>readonly</profile>

charts/hdx-oss-v2/templates/configmaps/app-configmap.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ data:
1717
NEXT_PUBLIC_SERVER_URL: "http://localhost:{{ .Values.hyperdx.apiPort }}"
1818
OTEL_SERVICE_NAME: "hdx-oss-api"
1919
REDIS_URL: "redis://{{ include "hdx-oss.fullname" . }}-redis:{{ .Values.redis.port }}"
20-
USAGE_STATS_ENABLED: "{{ .Values.hyperdx.usageStatsEnabled | default true }}"
20+
USAGE_STATS_ENABLED: "{{ .Values.hyperdx.usageStatsEnabled | default true }}"
21+
CRON_IN_APP_DISABLED: "{{ .Values.tasks.enabled | default false }}"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{{- if .Values.tasks.enabled }}
2+
---
3+
apiVersion: batch/v1
4+
kind: CronJob
5+
metadata:
6+
name: {{ include "hdx-oss.fullname" . }}-check-alerts
7+
labels:
8+
{{- include "hdx-oss.labels" . | nindent 4 }}
9+
spec:
10+
schedule: {{ .Values.tasks.checkAlerts.schedule | quote }}
11+
concurrencyPolicy: Forbid
12+
jobTemplate:
13+
spec:
14+
template:
15+
metadata:
16+
labels:
17+
{{- include "hdx-oss.selectorLabels" . | nindent 12 }}
18+
app.kubernetes.io/component: task
19+
spec:
20+
restartPolicy: OnFailure
21+
containers:
22+
- name: task
23+
image: "{{ .Values.images.hdx.repository }}:{{ .Values.images.hdx.tag | default .Chart.AppVersion }}"
24+
command: ["node", "/app/api/build/tasks/index.js", "check-alerts"]
25+
envFrom:
26+
- configMapRef:
27+
name: {{ include "hdx-oss.fullname" . }}-app-config
28+
env:
29+
- name: NODE_ENV
30+
value: "production"
31+
- name: OTEL_SERVICE_NAME
32+
value: "hdx-oss-task-check-alerts"
33+
resources:
34+
{{- toYaml .Values.tasks.checkAlerts.resources | nindent 16 }}
35+
{{- end }}

charts/hdx-oss-v2/values.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,15 @@ persistence:
7070
mongodb:
7171
enabled: true
7272
size: 10Gi
73+
74+
tasks:
75+
enabled: false
76+
checkAlerts:
77+
schedule: "*/1 * * * *" # Runs every 1 minute
78+
resources:
79+
limits:
80+
cpu: 200m
81+
memory: 256Mi
82+
requests:
83+
cpu: 100m
84+
memory: 128Mi

0 commit comments

Comments
 (0)