need to apply the prometheus rules from alertmanager repo in k8s

2/3/2020

Have 2 gitlab repos: => gitlab a => gitlab b

gitlab a - contains stateful set and pod of prometheus and prometheus pushgateway

gitlab b - conatins the alertmanager service and alermanager pod and prometheus rules.

all the pods and containers are up and running. am trying to apply the prometheus-rules to the prometheus stateful set. prometheusRule.png

need to apply the Kind:prometheus rule to stateful set of prometheus. can someone help. enter image description here

applied rules yaml :

apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  labels:
    prometheus: k8s
    role: alert-rules
  name: prometheus-k8s-rules
  namespace: cmp-monitoring
spec:
 groups:
  - name: node-exporter.rules
    rules:
    - expr: |
        count without (cpu) (
          count without (mode) (
            node_cpu_seconds_total{job="node-exporter"}
          )
        )
      record: instance:node_num_cpu:sum
    - expr: |
        1 - avg without (cpu, mode) (
          rate(node_cpu_seconds_total{job="node-exporter", mode="idle"}[1m])
        )
      record: instance:node_cpu_utilisation:rate1m

prometheus-statefulset

apiVersion: apps/v1

kind: StatefulSet
metadata:
  name: prometheus
  labels:
    app: prometheus
spec:
  selector:
    matchLabels:
      app: prometheus
  serviceName: prometheus
  replicas: 1
  template:
    metadata:
      labels:
        app: prometheus
    spec:
      terminationGracePeriodSeconds: 10
      containers:
        - name: prometheus
          image: prom/prometheus
          imagePullPolicy: Always
          ports:
            - name: http
              containerPort: 9090
          volumeMounts:
            - name: prometheus-config
              mountPath: "/etc/prometheus/prometheus.yml"
              subPath: prometheus.yml
            - name: prometheus-data
              mountPath: "/prometheus"
            #- name: rules-general
            #  mountPath: "/etc/prometheus/prometheus.rules.yml"
            #  subPath: prometheus.rules.yml
          livenessProbe:
            httpGet:
              path: /-/healthy
              port: 9090
            initialDelaySeconds: 120
            periodSeconds: 40
            successThreshold: 1
            timeoutSeconds: 10
            failureThreshold: 3
          readinessProbe:
            httpGet:
              path: /-/healthy
              port: 9090
            initialDelaySeconds: 120
            periodSeconds: 40
            successThreshold: 1
            timeoutSeconds: 10
            failureThreshold: 3
      securityContext:
        fsGroup: 1000
      volumes:
        - name: prometheus-config
          configMap:
            name: prometheus-server-conf
        #- name: rules-general
        #  configMap:
        #    name: prometheus-server-conf    
  volumeClaimTemplates:
    - metadata:
        name: prometheus-data
      spec:
        accessModes: [ "ReadWriteOnce" ]
        storageClassName: rbd-default
        resources:
          requests:
            storage: 10Gi
-- Joe Pauly
kubernetes
prometheus
prometheus-alertmanager

0 Answers