Skip to content

Commit 32dfb12

Browse files
authored
Push alerts to elastic search (#108) (#118)
* add elasticsearch stack to github actions * added kind config to map nodeports and removed portforwarding remove node settings added authentication added auth * push alerts to elastic search push alerts to elastic search elastic env in action nit echo nit test test lint fix * push metrics to elastic search metric structure change added upload_metric * push telemetry to elastic + refactoring remove warning fixed model error added module export from elastic models namespace minor checks minor checks changed method name fix tests changed check on metric type reduced elastic log level float casting fixed telemetry model minor nits test fix poetry.lock * export modules lint * taint constructor update * metrics model refactoring lint * elastic library log level * downgraded elastic search to 7.x fix --------- Signed-off-by: Tullio Sebastiani <[email protected]>
1 parent aceeef4 commit 32dfb12

File tree

14 files changed

+953
-115
lines changed

14 files changed

+953
-115
lines changed

.github/workflows/build.yaml

+36-6
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ jobs:
3131
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
3232
helm repo add stable https://charts.helm.sh/stable
3333
helm repo update
34-
- name: Deploy prometheus & Port Forwarding
34+
- name: Deploy prometheus
3535
run: |
36+
# nodePort mapping 30000 -> http://localhost:9090
3637
kubectl create namespace monitoring
3738
helm install \
3839
--wait --timeout 360s \
@@ -47,11 +48,36 @@ jobs:
4748
--set alertmanager.service.type=NodePort \
4849
--set prometheus-node-exporter.service.nodePort=32001 \
4950
--set prometheus-node-exporter.service.type=NodePort
51+
- name: Deploy Elasticsearch
5052

51-
SELECTOR=`kubectl -n monitoring get service kind-prometheus-kube-prome-prometheus -o wide --no-headers=true | awk '{ print $7 }'`
52-
POD_NAME=`kubectl -n monitoring get pods --selector="$SELECTOR" --no-headers=true | awk '{ print $1 }'`
53-
kubectl -n monitoring port-forward $POD_NAME 9090:9090 &
54-
sleep 5
53+
env:
54+
ELASTIC_URL: ${{ vars.ELASTIC_URL }}
55+
ELASTIC_PORT: ${{ vars.ELASTIC_PORT }}
56+
ELASTIC_USER: ${{ vars.ELASTIC_USER }}
57+
ELASTIC_PASSWORD: ${{ vars.ELASTIC_PASSWORD }}
58+
run: |
59+
echo "ELASTIC_URL: ${ELASTIC_URL}"
60+
echo "ELASTIC_PORT: ${ELASTIC_PORT}"
61+
echo "ELASTIC_USER: ${ELASTIC_USER}"
62+
echo "ELASTIC_PASSWORD:${ELASTIC_PASSWORD}"
63+
64+
65+
# nodePort mapping 32766 -> http://localhost:9091
66+
helm install \
67+
--wait --timeout 360s \
68+
elasticsearch \
69+
oci://registry-1.docker.io/bitnamicharts/elasticsearch \
70+
--set master.masterOnly=false \
71+
--set master.replicaCount=1 \
72+
--set data.replicaCount=0 \
73+
--set coordinating.replicaCount=0 \
74+
--set ingest.replicaCount=0 \
75+
--set service.type=NodePort \
76+
--set service.nodePorts.restAPI=32766 \
77+
--set security.elasticPassword=test \
78+
--set security.enabled=true \
79+
--set image.tag=7.17.23-debian-12-r0 \
80+
--set security.tls.autoGenerated=true
5581
- name: Check out code
5682
uses: actions/checkout@v3
5783
- name: Update version number
@@ -78,7 +104,11 @@ jobs:
78104
BUCKET_NAME: ${{ secrets.BUCKET_NAME }}
79105
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
80106
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
81-
ES_SERVER: ${{ secrets.ES_SERVER }}
107+
ELASTIC_URL: ${{ vars.ELASTIC_URL }}
108+
ELASTIC_PORT: ${{ vars.ELASTIC_PORT }}
109+
ELASTIC_USER: ${{ vars.ELASTIC_USER }}
110+
ELASTIC_PASSWORD: ${{ vars.ELASTIC_PASSWORD }}
111+
82112
run: |
83113
export TEST_WORKDIR=`pwd`/`date +%s`
84114
mkdir $TEST_WORKDIR

kind-config.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
kind: Cluster
2+
apiVersion: kind.x-k8s.io/v1alpha4
3+
nodes:
4+
- role: control-plane
5+
extraPortMappings:
6+
- containerPort: 30000
7+
hostPort: 9090
8+
- containerPort: 32766
9+
hostPort: 9091

poetry.lock

+21-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ tzlocal = "5.1"
2121
pytz = "^2023.3"
2222
PyYAML = "6.0.1"
2323
prometheus-api-client = "^0.5.4"
24-
elasticsearch = "8.14.0"
24+
elasticsearch = "7.13.4"
25+
elasticsearch-dsl = "7.4.1"
2526
wheel = "^0.42.0"
2627
cython = "3.0"
2728

src/krkn_lib/elastic/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .krkn_elastic import * # NOQA

0 commit comments

Comments
 (0)