Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/akshat-kumar-work/learning-monitoring
learning monitoring,logging,alerts from open source libraries like Grafana, Prometheus and Loki as alternative of newrelic
https://github.com/akshat-kumar-work/learning-monitoring
grafana loki prometheus
Last synced: about 1 month ago
JSON representation
learning monitoring,logging,alerts from open source libraries like Grafana, Prometheus and Loki as alternative of newrelic
- Host: GitHub
- URL: https://github.com/akshat-kumar-work/learning-monitoring
- Owner: Akshat-Kumar-work
- Created: 2024-08-29T06:45:22.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-09-02T17:19:29.000Z (4 months ago)
- Last Synced: 2024-10-18T08:56:19.539Z (2 months ago)
- Topics: grafana, loki, prometheus
- Language: JavaScript
- Homepage:
- Size: 43 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PROMETHEUS
- It is an monitoring tool for metrics
- We have to setup prometheus into our code because it is self hosted
- Does not have agents same as Newrelic- Install prom-client
```
npm i prom-client
```- Collect default metrics of server by adding this into main index.js
```
const collectDefaultMetrics = promClient.collectDefaultMetrics;
```- Register the collected metrics
```
collectDefaultMetrics({register:promClient.register});
```- Create api route to provide all collected metrics
```
app.get('/metrics',async(req,res)=>{
//we had set the content type into headers
res.setHeader('Content-Type',promClient.register.contentType);
//get the metrics from promp client
const metrics = await promClient.register.metrics();
//return the metrics in reponse
res.send(metrics);
})
```- Create prometheus-config.yml file and put the bellow data init
```
global:
scrape_interval: 4s #scrap the data after every 4 secondsscrape_configs:
-job_name: prometheus
static_configs:
-targets: [" 192.168.1.16:8000"] #from this local-host/ourIPaddress:port
```- Create docker-compose.yaml for prometheus server
```
version: "3"services:
prom-server:
image: prom/prometheus
ports:
- 9090:9090
volumes:
- ./prometheus-config.yml:/etc/prometheus/prometheus.yaml
```# GRAFANA
- It is used for metrics-visualization
- It uses the metrics which was scrapped by prometheus server
- It integrate the prometheus into its service- To run the grafana image directly into docker from CLI
```
docker run -d -p 3000:3000 --name=grafana grafana/grafana-oss
```
- To run from docker-compose
```
grafana:
image: grafana/grafana-oss
container_name: grafana
ports:
- 3000:3000
restart: always
```