Date: 27 December
Prometheus is an individual open source Metrics and Monitoring tool for your system and services.
Moreover, it is a time series database, but saves your data over time, not every second.
- Processes: Node, Rust, Golang, Solana etc. (not full application)
- Hosts: A full end to end application software
It pulls the data from /metrics endpoint from your application which sends the real time stats of your application, but prometheus polls the system in probably every n seconds and stores in Key Value pairs of our choice which makes it multi dimensional database.
Uses PromQL query.
- Runs on single machine
- Not distributed
- Cannot be scaled horizontally, unfortunately. no remote storage available for different containers or pods.
- In case of ASG's or services that run down before prometheus could even track them down.
Solution: what you can do is use external gateway's that let you push to prometheus forcefully.
Create a simple nodejs application or open your current application.
How to add?
-
Add
prometheus.ymlconfig file to establish a prometheus service. -
Containerise the prometheus service using docker and run it:
docker run -p 9090:9090 -v ./prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
-
Containerize our nodejs application.
-
Create a
docker-compose.ymlfile just to start 2 containers together:- Prometheus container
- Nodejs application
But with same network: Monitoring, so that they can be in same network and use correct port addresses.
An incremental counter that always goes up.
Example: Number of total requests.
Which can go up or also down.
Example: CPU utilisation, Active people using WebSocket.
It is a counter which goes up and down depending upon the user requirements.
If i have million users, i cannot store individual response time each user dealt with rather we create bucket that divides all million users using some parameter.
Key Points:
- For Infinite data
- Cumulative in nature, i.e. increase over time
- The histogram object requires 2 types of data:
- The observation that we want to do over time
- The parameter on which we will be observing, in our case it is time in ms
Example: How many users were responded back under 1 ms, further how many were responded within 5ms or 10ms.
(Coming soon - will add details about Grafana integration)
- Prometheus uses PromQL for querying metrics
- Make sure both containers are on the same network for proper communication
- The
/metricsendpoint should be exposed from your application - Prometheus will automatically scrape metrics at configured intervals