forked from fluent/fluent-bit-kubernetes-logging
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlokitest-job.yaml
51 lines (51 loc) · 2.21 KB
/
lokitest-job.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
apiVersion: batch/v1
kind: Job
metadata:
name: lokitest
spec:
backoffLimit: 5
template:
spec:
containers:
- name: lokitest
# Use any image with curl and logcli, or use curlimages/curl and replace logcli use with REST api calls
image: yolean/toil:16986b1488a60eaf2d81a8ff8f8f54f3aeacad1a@sha256:4717a46e082ac5a14da9a3e6e2aa2cd012f94989b2ee3c41ce7d39fa463d9915
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
command:
- /bin/bash
- -cx
- |
alias curl='curl -f -s --retry-connrefused --retry 20'
curl http://loki-ingest:3100/ready
curl http://loki-ingest:3100/metrics | grep memberlist | grep _count | grep -v gauge
curl http://loki-ingest:3100/config
curl http://loki-query:3100/loki/api/v1/labels
curl http://loki-query:3100/loki/api/v1/label/pod/values
function stream1 {
set +x
log=$1; [ -n "$log" ] || log="Logged at $(date -Ins)"
echo '{"streams":[{"stream":{"job":"lokitest"},"values":[["'$(date +%s%N)'","'$log'"]]}]}'
set -x
}
stream1 | jq -c .
t=$(date +%F'T'%T.%N'Z')
curl -H "Content-Type: application/json" -XPOST -w "%{http_code}\n" "http://loki-ingest:3100/loki/api/v1/push" --data-raw "$(stream1)"
export LOKI_ADDR=http://loki-query:3100
logcli query '{job="lokitest"}' --from=$t
# Test distriuted Loki, where ingestion might work while distribution doesn't; check if results differ between pods
for POD_IP in $(getent hosts loki-headless | cut -d' ' -f1); do
echo "# Loki pod IP $POD_IP"
curl -H "Content-Type: application/json" -XPOST -w "%{http_code}\n" "http://$POD_IP:3100/loki/api/v1/push" --data-raw "$(stream1)"
logcli --addr=http://$POD_IP:3100 query '{job="lokitest"}' --from=$t
done
echo "Sleeping for experiments through: kubectl -n $POD_NAMESPACE exec $POD_NAME -ti -- bash"
sleep 3600
restartPolicy: Never