-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #106. Automating Kibana DataView creation
- Loading branch information
Showing
4 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
kubernetes/platform/elastic-stack/app/components/kibana-config/kibana-configuration-cm.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: kibana-config-data | ||
data: | ||
wait-for-kibana.sh: | | ||
#!/bin/sh | ||
# Wait for Kibana to be available & healthy | ||
echo "Testing connection to Kibana" | ||
until $(curl -k -X GET http://${KIBANA_URL}:${KIBANA_PORT}/_cluster/health); do sleep 5; done | ||
until [ "$(curl -k -X GET http://${KIBANA_URL}:${KIBANA_PORT}/_cluster/health | wc -l)" == "0" ] | ||
do sleep 5 | ||
done | ||
create-data-view.sh: | | ||
#!/bin/sh | ||
#Import data view | ||
echo "Importing data_view..." | ||
curl -u elastic:${ELASTICSEARCH_PASSWORD} \ | ||
-X POST http://${KIBANA_URL}:${KIBANA_PORT}/api/data_views/data_view \ | ||
-H 'Content-Type: application/json; Elastic-Api-Version=2023-10-31' \ | ||
-H 'kbn-xsrf: string' \ | ||
-d ' | ||
{ | ||
"data_view": { | ||
"name": "fluentd", | ||
"title": "fluentd-*", | ||
"timeFieldName": "@timestamp" | ||
} | ||
} | ||
' |
45 changes: 45 additions & 0 deletions
45
kubernetes/platform/elastic-stack/app/components/kibana-config/kibana-configuration-job.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: kibana-config-job | ||
spec: | ||
parallelism: 1 | ||
completions: 1 | ||
template: | ||
spec: | ||
restartPolicy: Never | ||
initContainers: | ||
- name: wait-for-kibana | ||
image: alpine/curl:latest | ||
imagePullPolicy: IfNotPresent | ||
env: | ||
- name: KIBANA_URL | ||
value: efk-kb-http | ||
- name: KIBANA_PORT | ||
value: "5601" | ||
command: ["/bin/sh","/kibana/wait-for-kibana.sh"] | ||
volumeMounts: | ||
- name: kibana-config-data | ||
mountPath: /kibana/ | ||
containers: | ||
- name: kibana-config-job | ||
image: alpine/curl:latest | ||
env: | ||
- name: ELASTICSEARCH_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: efk-es-elastic-user | ||
key: elastic | ||
- name: KIBANA_URL | ||
value: efk-kb-http | ||
- name: KIBANA_PORT | ||
value: "5601" | ||
command: ["/bin/sh","/kibana/create-data-view.sh"] | ||
volumeMounts: | ||
- name: kibana-config-data | ||
mountPath: /kibana/ | ||
volumes: | ||
- name: kibana-config-data | ||
configMap: | ||
name: kibana-config-data | ||
defaultMode: 0777 |
6 changes: 6 additions & 0 deletions
6
kubernetes/platform/elastic-stack/app/components/kibana-config/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: kustomize.config.k8s.io/v1alpha1 | ||
kind: Component | ||
|
||
resources: | ||
- kibana-configuration-cm.yaml | ||
- kibana-configuration-job.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters