Skip to content

Commit 71d868f

Browse files
basic example (#13)
* add list of default metrics in readme * readme updates * various updates * README.md updates * README.md updates * basic example
1 parent f4567a5 commit 71d868f

5 files changed

+111
-0
lines changed

examples/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,21 @@
33

44
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.
55

6+
A simple setup in Kubernetes involves the following steps (with the assumption that Prometheus is already installed)
7+
8+
1. Change the %EXPORTER_NAME% value in all yaml files in this directory. This can be any value such as "helloworld".
9+
10+
2. Change the database connection information in the unified-observability-exporter-deployment.yaml file.
11+
- The only value required is the DATA_SOURCE_NAME which takes the format `USER/PASSWORD@DB_SERVICE_URL`
12+
- In the example the connection information is obtained from a mount created from the wallet obtained from a Kubernetes secret named `%db-wallet-secret%`
13+
- In the example the password is obtained from a Kubernetes secret named `dbuser`
14+
15+
3. Copy a config file to unified-observability-%EXPORTER_NAME%-exporter-metrics.toml in currently directly
16+
- Eg, `cp ../metrics/aq-metrics.toml unified-observability-helloworld-exporter-metrics.toml`
17+
- This will be used to create a configmap that is referenced in the deployment.
18+
19+
4. Run `./update-and-redeploy-unified-observabiity-exporter.sh`
20+
21+
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
22+
623
More examples will be provided here in the near future.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
## Copyright (c) 2021 Oracle and/or its affiliates.
2+
## Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
apiVersion: apps/v1
4+
kind: Deployment
5+
metadata:
6+
name: unified-observability-exporter-%EXPORTER_NAME%
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: unified-observability-exporter-%EXPORTER_NAME%
12+
template:
13+
metadata:
14+
labels:
15+
app: unified-observability-exporter-%EXPORTER_NAME%
16+
spec:
17+
containers:
18+
- name: unified-observability-exporter-%EXPORTER_NAME%
19+
image: container-registry.oracle.com/database/observability-exporter:0.1.0
20+
imagePullPolicy: Always
21+
env:
22+
- name: DEFAULT_METRICS
23+
value: /observability/unified-observability-%EXPORTER_NAME%-exporter-metrics.toml
24+
- name: TNS_ADMIN
25+
value: "/creds"
26+
- name: dbpassword
27+
valueFrom:
28+
secretKeyRef:
29+
name: dbuser
30+
key: dbpassword
31+
optional: true
32+
- name: DATA_SOURCE_NAME
33+
value: "%USER%/$(dbpassword)@%PDB_NAME%_tp"
34+
volumeMounts:
35+
- name: creds
36+
mountPath: /creds
37+
- name: config-volume
38+
mountPath: /observability/unified-observability-%EXPORTER_NAME%-exporter-metrics.toml
39+
subPath: unified-observability-%EXPORTER_NAME%-exporter-metrics.toml
40+
ports:
41+
- containerPort: 8080
42+
restartPolicy: Always
43+
volumes:
44+
- name: creds
45+
secret:
46+
secretName: %db-wallet-secret%
47+
- name: config-volume
48+
configMap:
49+
name: unified-observability-%EXPORTER_NAME%-exporter-config
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: unified-observability-exporter-service-%EXPORTER_NAME%
5+
labels:
6+
app: unified-observability-exporter-%EXPORTER_NAME%
7+
release: stable
8+
spec:
9+
type: NodePort
10+
ports:
11+
- port: 9161
12+
name: metrics
13+
selector:
14+
app: unified-observability-exporter-%EXPORTER_NAME%
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: monitoring.coreos.com/v1
2+
kind: ServiceMonitor
3+
metadata:
4+
name: prometheus-unified-observability-exporter-%EXPORTER_NAME%
5+
labels:
6+
app: unified-observability-exporter-%EXPORTER_NAME%
7+
release: stable
8+
spec:
9+
endpoints:
10+
- interval: 20s
11+
port: metrics
12+
selector:
13+
matchLabels:
14+
app: unified-observability-exporter-%EXPORTER_NAME%
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
## Copyright (c) 2021 Oracle and/or its affiliates.
3+
## Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
4+
5+
# add namespace if/as appropriate, eg `kubectl apply -f unified-observability-exporter-deployment.yaml-n mynamespace`
6+
7+
echo delete previous deployment so that deployment is reapplied/deployed after configmap changes for exporter are made...
8+
kubectl delete deployment db-metrics-exporter-orderpdb
9+
10+
echo create configmap for unified-observability-exporter...
11+
kubectl delete configmap unified-observability-exporter-config
12+
kubectl create configmap unified-observability-exporter-config --from-file=unified-observability-%EXPORTER_NAME%-exporter-metrics.toml
13+
14+
kubectl apply -f unified-observability-exporter-deployment.yaml
15+
# the following are unnecessary after initial deploy but in order to keep to a single bash script...
16+
kubectl apply -f unified-observability-exporter-service.yaml
17+
kubectl apply -f unified-observability-exporter-servicemonitor.yaml

0 commit comments

Comments
 (0)