https://github.com/marcopacini/hello-grafana-prometheus
https://github.com/marcopacini/hello-grafana-prometheus
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/marcopacini/hello-grafana-prometheus
- Owner: marcopacini
- Created: 2020-03-20T11:54:59.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-12-06T22:34:01.000Z (6 months ago)
- Last Synced: 2025-01-28T03:30:35.806Z (4 months ago)
- Language: JavaScript
- Size: 47.9 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# hello-grafana-prometheus
Just a playground for getting started with Prometheus and Grafana.
### Components
- App (node.js)
- Prometheus Server
- Node Exporter
- Grafana Server### Run
```
docker-compose up
```###### Grafana datasources (automatic.yml)
```yml
datasources:
- name: Prometheus
type: prometheus
access: proxy
orgId: 1
url: http://prometheus:9090
```###### App metrics scraping (prometheus.yml)
```yml
scrape_configs:
- job_name: 'app'
scrape_interval: 5s
static_configs:
- targets: ['app:9091']
```###### prom-client
```js
const counter = new prometheus.Counter({
name: 'app_http_request_total',
help: 'http request total metric',
labelNames: ['route', 'method', 'status']
});counter.labels('/path/to/', 'GET', '200').inc();
app.get('/metrics', (_, res) => {
res.set('Content-Type', prometheus.register.contentType)
res.end(prometheus.register.metrics())
})
```### Extra
- After connecting your data source, you can import the **node-exporter** metrics
dashboard just copying its dashboard ID (405) in Grafana: *Create - Import*.