Skip to content

Commit b4cf18c

Browse files
authored
Merge pull request #63 from matrober-uk/openshift
Samples and instructions for monitoring in OpenShift
2 parents 6474fb5 + 66ad943 commit b4cf18c

File tree

4 files changed

+148
-0
lines changed

4 files changed

+148
-0
lines changed

cp4i/README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Monitoring metrics in Cloud Pak for Integration
2+
This directory contains sample files that show how to deploy the Prometheus
3+
monitor to expose queue metrics for a queue manager running in a Cloud Pak for
4+
Integration deployment on Red Hat OpenShift.
5+
6+
The MQ Certified Container that comes in the Cloud Pak for Integration
7+
emits a range of [queue manager (server) scope metrics](https://www.ibm.com/docs/en/ibm-mq/9.2?topic=containers-metrics-published-by-mq-certified) but does not currently offer an option to
8+
publish information about queues or topics, so use of an additional Prometheus monitor pod as
9+
shown below allows queue (and topic) metrics to be published to Prometheus for consumption
10+
by OpenShift monitoring tools.
11+
12+
The steps to do this are as follows;
13+
14+
```
15+
# Build the Prometheus monitor container as normal
16+
cd mq-metric-samples/scripts
17+
./buildRuntime.sh mq_prometheus
18+
19+
# Tag and push the Docker image to the container registry used by your OpenShift cluster
20+
docker tag mq-metric-prometheus:5.2.0 your.repo/your-namespace/mq-metric-prometheus:1.0
21+
docker push your.repo/your-namespace/mq-metric-prometheus:1.0
22+
23+
# Create a ConfigMap and Secret to configure the settings that you wish to apply to your monitor.
24+
# Update these to suit your requirements
25+
oc create configmap metrics-configuration \
26+
--from-literal=IBMMQ_CONNECTION_QUEUEMANAGER='QM1' \
27+
--from-literal=IBMMQ_CONNECTION_CONNNAME='quickstart-cp4i-ibm-mq(1414)' \
28+
--from-literal=IBMMQ_CONNECTION_CHANNEL='SYSTEM.DEF.SVRCONN' \
29+
--from-literal=IBMMQ_OBJECTS_QUEUES='*,!SYSTEM.*,!AMQ.*' \
30+
--from-literal=IBMMQ_OBJECTS_SUBSCRIPTIONS='!$SYS*' \
31+
--from-literal=IBMMQ_OBJECTS_TOPICS='!*' \
32+
--from-literal=IBMMQ_GLOBAL_USEPUBLICATIONS=false \
33+
--from-literal=IBMMQ_GLOBAL_USEOBJECTSTATUS=true \
34+
--from-literal=IBMMQ_GLOBAL_CONFIGURATIONFILE='' \
35+
--from-literal=IBMMQ_GLOBAL_LOGLEVEL=INFO
36+
37+
oc create secret generic metrics-credentials \
38+
--from-literal=IBMMQ_CONNECTION_USER='dummyuser' \
39+
--from-literal=IBMMQ_CONNECTION_PASSWORD='dummypassword'
40+
41+
42+
43+
# Use the samples in this directory to deploy the Prometheus container to OpenShift
44+
cd mq-metric-samples/cp4i
45+
46+
# Create a new ServiceAccount that will ensure the metrics pod is
47+
# deployed using the most secure Restricted SCC
48+
oc apply -f sa-pod-deployer.yaml
49+
50+
# Update the spec.containers.image attribute in metrics-pod.yaml to match
51+
# your container registry and image name using a text editor
52+
vi metrics-pod.yaml
53+
54+
# Deploy the metrics pod using the service account
55+
oc apply -f ./metrics-pod.yaml --as=my-service-account
56+
57+
# Create a Service object that exposes the metrics pod so that it can
58+
# be discovered by monitoring tools that are looking for Prometheus endpoints
59+
#
60+
# Note that the spec.selector.app matches the metadata.labels.app property
61+
# defined in metrics-pod.yaml
62+
oc apply -f ./metrics-service.yaml
63+
```
64+
65+
66+
Once the metrics pod is deployed you can see it in action by looking at the logs
67+
for the pod, and the "IBMMQ Collect" statements showing that the metrics are being
68+
scraped by the Prometheus agent running in your OpenShift cluster.
69+
```
70+
oc logs mq-metric-prometheus
71+
72+
73+
IBM MQ metrics exporter for Prometheus monitoring
74+
Build : 20210410-173628
75+
Commit Level : 3dd2c0d
76+
Build Platform: Darwin/
77+
78+
time="2021-04-13T20:12:52Z" level=info msg="Trying to connect as client using ConnName: quickstart-cp4i-ibm-mq(1414), Channel: SYSTEM.DEF.SVRCONN"
79+
time="2021-04-13T20:12:52Z" level=info msg="Connected to queue manager QM1"
80+
time="2021-04-13T20:12:52Z" level=info msg="IBMMQ Describe started"
81+
time="2021-04-13T20:12:52Z" level=info msg="Platform is UNIX"
82+
time="2021-04-13T20:12:52Z" level=info msg="Listening on http address :9157"
83+
time="2021-04-13T20:12:55Z" level=info msg="IBMMQ Collect started 14000001720300"
84+
time="2021-04-13T20:12:55Z" level=info msg="Collection time = 0 secs"
85+
time="2021-04-13T20:13:55Z" level=info msg="IBMMQ Collect started 14000003035700"
86+
time="2021-04-13T20:13:55Z" level=info msg="Collection time = 0 secs"
87+
```

cp4i/metrics-pod.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: mq-metric-prometheus
5+
labels:
6+
app: mq-metric-prometheus-app
7+
spec:
8+
containers:
9+
- name: mq-metric-prometheus
10+
image: uk.icr.io/my-icr-namespace/mq-metric-prometheus:1.0
11+
envFrom:
12+
- configMapRef:
13+
name: metrics-configuration
14+
- secretRef:
15+
name: metrics-credentials
16+
restartPolicy: OnFailure
17+
imagePullSecrets:
18+
- name: all-icr-io

cp4i/metrics-service.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: mq-metric-prometheus-service
5+
annotations:
6+
prometheus.io/scrape: 'true'
7+
prometheus.io/port: '9157'
8+
labels:
9+
app: mq-metric-prometheus
10+
spec:
11+
ports:
12+
- name: metrics
13+
port: 9157
14+
targetPort: 9157
15+
protocol: TCP
16+
selector:
17+
app: mq-metric-prometheus-app
18+
type: ClusterIP

cp4i/sa-pod-deployer.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: my-service-account
5+
---
6+
kind: Role
7+
apiVersion: rbac.authorization.k8s.io/v1
8+
metadata:
9+
name: pod-interactions
10+
rules:
11+
- apiGroups: [""]
12+
resources: ["pods", "pods/exec"]
13+
verbs: ["get", "list", "delete", "patch", "create"]
14+
---
15+
apiVersion: rbac.authorization.k8s.io/v1
16+
kind: RoleBinding
17+
metadata:
18+
name: pod-interactions
19+
subjects:
20+
- kind: User
21+
name: my-service-account
22+
roleRef:
23+
kind: Role
24+
name: pod-interactions
25+
apiGroup: rbac.authorization.k8s.io

0 commit comments

Comments
 (0)