diff --git a/examples/README.md b/examples/README.md index ae4198a4..319745de 100644 --- a/examples/README.md +++ b/examples/README.md @@ -3,4 +3,21 @@ Please refer to the Unified Observability in Grafana with converged Oracle Database Workshop at http://bit.ly/unifiedobservability and it's corresponding repos https://github.com/oracle/microservices-datadriven/tree/main/grabdish/observability/db-metrics-exporter for complete examples. +A simple setup in Kubernetes involves the following steps (with the assumption that Prometheus is already installed) + +1. Change the %EXPORTER_NAME% value in all yaml files in this directory. This can be any value such as "helloworld". + +2. Change the database connection information in the unified-observability-exporter-deployment.yaml file. + - The only value required is the DATA_SOURCE_NAME which takes the format `USER/PASSWORD@DB_SERVICE_URL` + - In the example the connection information is obtained from a mount created from the wallet obtained from a Kubernetes secret named `%db-wallet-secret%` + - In the example the password is obtained from a Kubernetes secret named `dbuser` + +3. Copy a config file to unified-observability-%EXPORTER_NAME%-exporter-metrics.toml in currently directly + - Eg, `cp ../metrics/aq-metrics.toml unified-observability-helloworld-exporter-metrics.toml` + - This will be used to create a configmap that is referenced in the deployment. + +4. Run `./update-and-redeploy-unified-observabiity-exporter.sh` + +5. You should see metrics being exported from within the container at http://localhost:9161/metrics and likewise from the Kubnernetes service at http://unified-observability-exporter-service-%EXPORTER_NAME%:9161/metrics + More examples will be provided here in the near future. diff --git a/examples/unified-observability-exporter-deployment.yaml b/examples/unified-observability-exporter-deployment.yaml new file mode 100644 index 00000000..02ff0c5c --- /dev/null +++ b/examples/unified-observability-exporter-deployment.yaml @@ -0,0 +1,49 @@ +## Copyright (c) 2021 Oracle and/or its affiliates. +## Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: unified-observability-exporter-%EXPORTER_NAME% +spec: + replicas: 1 + selector: + matchLabels: + app: unified-observability-exporter-%EXPORTER_NAME% + template: + metadata: + labels: + app: unified-observability-exporter-%EXPORTER_NAME% + spec: + containers: + - name: unified-observability-exporter-%EXPORTER_NAME% + image: container-registry.oracle.com/database/observability-exporter:0.1.0 + imagePullPolicy: Always + env: + - name: DEFAULT_METRICS + value: /observability/unified-observability-%EXPORTER_NAME%-exporter-metrics.toml + - name: TNS_ADMIN + value: "/creds" + - name: dbpassword + valueFrom: + secretKeyRef: + name: dbuser + key: dbpassword + optional: true + - name: DATA_SOURCE_NAME + value: "%USER%/$(dbpassword)@%PDB_NAME%_tp" + volumeMounts: + - name: creds + mountPath: /creds + - name: config-volume + mountPath: /observability/unified-observability-%EXPORTER_NAME%-exporter-metrics.toml + subPath: unified-observability-%EXPORTER_NAME%-exporter-metrics.toml + ports: + - containerPort: 8080 + restartPolicy: Always + volumes: + - name: creds + secret: + secretName: %db-wallet-secret% + - name: config-volume + configMap: + name: unified-observability-%EXPORTER_NAME%-exporter-config \ No newline at end of file diff --git a/examples/unified-observability-exporter-service.yaml b/examples/unified-observability-exporter-service.yaml new file mode 100644 index 00000000..cc03655b --- /dev/null +++ b/examples/unified-observability-exporter-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: unified-observability-exporter-service-%EXPORTER_NAME% + labels: + app: unified-observability-exporter-%EXPORTER_NAME% + release: stable +spec: + type: NodePort + ports: + - port: 9161 + name: metrics + selector: + app: unified-observability-exporter-%EXPORTER_NAME% diff --git a/examples/unified-observability-exporter-servicemonitor.yaml b/examples/unified-observability-exporter-servicemonitor.yaml new file mode 100644 index 00000000..2d44b96f --- /dev/null +++ b/examples/unified-observability-exporter-servicemonitor.yaml @@ -0,0 +1,14 @@ +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: prometheus-unified-observability-exporter-%EXPORTER_NAME% + labels: + app: unified-observability-exporter-%EXPORTER_NAME% + release: stable +spec: + endpoints: + - interval: 20s + port: metrics + selector: + matchLabels: + app: unified-observability-exporter-%EXPORTER_NAME% \ No newline at end of file diff --git a/examples/update-and-redeploy-unified-observabiity-exporter.sh b/examples/update-and-redeploy-unified-observabiity-exporter.sh new file mode 100755 index 00000000..5c6795e1 --- /dev/null +++ b/examples/update-and-redeploy-unified-observabiity-exporter.sh @@ -0,0 +1,17 @@ +#!/bin/bash +## Copyright (c) 2021 Oracle and/or its affiliates. +## Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ + +# add namespace if/as appropriate, eg `kubectl apply -f unified-observability-exporter-deployment.yaml-n mynamespace` + +echo delete previous deployment so that deployment is reapplied/deployed after configmap changes for exporter are made... +kubectl delete deployment db-metrics-exporter-orderpdb + +echo create configmap for unified-observability-exporter... +kubectl delete configmap unified-observability-exporter-config +kubectl create configmap unified-observability-exporter-config --from-file=unified-observability-%EXPORTER_NAME%-exporter-metrics.toml + +kubectl apply -f unified-observability-exporter-deployment.yaml +# the following are unnecessary after initial deploy but in order to keep to a single bash script... +kubectl apply -f unified-observability-exporter-service.yaml +kubectl apply -f unified-observability-exporter-servicemonitor.yaml