Deploying the SNMP Prometheus Adapter
You can deploy the SNMP Prometheus Adapter in various ways, depending on your MATRIXX environment.
Deployment to Kubernetes
In a Kubernetes environment, the SNMP Prometheus Adapter is designed to run as a sidecar container inside the same pod as the SBA Gateway. The Prometheus metrics can be accessed over HTTP using localhost, but the log files must be written to a shared location, such as a volume, where they can be accessed by both processes.
Figure 1 shows Prometheus metrics written to log files in a shared location.
Configuration
The following shows a sample SNMP Kubernetes configuration for installing the SNMP Prometheus Adapter as a sidecar to the SBA Gateway.
apiVersion: v1
kind: Service
metadata:
name: sba
labels:
app: sba
spec:
ports:
- port: 9098
name: sba5g
clusterIP: None
selector:
app: sba
---
apiVersion: v1
kind: ConfigMap
metadata:
name: snmp-adapter-config
namespace: matrixx
data:
snm-adpater.yaml: |
snmp-adapter:
nms:
default:
host: snmpserver
notificationPort: 162
timeout: 5s
retries: 2
alarms:
logFiles:
- fileName: /var/log/mtx/nf.log
pollingFrequency: 5s
prometheusMetrics:
endpoints:
- url: 'http://localhost:9098/metrics'
pollingFrequency: 5s
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: sba5g
spec:
replicas: 2
selector:
matchLabels:
app: sba
template:
metadata:
labels:
app: sba
spec:
imagePullSecrets:
- name: registrypullsecret
containers:
# SBA CHF
- name: sba
image: r.m0012242008.com:18080/sba-5gc-networkfunctions-chf
ports:
- containerPort: 9098
name: sba5g
env:
- name: nrf.registerWithNrf
value: "true"
- name: nrf.leaderSidecar.enabled
value: "true"
- name: nrf.nrfUris
value: "http://nrf:9098"
volumeMounts:
- mountPath: /var/log/mtx
name: sba-log
# Leader Elect Sidecar
- name: leadersidecar
image: r.m0012242008.com:18080/sba-5gc-networkfunctions-leadersidecar
ports:
- containerPort: 8080
env:
- name: lock.name
value: sba
- name: lock.identity
valueFrom:
fieldRef:
fieldPath: metadata.name
# SNMP Adapter Sidecar
- name: snmpadapter
image: r.m0012242008.com:18080/snmp-adapter
ports:
- containerPort: 5770
protocol: UDP
env:
- name: spring_profiles_active
value: sba
volumeMounts:
- mountPath: /var/log/mtx
name: sba-log
- mountPath: /opt/mtx/conf
name: snmp-adapter-config
volumes:
# Log Directory Shared by the SBA CHF and the SNMP Adapter
- name: sba-logs
emptyDir: {}
# SNMP Adapter Configuration Mount
- name: snmp-adapter-config
configMap:
name: snmp-adapter-config
Troubleshooting the Network Connections
The following networking limitations may apply:
- SNMP server (NMS) must be able to poll the SNMP agent of the SNMP Prometheus Adapter to retrieve the metrics.
- The SNMP Prometheus Adapter is running in a pod, and these instances are created and destroyed as needed. Therefore, there is no fixed set of IP addresses with which the SNMP server (NMS) can be configured. These SNMP servers cannot be configured using only the service as the host, because this would yield polling metrics data from only one pod. The results could depend on which load balancer rules are configured, such as round robin, and so on.
The following Prometheus limitations may apply:
- Prometheus has an issue similar to the networking limitation described above with no fixed set of IP addresses. This issue was solved using an operator that uses the Kubernetes API to fetch the IP addresses of the pods associated with a service. This operator can query each of the pods' endpoints and aggregate the results. The success of this approach depends upon which SNMP server (NMS) implementation you are using.
- If an NMS is configured, the SNMP Prometheus Adapter will send a cold start notification (trap) upon startup. It is possible the SNMP server (NMS) might be able to use this notification to register new instances, but the viability of this approach depends on whether the vendor has implemented this as a feature.
Deployment to Docker
The SNMP Prometheus Adapter application can be run as a standalone Docker image, as shown in the following example:
docker run -e spring_profiles_active=sba -p 5770:5770/udp -v `pwd`/conf:/opt/mtx/conf -v /var/log/mtx:/var/log/mtx r.m0012242008.com:18080/snmp-adapter:5200-SNAPSHOT
This runs a 5200-SNAPSHOT version of the image with the SBA default configuration loaded. It assumes that you have a snmp-adapter.yaml file containing your file and endpoint configuration in a conf sub directory in the same directory as you are running the command from. See Docker CLI: Run for more information and options.
Configuration
The SBA profile is activated by default and a default configuration file is created in the following directory: /opt/mtx/conf/snmp-adapter.yaml.
Logging
The SNMP Prometheus Adapter application logs are written to the log file in the following directory: /var/log/mtx/snmp-adapter.log. The SNMP MIB files can be found in the following directory: /opt/mtx/data/snmp/mibs.