Setup a Single Solr exporter, for all instances of Solr Statefulsets running in different namespaces in a Kubernetes Cluster

8/19/2021

In our Project, we are using Solr exporter to fetch Solr metrics like heap usage and send it to Prometheus. We have configured alert manager to fire alert when Solr heap usage exceeds 80%. This application is configured for all instances.

Is there a way we can configure a common Solr exporter which will fetch Solr metrics from all instances which are in different namespaces in that cluster.? (This is reduce the resource consumption in kuberenetes caused by multiple solr exporter instances.)

YAML configs for solr exporter given below:

             apiVersion: v1
             kind: Service
             metadata:
               name: solr-exporter
               labels:
                 app: solr-exporter
             spec:
               ports:
               - port: 9983
                 name: client 
               selector:    
                 app: solr
             ---
             apiVersion: apps/v1
             kind: Deployment
             metadata:
               labels:
                 app: solr
               name: solr-exporter
               namespace: default  
             spec:
               progressDeadlineSeconds: 600
               replicas: 1
               revisionHistoryLimit: 10
               selector:
                 matchLabels:
                   app: solr       
                   pod: solr-exporter
               strategy:
                 rollingUpdate:
                   maxSurge: 25%
                   maxUnavailable: 25%
                 type: RollingUpdate
               template:
                 metadata:
                   creationTimestamp: null
                   labels:
                     app: solr
                     pod: solr-exporter        
                 spec:
                   containers:
                   - command:
                     - /bin/bash
                     - -c
                     - /opt/solr/contrib/prometheus-exporter/bin/solr-exporter -p 9983 -z zk-cs:2181
                       -n 7 -f /opt/solr/contrib/prometheus-exporter/conf/solr-exporter-config.xml
                     image: solr:8.1.1
                     imagePullPolicy: Always
                     livenessProbe:
                       failureThreshold: 3
                       httpGet:
                         path: /metrics
                         port: 9983
                         scheme: HTTP
                       initialDelaySeconds: 480
                       periodSeconds: 5
                       successThreshold: 1
                       timeoutSeconds: 5
                     name: solr-exporter
                     ports:
                     - containerPort: 9983
                       protocol: TCP
                     readinessProbe:
                       failureThreshold: 2
                       httpGet:
                         path: /metrics
                         port: 9983
                         scheme: HTTP
                       initialDelaySeconds: 60
                       periodSeconds: 5
                       successThreshold: 1
                       timeoutSeconds: 5
                     resources:
                       limits:
                         cpu: 500m
                       requests:
                         cpu: 50m
                         memory: 64Mi
                     terminationMessagePath: /dev/termination-log
                     terminationMessagePolicy: File
                     volumeMounts:
                     - mountPath: /opt/solr/contrib/prometheus-exporter/conf/solr-exporter-config.xml
                       name: solr-exporter-config
                       readOnly: true
                       subPath: solr-exporter-config.xml
                   dnsPolicy: ClusterFirst
                   initContainers:
                   - command:
                     - sh
                     - -c
                     - |-
                       apt-get update
                                   apt-get install curl -y
                                   PROTOCOL="http://"
                                   COUNTER=0;
                                   while [  $COUNTER -lt 30 ]; do
                                   curl -v -k -s --connect-timeout 10 "${PROTOCOL}solrcluster:8983/solr/admin/info/system" && exit 0
                                   sleep 2
                                   done;
                                   echo "Did NOT see a Running Solr instance after 60 secs!";
                                   exit 1;
                     image: solr:8.1.1
                     imagePullPolicy: Always
                     name: mpi-demo-solr-exporter-init
                     resources: {}
                     securityContext:
                       runAsUser: 0
                     terminationMessagePath: /dev/termination-log
                     terminationMessagePolicy: File
                   restartPolicy: Always
                   schedulerName: default-scheduler
                   securityContext: {}
                   terminationGracePeriodSeconds: 30
                   volumes:
                   - configMap:
                       defaultMode: 420
                       name: solr-exporter-config
                     name: solr-exporter-config
-- Paul Joseph
google-kubernetes-engine
kubernetes
prometheus
solr

0 Answers