3.1. Metrics User Guide

3.1.1. Setup Prerequisites

  • Require 3 VMs to setup K8s

  • $ sudo yum install ansible

  • $ pip install openshift pyyaml kubernetes (required for ansible K8s module)

  • Update IPs in all these files (if changed)
    • ansible-server/group_vars/all.yml (IP of apiserver and hostname)

    • ansible-server/hosts (IP of VMs to install)

    • ansible-server/roles/monitoring/files/grafana/grafana-pv.yaml (IP of NFS-Server)

    • ansible-server/roles/monitoring/files/alertmanager/alertmanager-config.yaml (IP of alert-receiver) Setup Structure

../../_images/setup1.png Installation - Client Side Nodes

  • Node1 =

  • Node4 = How installation is done?

Ansible playbook available in tools/lma/ansible-client folder

  • cd tools/lma/ansible-client

  • ansible-playbook setup.yaml

This deploys collectd and configures it to send data to collectd exporter configured at (ip address of current instance of collectd-exporter) Please make appropriate changes in the config file present in tools/lma/ansible-client/roles/collectd/files/ Installation - Server Side Nodes

Inside Jumphost - POD12
  • VM1 =

  • VM2 =

  • VM3 = How installation is done?

Using Ansible:
  • K8s
    • Prometheus: 2 independent deployments

    • Alertmanager: 2 independent deployments (cluster peers)

    • Grafana: 1 Replica deployment

    • cAdvisor: 1 daemonset, i.e 3 replicas, one on each node

    • collectd-exporter: 1 Replica

    • node-exporter: 1 statefulset with 3 replicas

    • kube-state-metrics: 1 deployment

  • NFS Server: at each VM to store grafana data at following path
    • /usr/share/monitoring_data/grafana How to setup?

  • To setup K8s cluster, EFK and PAG: Run the ansible-playbook ansible/playbooks/setup.yaml

  • To clean everything: Run the ansible-playbook ansible/playbooks/clean.yaml Do we have HA?


3.1.2. Configuration K8s Path to all yamls (Server Side)

tools/lma/ansible-server/roles/monitoring/files/ K8s namespace

monitoring Configuration Serivces and Ports

Services and their ports are listed below, one can go to IP of any node on the following ports, service will correctly redirect you
















30130 How to change Configuration?

  • Ports, names of the containers, pretty much every configuration can be modified by changing the required values in the respective yaml files (/tools/lma/ansible-server/roles/monitoring/)

  • For metrics, on the client’s machine, edit the collectd’s configuration (jinja2 template) file, and add required plugins (/tools/lma/ansible-client/roles/collectd/files/collectd.conf.j2). For more details refer this Where to send metrics?

Metrics are sent to collectd exporter. UDP packets are sent to port 38026 (can be configured and checked at tools/lma/ansible-server/roles/monitoring/files/collectd-exporter/collectd-exporter-deployment.yaml)

3.1.3. Data Management DataFlow:

../../_images/dataflow.png Where is the data stored now?

  • Grafana data (including dashboards) ==> On master, at /usr/share/monitoring_data/grafana (its accessed by Presistent volume via NFS)

  • Prometheus Data ==> On VM2 and VM3, at /usr/share/monitoring_data/prometheus

Note: Promethei data also are independent of each other, a shared data solution gave errors Do we have backup of data?

Promethei even though independent scrape same targets, have same alert rules, therefore generate very similar data.

Grafana’s NFS part of the data has no backup Dashboards’ json are available in the /tools/lma/metrics/dashboards directory When containers are restarted, the data is still accessible?

Yes, unless the data directories are deleted (/usr/share/monitoring_data/*) from each node

3.1.4. Alert Management Configure Alert receiver

  • Go to file /tools/lma/ansible-server/roles/monitoring/files/alertmanager/alertmanager-config.yaml

  • Under the config.yml section under receivers, add, update, delete receivers

  • Currently ip of unified alert receiver is used.

  • Alertmanager supports multiple types of receivers, you can get a list here Add new alerts

  • Go to file /tools/lma/ansible-server/roles/monitoring/files/prometheus/prometheus-config.yaml

  • Under the data section alert.rules file is mounted on the config-map.

  • In this file alerts are divided in 4 groups, namely:
    • targets

    • host and hardware

    • container

    • kubernetes

  • Add alerts under exisiting group or add new group. Please follow the structure of the file for adding new group

  • To add new alert:
    • Use the following structure:

      alert: alertname

      expr: alert rule (generally promql conditional query)

      for: time-range (eg. 5m, 10s, etc, the amount of time the condition needs to be true for the alert to be triggered)


      severity: critical (other severity options and other labels can be added here)

      type: hardware


      summary: <summary of the alert>

      description: <descibe the alert here>

  • For an exhaustive alerts list you can have a look here

3.1.5. Troubleshooting No metrics received in grafana plot

  • Check if all configurations are correctly done.

  • Go to main-prometheus’s port and any one VMs’ ip, and check if prometheus is getting the metrics

  • If prometheus is getting them, read grafana’s logs (kubectl -n monitoring logs <name_of_grafana_pod>)

  • Else, have a look at collectd exporter’s metrics endpoint (eg.

  • If collectd is getting them, check prometheus’s config file if collectd’s ip is correct over there.

  • Else ssh to master, check which node collectd-exporter is scheduled (lets say vm2)

  • Now ssh to vm2

  • Use tcpdump -i ens3 #the interface used to connect to the internet > testdump

  • Grep your client node’s ip and check if packets are reaching our monitoring cluster (cat testdump | grep <ip of client>)

  • Ideally you should see packets reaching the node, if so please see if the collectd-exporter is running correctly, check its logs.

  • If no packets are received, error is on the client side, check collectd’s config file and make sure correct collectd-exporter ip is used in the <network> section. If no notification received

  • Go to main-prometheus’s port and any one VMs’ ip,(eg. and check if prometheus is getting the metrics

  • If no, read “No metrics received in grafana plot” section, else read ahead.

  • Check IP of alert-receiver, you can see this by going to alertmanager-ip:port and check if alertmanager is configured correctly.

  • If yes, paste the alert rule in the prometheus’ query-box and see if any metric staisfy the condition.

  • You may need to change alert rules in the alert.rules section of prometheus-config.yaml if there was a bug in the alert’s rule. (please read the “Add new alerts” section for detailed instructions)