Thursday, March 17, 2022

Prometheus

Prometheus

 

https://www.youtube.com/watch?v=KY0Kzmm_928


What is Prometheus?
Primarily used for metrics monitoring
It use PromQL.
Prometheus is a pull based metric monitoring system which need the location of endpoint.
endpoint need to exposed.  

Monitoring Using Premetheus
Monitoring Kubernetes cluster
Query time series data to generate graphs, tables
create alerts
Open source

Where does Prometheus Live?
Port 9090

Node exporter
Port 9100

 

Downloading and running Prometheus
https://prometheus.io/download/#prometheus

wget https://github.com/prometheus/prometheus/releases/download/v2.34.0/prometheus-2.34.0.linux-amd64.tar.gz

https://prometheus.io/docs/prometheus/latest/getting_started/


Configuring Prometheus to monitor itself
check config in below yml file
prometheus.yml

Starting Prometheus
./prometheus --config.file=prometheus.yml

Node exporter
Targets means node exporter
or any other exporter so we use node exporter


https://prometheus.io/docs/guides/node-exporter/

wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz

Starting Prometheus
./node_exporter

After starting Node Exporter,
Need to inform on prometheus about Node exporter
and ask to collect data.

How to configure role?
If you want to see granular data,
like daywise or weekly, you can check this data with query also.
But when you run query, it process all data in realtime, then it show result.
so here process run for this task can slow your server etc.

so if you already aware you gonna see weekly or daily particular data.
you can create a rule for that, and rule will only store the processed
data result in prometheus.

Configure rules for aggregating scraped data into new time series

groups:
- name: cpu-node
  rules:
  - record: job_instance_mode:node_cpu_seconds:avg_rate5m
    expr: avg by (job, instance, mode) (rate(node_cpu_seconds_total[5m]))

in record - (we are giving name of metric)
in expr - we have query

go to prometheus folder, create 1 file
file name - cpunode.yml
pass above yml code

go to prometheus.yml file
give path under rule_files:
rule_files:
   - "cpunode.yml"


now restart prometheus

Now if we run above record - job_instance_mode:node_cpu_seconds:avg_rate5m
it will give us directly result

How to connect Prometheus with Grafana?

Prometheus in hindi

https://www.youtube.com/watch?v=UbfpughYouw&t=69s

Prometheus - its data store - it can store any kind of data -
data like - cpu, apps, disk space -
if not given any database -
it will store the data - /var/lib/prometheus
it will install and store data on above location
Port - 9090

How give data to Prometheus
2 below agents
E.S.(elastic search)
Cadvisor
both task to bring data - give to prometheus
so prometheus filter the data by itself
and start showing on prometheus
 like cpu data
 health check data

so promethus keep data on its end in this way
data is kind of query data

But how you its visible?
That will be done by grafana.

Grafana basically read that data and give visual

Exporter
data can come 2 way
1. Local data
2. Exporter - it will collect data from server A and B
app data, jenkins app metric. and put in datastore

Export type
Http, Node
Ever application have node-exporter
Node -exporter - go and write data to the prometheus.

How brings data in Prometheus ?

Node exporter


https://www.youtube.com/watch?v=1fiq2yPQhXs&list=PLdsu0umqbb8NxUs8r8BIUe9-PhcoZyojA&index=17

No comments:

Post a Comment