Kubernetes Classroom Series – 24/Aug/2021

Running Prometheus

  • Lets try to run Prometheus on a Linux machine
  • Lets create a vm
  • Download the linux tar file Refer Here Preview
  • Now in the prometheus.yml file ensure you have the following content
# my global config
global:
  scrape_interval: 10s 
scrape_configs:
  - job_name: "prometheus"
    static_configs:
      - targets: ["localhost:9090"]
  • Now lets try to run prometheus Preview Preview Preview Preview

  • Open the prometheus expression browser and execute up Preview

  • There is a single result with value 1 and the name up{instance="localhost:9090", job="prometheus"}.

  • up is a special metric added by Prometheus when it performsa scrape and 1 indicates that the scrape was succesful. Then instance is a label, indicating the target wthat was scrapted and the job label here comes from job_name in the prometheus.yml file Preview

  • Lets try to download a Node exporter Refer Here

    • untar the exporter and try to run the node exporter with ./node_exporter
    • Now access the metrics from node exporter http://<ip&gt;:9100
  • Now lets add some more info to the prometheus.yml to scrape node metrics exported by node exporter

global:
  scrape_interval: 10s 
scrape_configs:
  - job_name: "prometheus"
    static_configs:
      - targets: ["localhost:9090"]
  - job_name: node
    static_configs:
      - targets: ["localhost:9100"]
  • and restart prometheus (./prometheus) Preview Preview Preview

  • Now lets try to add some alert manager configuration

global:
  scrape_interval: 10s 

alerting:
  alertmanagers:
    - static_configs:
        - localhost:9093
scrape_configs:
  - job_name: "prometheus"
    static_configs:
      - targets: ["localhost:9090"]
  - job_name: node
    static_configs:
      - targets: ["localhost:9100"]
  • Now create a new file called as rules.yaml
groups:
  - name: example
    rules:
      - alert: InstanceDown
        expr: up == 0
        for: 1m
  • Now Download the alertmanager and configure the alert manager.yaml file

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin